List of usage examples for org.apache.commons.lang3 StringUtils repeat
public static String repeat(final char ch, final int repeat)
From source file:com.cloudera.impala.common.PrintUtils.java
/** * Prints the given square matrix into matrixStr. Separates cells by cellSpacing. *//*from w w w . j a va 2 s . com*/ public static void printMatrix(boolean[][] matrix, int cellSpacing, StringBuilder matrixStr) { // Print labels. matrixStr.append(StringUtils.repeat(' ', cellSpacing)); String formatStr = "%Xd".replace("X", String.valueOf(cellSpacing)); for (int i = 0; i < matrix.length; ++i) { matrixStr.append(String.format(formatStr, i)); } matrixStr.append("\n"); // Print matrix. for (int i = 0; i < matrix.length; ++i) { matrixStr.append(String.format(formatStr, i)); for (int j = 0; j < matrix.length; ++j) { int cell = (matrix[i][j]) ? 1 : 0; matrixStr.append(String.format(formatStr, cell)); } matrixStr.append("\n"); } }
From source file:fi.helsinki.opintoni.domain.validation.TodoItemValidationTest.java
@Test public void thatContentIsValidated() { TodoItem todoItem = getTodoItem();/*from w w w. ja va 2s.c o m*/ Set<ConstraintViolation<TodoItem>> result = validate(todoItem); assertThat(result, hasItem(notBlankConstraintViolation("content"))); todoItem.content = " "; result = validate(todoItem); assertThat(result, hasItem(notBlankConstraintViolation("content"))); todoItem.content = StringUtils.repeat("a", 501); result = validate(todoItem); assertThat(result, hasItem(sizeConstraintViolation("content"))); todoItem.content = "Content"; result = validate(todoItem); assertThat(result, empty()); }
From source file:com.hubspot.jinjava.tree.Node.java
public String toTreeString(int level) { String prefix = StringUtils.repeat(" ", level * 4) + " "; StringBuilder t = new StringBuilder(prefix).append(toString()).append('\n'); for (Node n : getChildren()) { t.append(n.toTreeString(level + 1)); }/*from w ww. j a v a 2s. c om*/ if (getChildren().size() > 0) { t.append(prefix).append("end :: " + toString()).append('\n'); } return t.toString(); }
From source file:com.opensymphony.xwork2.conversion.impl.StringConverterTest.java
public void testDoubleToStringConversionPL() throws Exception { // given/* w w w . j a va 2 s . c om*/ StringConverter converter = new StringConverter(); Map<String, Object> context = new HashMap<>(); context.put(ActionContext.LOCALE, new Locale("pl", "PL")); // when has max fraction digits Object value = converter.convertValue(context, null, null, null, Double.MIN_VALUE, null); // then does not lose fraction digits assertEquals("0," + StringUtils.repeat('0', 323) + "49", value); // when has max integer digits value = converter.convertValue(context, null, null, null, Double.MAX_VALUE, null); // then does not lose integer digits assertEquals("17976931348623157" + StringUtils.repeat('0', 292), value); // when cannot be represented exactly with a finite binary number value = converter.convertValue(context, null, null, null, 0.1d, null); // then produce the shortest decimal representation that can unambiguously identify the true value of the floating-point number assertEquals("0,1", value); }
From source file:com.gmarciani.gmparser.commons.TestDeterministicFunction.java
@Test public void createCompleteFunction() { System.out.println("#createCompleteFunction"); GSet<Character> domainX = new GSet<Character>(); domainX.add('a'); domainX.add('b'); domainX.add('c'); GSet<Integer> domainY = new GSet<Integer>(); domainY.add(1);// w ww .ja va 2s.c o m domainY.add(2); domainY.add(3); GSet<String> domainZ = new GSet<String>(); for (Character c : domainX) for (Integer n : domainY) domainZ.add(StringUtils.repeat(c, n)); Function<Character, Integer, String> function = new DeterministicFunction<Character, Integer, String>( domainX, domainY, domainZ); for (Character c : domainX) for (Integer n : domainY) function.add(c, n, StringUtils.repeat(c, n)); System.out.println(function); System.out.println(function.toFormattedFunction()); }
From source file:io.wcm.caravan.pipeline.cache.couchbase.impl.CouchbaseCacheAdapterTest.java
@Test public void getLongCacheKey() { String cacheKey = adapter.getCacheKey("example", StringUtils.repeat("/a/b/c", 500)); assertEquals(250, cacheKey.length()); assertTrue("beginning of cache key is left untouched?", cacheKey.startsWith("prefix:example:/a/b/c")); }
From source file:monasca.api.app.validation.DimensionsTest.java
@Test(expectedExceptions = WebApplicationException.class) public void shouldErrorOnValidateKeyWithLongKey() { String key = StringUtils.repeat("A", 256); DimensionValidation.validateName(key); }
From source file:io.crate.integrationtests.BlobSslEnabledITest.java
private String uploadSmallBlob() throws IOException { String digest = "c520e6109835c876fd98636efec43dd61634b7d3"; CloseableHttpResponse response = put(blobUri(digest), StringUtils.repeat("a", 1500)); assertThat(response.getStatusLine().getStatusCode(), is(201)); return digest; }
From source file:com.qcadoo.model.internal.types.DecimalTypeTest.java
@Test public final void shouldFormatDecimalWithoutOfficiousTrimmingFractionalValue() { // given/*from w w w . ja v a 2s.co m*/ final String decimalAsString = "1234567." + StringUtils.repeat("9", NumberService.DEFAULT_MAX_FRACTION_DIGITS_IN_DECIMAL + 3); BigDecimal value = new BigDecimal(decimalAsString); // when String result = decimalType.toString(value, locale); // then assertFormattedEquals(value, result); }
From source file:de.neuland.jade4j.compiler.BaseWriter.java
public void newline() { if (useIndent && !empty) { write("\n" + StringUtils.repeat(" ", indent)); } }