List of usage examples for org.apache.commons.lang3 StringUtils capitalize
public static String capitalize(final String str)
Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char) .
From source file:org.egov.adtax.entity.enums.AdvertisementApplicationType.java
@Override public String toString() { return StringUtils.capitalize(name()); }
From source file:org.egov.eis.entity.enums.BloodGroup.java
@Override @JsonValue public String toString() { return StringUtils.capitalize(name()); }
From source file:org.egov.pgr.dashboard.service.DashboardService.java
public List<Map<String, Object>> getMonthlyAggregate() { DateTime currentDate = new DateTime(); List<Map<String, Object>> dataHolder = constructMonthPlaceHolder(currentDate.minusMonths(6), currentDate, "MMM-yyyy"); for (Object[] compCnt : dashboardRepository.fetchMonthlyAggregateBetween( startOfGivenDate(currentDate.minusMonths(6).withDayOfMonth(1)).toDate(), endOfGivenDate(currentDate).toDate())) for (Map<String, Object> mapdata : dataHolder) if (mapdata.containsValue(StringUtils.capitalize(String.valueOf(compCnt[0]).toLowerCase()))) mapdata.put("y", Integer.valueOf(String.valueOf(compCnt[1]))); return dataHolder; }
From source file:org.egov.pgr.entity.ReceivingMode.java
@Override public String toString() { return StringUtils.capitalize(name); }
From source file:org.egov.pgr.service.dashboard.DashboardService.java
public List<Map<String, Object>> getMonthlyAggregate() { final DateTime currentDate = new DateTime(); final List<Map<String, Object>> dataHolder = constructMonthPlaceHolder(currentDate.minusMonths(6), currentDate, "MMM-yyyy"); for (final Object[] compCnt : dashboardRepository.fetchMonthlyAggregateBetween( startOfGivenDate(currentDate.minusMonths(6).withDayOfMonth(1)).toDate(), endOfGivenDate(currentDate).toDate())) for (final Map<String, Object> mapdata : dataHolder) if (mapdata.containsValue(StringUtils.capitalize(String.valueOf(compCnt[0]).toLowerCase()))) mapdata.put("y", Integer.valueOf(String.valueOf(compCnt[1]))); return dataHolder; }
From source file:org.elfinder.servlets.AbstractConnectorServlet.java
/** * Get default implementation class for a command. * @param commandName//from w w w . ja va 2 s. c o m * @return */ @SuppressWarnings("unchecked") protected Class<AbstractCommand> getCommandClassDefault(String commandName) { String className = AbstractConnectorServlet.class.getPackage().getName() + ".commands." + StringUtils.capitalize(commandName) + "Command"; Class<AbstractCommand> clazz = null; try { clazz = (Class<AbstractCommand>) Class.forName(className); } catch (ClassNotFoundException e) { // not found } return clazz; }
From source file:org.elfinder.servlets.AbstractConnectorServlet.java
/** * Get override implementation class for a command. * @param commandName/*w ww. j a va 2s. co m*/ * @return */ @SuppressWarnings("unchecked") protected Class<AbstractCommand> getCommandClassOverride(String commandName) { String className = AbstractConnectorServlet.class.getPackage().getName() + ".commands." + StringUtils.capitalize(commandName) + "CommandOverride"; Class<AbstractCommand> clazz = null; try { clazz = (Class<AbstractCommand>) Class.forName(className); } catch (ClassNotFoundException e) { // not found } return clazz; }
From source file:org.emau.icmvc.ganimed.deduplication.preprocessing.impl.UniversalStringTransformation.java
/** * The method normalizes spaces, turns the string to uppercase representation * and normalizes hyphens/*from ww w . jav a2 s . co m*/ * @param input * @return */ public String normalize(String input) { // normalize spaces input = StringUtils.normalizeSpace(input); input = StringUtils.replace(input, "-", " - "); input = StringUtils.replace(input, " - ", "-"); input = StringUtils.capitalize(input); return input; }
From source file:org.evosuite.junit.TestSuiteWriter.java
/** * Convert one test case to a Java method * //from w ww. ja v a 2s . c om * @param id * Index of the test case * @return String representation of test case * @param result * a {@link org.evosuite.testcase.ExecutionResult} object. */ protected String testToString(int number, int id, ExecutionResult result) { boolean wasSecurityException = result.hasSecurityException(); StringBuilder builder = new StringBuilder(); builder.append("\n"); if (Properties.TEST_COMMENTS || testComment.containsKey(id)) { builder.append(METHOD_SPACE); builder.append("//"); builder.append(getInformation(id)); builder.append("\n"); } String methodName; if (Properties.ASSERTION_STRATEGY == AssertionStrategy.STRUCTURED) { StructuredTestCase structuredTest = (StructuredTestCase) testCases.get(id); String targetMethod = structuredTest.getTargetMethods().iterator().next(); targetMethod = targetMethod.replace("<init>", "Constructor"); if (targetMethod.indexOf('(') != -1) targetMethod = targetMethod.substring(0, targetMethod.indexOf('(')); targetMethod = StringUtils.capitalize(targetMethod); int num = 0; if (testMethodNumber.containsKey(targetMethod)) { num = testMethodNumber.get(targetMethod); testMethodNumber.put(targetMethod, num + 1); } else { testMethodNumber.put(targetMethod, 1); } methodName = "test" + targetMethod + num; builder.append(adapter.getMethodDefinition(methodName)); } else { methodName = getNameOfTest(testCases, number); builder.append(adapter.getMethodDefinition(methodName)); } /* * A test case might throw a lot of different kinds of exceptions. * These might come from SUT, and might also come from the framework itself (eg, see ExecutorService.submit). * Regardless of whether they are declared or not, an exception that propagates to the JUnit framework will * result in a failure for the test case. However, there might be some checked exceptions, and for those * we need to declare them in the signature with "throws". So, the easiest (but still correct) option * is to just declare once to throw any genetic Exception, and be done with it once and for all */ builder.append(" throws Throwable "); builder.append(" {\n"); // --------- start with the body ------------------------- String CODE_SPACE = INNER_BLOCK_SPACE; // No code after an exception should be printed as it would break compilability TestCase test = testCases.get(id); Integer pos = result.getFirstPositionOfThrownException(); if (pos != null) { if (result.getExceptionThrownAtPosition(pos) instanceof CodeUnderTestException) { test.chop(pos); } else { test.chop(pos + 1); } } if (wasSecurityException) { builder.append(BLOCK_SPACE); builder.append("Future<?> future = " + EXECUTOR_SERVICE + ".submit(new Runnable(){ \n"); builder.append(INNER_BLOCK_SPACE); // Doesn't seem to need override? // builder.append("@Override \n"); builder.append(INNER_BLOCK_SPACE); builder.append("public void run() { \n"); Set<Class<?>> exceptions = test.getDeclaredExceptions(); if (!exceptions.isEmpty()) { builder.append(INNER_INNER_BLOCK_SPACE); builder.append("try {\n"); } CODE_SPACE = INNER_INNER_INNER_BLOCK_SPACE; } for (String line : adapter.getTestString(id, test, result.exposeExceptionMapping(), visitor) .split("\\r?\\n")) { builder.append(CODE_SPACE); builder.append(line); builder.append("\n"); } if (wasSecurityException) { Set<Class<?>> exceptions = test.getDeclaredExceptions(); if (!exceptions.isEmpty()) { builder.append(INNER_INNER_BLOCK_SPACE); builder.append("} catch(Throwable t) {\n"); builder.append(INNER_INNER_INNER_BLOCK_SPACE); builder.append(" // Need to catch declared exceptions\n"); builder.append(INNER_INNER_BLOCK_SPACE); builder.append("}\n"); } builder.append(INNER_BLOCK_SPACE); builder.append("} \n"); //closing run(){ builder.append(BLOCK_SPACE); builder.append("}); \n"); //closing submit long time = Properties.TIMEOUT + 1000; // we add one second just to be sure, that to avoid issues with test cases taking exactly TIMEOUT ms builder.append(BLOCK_SPACE); builder.append("future.get(" + time + ", TimeUnit.MILLISECONDS); \n"); } // --------- end of the body ---------------------------- builder.append(METHOD_SPACE); builder.append("}\n"); String testCode = builder.toString(); TestGenerationResultBuilder.getInstance().setTestCase(methodName, testCode, test, getInformation(id), result); return testCode; }
From source file:org.evosuite.junit.writer.TestSuiteWriter.java
/** * Convert one test case to a Java method * * @param id Index of the test case/*from w w w . jav a 2s .c om*/ * @param result a {@link org.evosuite.testcase.execution.ExecutionResult} object. * @return String representation of test case */ protected String testToString(int number, int id, ExecutionResult result) { boolean wasSecurityException = result.hasSecurityException(); String testInfo = getInformation(id); StringBuilder builder = new StringBuilder(); builder.append(NEWLINE); if (Properties.TEST_COMMENTS || testComment.containsKey(id)) { builder.append(METHOD_SPACE); builder.append("//"); builder.append(testInfo); builder.append(NEWLINE); } String methodName; if (Properties.ASSERTION_STRATEGY == AssertionStrategy.STRUCTURED) { StructuredTestCase structuredTest = (StructuredTestCase) testCases.get(id); String targetMethod = structuredTest.getTargetMethods().iterator().next(); targetMethod = targetMethod.replace("<init>", "Constructor"); if (targetMethod.indexOf('(') != -1) targetMethod = targetMethod.substring(0, targetMethod.indexOf('(')); targetMethod = StringUtils.capitalize(targetMethod); int num = 0; if (testMethodNumber.containsKey(targetMethod)) { num = testMethodNumber.get(targetMethod); testMethodNumber.put(targetMethod, num + 1); } else { testMethodNumber.put(targetMethod, 1); } methodName = "test" + targetMethod + num; builder.append(adapter.getMethodDefinition(methodName)); } else { methodName = TestSuiteWriterUtils.getNameOfTest(testCases, number); builder.append(adapter.getMethodDefinition(methodName)); } /* * A test case might throw a lot of different kinds of exceptions. * These might come from SUT, and might also come from the framework itself (eg, see ExecutorService.submit). * Regardless of whether they are declared or not, an exception that propagates to the JUnit framework will * result in a failure for the test case. However, there might be some checked exceptions, and for those * we need to declare them in the signature with "throws". So, the easiest (but still correct) option * is to just declare once to throw any generic Exception, and be done with it once and for all */ builder.append(" throws Throwable "); builder.append(" {"); builder.append(NEWLINE); // --------- start with the body ------------------------- String CODE_SPACE = INNER_BLOCK_SPACE; // No code after an exception should be printed as it would break compilability TestCase test = testCases.get(id); Integer pos = result.getFirstPositionOfThrownException(); if (pos != null) { if (result.getExceptionThrownAtPosition(pos) instanceof CodeUnderTestException) { test.chop(pos); } else { test.chop(pos + 1); } } if (wasSecurityException) { builder.append(BLOCK_SPACE); builder.append("Future<?> future = " + Scaffolding.EXECUTOR_SERVICE + ".submit(new Runnable(){ "); builder.append(NEWLINE); builder.append(INNER_BLOCK_SPACE); builder.append(INNER_BLOCK_SPACE); builder.append("@Override public void run() { "); builder.append(NEWLINE); Set<Class<?>> exceptions = test.getDeclaredExceptions(); if (!exceptions.isEmpty()) { builder.append(INNER_INNER_BLOCK_SPACE); builder.append("try {"); builder.append(NEWLINE); } CODE_SPACE = INNER_INNER_INNER_BLOCK_SPACE; } for (String line : adapter.getTestString(id, test, result.exposeExceptionMapping(), visitor) .split("\\r?\\n")) { builder.append(CODE_SPACE); builder.append(line); builder.append(NEWLINE); } if (wasSecurityException) { Set<Class<?>> exceptions = test.getDeclaredExceptions(); if (!exceptions.isEmpty()) { builder.append(INNER_INNER_BLOCK_SPACE); builder.append("} catch(Throwable t) {"); builder.append(NEWLINE); builder.append(INNER_INNER_INNER_BLOCK_SPACE); builder.append(" // Need to catch declared exceptions"); builder.append(NEWLINE); builder.append(INNER_INNER_BLOCK_SPACE); builder.append("}"); builder.append(NEWLINE); } builder.append(INNER_BLOCK_SPACE); builder.append("} "); //closing run(){ builder.append(NEWLINE); builder.append(BLOCK_SPACE); builder.append("});"); //closing submit builder.append(NEWLINE); long time = Properties.TIMEOUT + 1000; // we add one second just to be sure, that to avoid issues with test cases taking exactly TIMEOUT ms builder.append(BLOCK_SPACE); builder.append("future.get(" + time + ", TimeUnit.MILLISECONDS);"); builder.append(NEWLINE); } // --------- end of the body ---------------------------- builder.append(METHOD_SPACE); builder.append("}"); builder.append(NEWLINE); String testCode = builder.toString(); TestGenerationResultBuilder.getInstance().setTestCase(methodName, testCode, test, testInfo, result); return testCode; }