List of usage examples for org.apache.commons.lang3 StringUtils repeat
public static String repeat(final char ch, final int repeat)
From source file:org.openmrs.module.radiology.dicom.DicomUidValidatorTest.java
/** * @see DicomUidValidator#isLengthValid(String) * @verifies return false for uid length bigger than 64 *///from ww w .jav a 2 s .c o m @Test public void isLengthValid_shouldReturnFalseForUidLengthBiggerThan64() throws Exception { String uid = StringUtils.repeat("1.2", 22); assertThat(uid.length(), is(greaterThan(64))); assertFalse(DicomUidValidator.isLengthValid(uid)); }
From source file:org.openmrs.module.radiology.dicom.DicomUidValidatorTest.java
/** * @see DicomUidValidator#isLengthValid(String) * @verifies return true for uid length smaller or equal to 64 *///from w w w.j av a 2 s. c o m @Test public void isLengthValid_shouldReturnTrueForUidLengthSmallerOrEqualTo64() throws Exception { String uid = StringUtils.repeat("1.2", 20); assertThat(uid.length(), is(not(greaterThan(64)))); assertTrue(DicomUidValidator.isLengthValid(uid)); uid = StringUtils.repeat("1.2", 20) + "8317"; assertThat(uid.length(), is(64)); assertTrue(DicomUidValidator.isLengthValid(uid)); }
From source file:org.openmrs.module.radiology.dicom.UuidDicomUidGeneratorTest.java
/** * @see DicomUidGenerator#getNewDicomUid(String) * @verifies throw an illegal argument exception if root is not a valid UID *///from w w w . jav a 2 s . c om @Test public void getNewDicomUid_shouldThrowAnIllegalArgumentExceptionIfRootIsNotAValidUID() throws Exception { // test with invalid root pattern but smaller than 64 characters String root = "1.2.A.1"; expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("root is an invalid DICOM UID"); dicomUidGenerator.getNewDicomUid(root); // test with valid root pattern but exceeding 64 characters root = StringUtils.repeat("1.2", 22); assertThat(root.length(), is(greaterThan(64))); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("root is an invalid DICOM UID"); dicomUidGenerator.getNewDicomUid(root); }
From source file:org.openmrs.module.radiology.dicom.UuidDicomUidGeneratorTest.java
/** * @see DicomUidGenerator#getNewDicomUid(String) * @verifies throw an illegal argument exception if root exceeds the maximum length *///from ww w .j ava 2s .co m @Test public void getNewDicomUid_shouldThrowAnIllegalArgumentExceptionIfRootExceedsTheMaximumLength() throws Exception { String root = StringUtils.repeat("1.2", 10); // ensure root itself is a valid DICOM UID but exceeds max length assertThat(root.length(), is(greaterThan(dicomUidGenerator.getMaxRootLength()))); assertTrue(DicomUidValidator.isPatternValid(root)); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("root length is > " + dicomUidGenerator.getMaxRootLength()); dicomUidGenerator.getNewDicomUid(root); }
From source file:org.openmrs.validator.ConceptSourceValidatorTest.java
@Test public void validate_shouldFailValidationIfFieldLengthsAreNotCorrect() { ConceptSource conceptSource = new ConceptSource(); conceptSource.setName(StringUtils.repeat("a", 51)); conceptSource.setDescription(StringUtils.repeat("a", 1025)); conceptSource.setHl7Code(StringUtils.repeat("a", 51)); conceptSource.setUniqueId(StringUtils.repeat("a", 251)); conceptSource.setRetireReason(StringUtils.repeat("a", 256)); Errors errors = new BindException(conceptSource, "conceptSource"); new ConceptSourceValidator().validate(conceptSource, errors); Assert.assertTrue(errors.hasFieldErrors("name")); Assert.assertTrue(errors.hasFieldErrors("description")); Assert.assertTrue(errors.hasFieldErrors("hl7Code")); Assert.assertTrue(errors.hasFieldErrors("uniqueId")); Assert.assertTrue(errors.hasFieldErrors("retireReason")); }
From source file:org.openmrs.validator.EncounterTypeValidatorTest.java
/** * @see EncounterTypeValidator#validate(Object,Errors) *///from ww w . ja v a 2 s.co m @Test @Verifies(value = "should fail validation if field lengths are not correct", method = "validate(Object,Errors)") public void validate_shouldFailValidationIfFieldLengthsAreNotCorrect() throws Exception { EncounterType type = new EncounterType(); type.setName(StringUtils.repeat("longer than 50 chars", 6)); type.setDescription(StringUtils.repeat("longer than 1024 chars", 120)); type.setRetireReason(StringUtils.repeat("longer than 255 chars", 27)); Errors errors = new BindException(type, "type"); new EncounterTypeValidator().validate(type, errors); Assert.assertTrue(errors.hasFieldErrors("name")); Assert.assertTrue(errors.hasFieldErrors("description")); Assert.assertTrue(errors.hasFieldErrors("retireReason")); }
From source file:org.orbeon.oxf.cache.CacheUtils.java
private static String validityToString(Object validity, int level) { if (validity instanceof Long) { return StringUtils.repeat(" ", INDENTATION * level) + new Date((Long) validity).toString(); } else if (validity instanceof List) { StringBuilder result = new StringBuilder(); result.append(StringUtils.repeat(" ", INDENTATION * level)); result.append("[\n"); for (Iterator i = ((List) validity).iterator(); i.hasNext();) { Object childValidity = i.next(); result.append(validityToString(childValidity, level + 1)); result.append("\n"); }/*from www . j a v a 2s . com*/ result.append(StringUtils.repeat(" ", INDENTATION * level)); result.append("]"); return result.toString(); } else { throw new OXFException("Unsupported validity type: '" + validity.getClass().getName() + "'"); } }
From source file:org.pf4j.demo.Boot.java
private static void printLogo() { logger.info(StringUtils.repeat("#", 40)); logger.info(StringUtils.center("PF4J-DEMO", 40)); logger.info(StringUtils.repeat("#", 40)); }
From source file:org.schedulesdirect.grabber.Grabber.java
private String formatCountries(String json) throws IOException { JSONObject resp = Config.get().getObjectMapper().readValue(json, JSONObject.class); String fmt = "%-15s %15s %3s %-40s%n"; getDisplay().info("Use 'ISO' value when adding lineups to your account."); getDisplay().info(String.format(fmt, "LOCATION", "", "ISO", "EXAMPLE")); getDisplay().info(String.format("%s%n", StringUtils.repeat('=', 76))); getDisplay().info(String.format("%s%n", "North America")); getDisplay().info(String.format(fmt, "", "United States", "USA", "12345")); getDisplay().info(String.format(fmt, "", "Canada", "CAN", "A0A0A0")); return resp.toString(3); }
From source file:org.sejda.core.support.prefix.NameGeneratorTest.java
@Test public void testMaxFilenameSize() { String generatedFilename = nameGenerator("BLA_[TEXT]") .generate(nameRequest("pdf").text(StringUtils.repeat('a', 300))); assertEquals(255, generatedFilename.length()); assertThat(generatedFilename, endsWith("aaa.pdf")); }