TaxonomyResourceDefinition extends BaseResourceDefinition { @Override public void validateCreatePayload(Request request) throws InvalidPayloadException { super.validateCreatePayload(request); if (String.valueOf(request.getQueryProperties().get("name")).contains(".")) { throw new InvalidPayloadException("The \"name\" property may not contain the character '.'"); } } TaxonomyResourceDefinition(); @Override void validateCreatePayload(Request request); @Override String getTypeName(); @Override String getIdPropertyName(); @Override String resolveHref(Map<String, Object> properties);  }
@Test public void testValidate() throws Exception { Map<String, Object> properties = new HashMap<>(); properties.put("name", "taxonomyName"); properties.put("description", "foo"); Request request = new InstanceRequest(properties); ResourceDefinition taxonomyDefinition = new TaxonomyResourceDefinition(); taxonomyDefinition.validateCreatePayload(request); }
@Test(expectedExceptions = InvalidPayloadException.class) public void testValidate_missingName() throws Exception { Map<String, Object> properties = new HashMap<>(); properties.put("description", "foo"); Request request = new InstanceRequest(properties); ResourceDefinition taxonomyDefinition = new TaxonomyResourceDefinition(); taxonomyDefinition.validateCreatePayload(request); }
@Test(expectedExceptions = InvalidPayloadException.class) public void testValidate_invalidProperty() throws Exception { Map<String, Object> properties = new HashMap<>(); properties.put("name", "foo"); properties.put("unknownProperty", "value"); Request request = new InstanceRequest(properties); ResourceDefinition taxonomyDefinition = new TaxonomyResourceDefinition(); taxonomyDefinition.validateCreatePayload(request); }