### Question:
PDSProductIdentifierValidator { public String createValidationErrorMessage(String productId) { if (productId == null || productId.trim().isEmpty()) { return "product identifier not set!"; } if (productId.length() > 30) { return "product identifier length too big:" + productId.length() + ", allowed is only 30"; } for (char c : productId.toCharArray()) { if (Character.isAlphabetic(c)) { continue; } if (Character.isDigit(c)) { continue; } if (c == '_') { continue; } return "unexpected char inside product identifier found:" + c + ", allowed is only [a-zA-Z0-9_]"; } return null; }  String createValidationErrorMessage(String productId);  }### Answer:
@Test public void empty_product_identifiers_return_errormessage() { assertNotNull(validatorToTest.createValidationErrorMessage(null)); assertNotNull(validatorToTest.createValidationErrorMessage("")); }
@Test public void product_identifiers_too_long_returns_errormessage() { assertNotNull(validatorToTest.createValidationErrorMessage("123456789012345678901234567890x")); }
@Test public void product_identifiers_not_too_long_returns_NO_errormessage() { assertNull(validatorToTest.createValidationErrorMessage("123456789012345678901234567890")); assertNull(validatorToTest.createValidationErrorMessage("ABCDE_1234_11")); }
@Test public void product_identifiers_containing_non_alphaebtic_digit_and_no_underscore_are_not_accepted() { assertNotNull(validatorToTest.createValidationErrorMessage("$")); assertNotNull(validatorToTest.createValidationErrorMessage("x$")); assertNotNull(validatorToTest.createValidationErrorMessage("x-")); assertNotNull(validatorToTest.createValidationErrorMessage("-")); assertNotNull(validatorToTest.createValidationErrorMessage("!")); }