### Question:
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } TokenSchema();  TokenSchema(String xsdType); @Override NeutralSchemaType getSchemaType(); @Override boolean isPrimitive(); @Override Object convert(Object value); static final String TOKENS; }### Answer:
@Test public void testTokenValidation() throws IllegalArgumentException { List<String> tokens = new ArrayList<String>(); tokens.add("validToken"); schema.getProperties().put(TokenSchema.TOKENS, tokens); String tokenEntity = "validToken"; assertTrue("Token entity validation failed", schema.validate(tokenEntity)); }
@Test public void testTokenValidationFailure() throws IllegalArgumentException { List<String> tokens = new ArrayList<String>(); tokens.add("validToken"); schema.getProperties().put(TokenSchema.TOKENS, tokens); String tokenEntity = "invalidToken"; assertFalse("Expected TokenSchema invalid token validation failure did not succeed", schema.validate(tokenEntity)); }
@Test public void testValidationOfBooleanFailure() { Boolean booleanEntity = true; assertFalse("Expected TokenSchema boolean validation failure did not succeed", schema.validate(booleanEntity)); }
@Test public void testValidationOfIntegerFailure() { Integer integerEntity = 0; assertFalse("Expected TokenSchema integer validation failure did not succeed", schema.validate(integerEntity)); }
@Test public void testValidationOfFloatFailure() { Float floatEntity = new Float(0); assertFalse("Expected TokenSchema float validation failure did not succeed", schema.validate(floatEntity)); }