@Test public void should_ReturnValidationError_When_ReservedWordAsServiceNameGiven() { for (String reservedEsWord : VaadinServiceNameChecker.ECMA_SCRIPT_RESERVED_WORDS) { String validationResult = checker.check(reservedEsWord); assertNotNull(String.format( "Word '%s' should cause validation errors, but it did not", reservedEsWord), validationResult); assertTrue(validationResult.contains("reserved")); } }
public String check(String serviceName) { if (serviceName == null || serviceName.isEmpty()) { return "Service name cannot be blank"; } if (ECMA_SCRIPT_RESERVED_WORDS.contains(serviceName)) { return "Service name cannot be equal to JavaScript reserved words"; } if (CONTAINS_WHITESPACE_PATTERN.matcher(serviceName).matches()) { return "Service name cannot contain any whitespaces"; } return null; }
VaadinServiceNameChecker { public String check(String serviceName) { if (serviceName == null || serviceName.isEmpty()) { return "Service name cannot be blank"; } if (ECMA_SCRIPT_RESERVED_WORDS.contains(serviceName)) { return "Service name cannot be equal to JavaScript reserved words"; } if (CONTAINS_WHITESPACE_PATTERN.matcher(serviceName).matches()) { return "Service name cannot contain any whitespaces"; } return null; } }
VaadinServiceNameChecker { public String check(String serviceName) { if (serviceName == null || serviceName.isEmpty()) { return "Service name cannot be blank"; } if (ECMA_SCRIPT_RESERVED_WORDS.contains(serviceName)) { return "Service name cannot be equal to JavaScript reserved words"; } if (CONTAINS_WHITESPACE_PATTERN.matcher(serviceName).matches()) { return "Service name cannot contain any whitespaces"; } return null; }  }
VaadinServiceNameChecker { public String check(String serviceName) { if (serviceName == null || serviceName.isEmpty()) { return "Service name cannot be blank"; } if (ECMA_SCRIPT_RESERVED_WORDS.contains(serviceName)) { return "Service name cannot be equal to JavaScript reserved words"; } if (CONTAINS_WHITESPACE_PATTERN.matcher(serviceName).matches()) { return "Service name cannot contain any whitespaces"; } return null; }  String check(String serviceName); }
VaadinServiceNameChecker { public String check(String serviceName) { if (serviceName == null || serviceName.isEmpty()) { return "Service name cannot be blank"; } if (ECMA_SCRIPT_RESERVED_WORDS.contains(serviceName)) { return "Service name cannot be equal to JavaScript reserved words"; } if (CONTAINS_WHITESPACE_PATTERN.matcher(serviceName).matches()) { return "Service name cannot contain any whitespaces"; } return null; }  String check(String serviceName); static final Set<String> ECMA_SCRIPT_RESERVED_WORDS; }