@Test public void testListEnum() { SchemaImpl schema = new SchemaImpl(); FieldImpl field = new FieldImpl(); field.setType("array[enum]"); field.setOptions(Arrays.asList("one", "two")); field.setCreate(true); schema.getResourceFields().put("test", field); ApiRequest request = new ApiRequest(null, null); ValidationContext context = new ValidationContext(); ValidationHandler handler = new ValidationHandler(); Map<String, Object> input = new HashMap<String, Object>(); input.put("test", "three"); request.setRequestObject(input); try { handler.validateOperationField(schema, request, true, context); fail(); } catch (ClientVisibleException e) { assertEquals(ValidationErrorCodes.INVALID_OPTION, e.getApiError().getCode()); } input.put("test", "one"); handler.validateOperationField(schema, request, true, context); }
protected void validateOperationField(Schema schema, ApiRequest request, boolean create, ValidationContext context) { Map<String, Object> input = RequestUtils.toMap(request.getRequestObject()); Object obj = validateRawOperationField(schema, request.getType(), input, create, context, request.getId()); if (obj != null) { request.setRequestObject(obj); } }
ValidationHandler extends AbstractResponseGenerator { protected void validateOperationField(Schema schema, ApiRequest request, boolean create, ValidationContext context) { Map<String, Object> input = RequestUtils.toMap(request.getRequestObject()); Object obj = validateRawOperationField(schema, request.getType(), input, create, context, request.getId()); if (obj != null) { request.setRequestObject(obj); } } }
ValidationHandler extends AbstractResponseGenerator { protected void validateOperationField(Schema schema, ApiRequest request, boolean create, ValidationContext context) { Map<String, Object> input = RequestUtils.toMap(request.getRequestObject()); Object obj = validateRawOperationField(schema, request.getType(), input, create, context, request.getId()); if (obj != null) { request.setRequestObject(obj); } }  }
ValidationHandler extends AbstractResponseGenerator { protected void validateOperationField(Schema schema, ApiRequest request, boolean create, ValidationContext context) { Map<String, Object> input = RequestUtils.toMap(request.getRequestObject()); Object obj = validateRawOperationField(schema, request.getType(), input, create, context, request.getId()); if (obj != null) { request.setRequestObject(obj); } }  @Override void generate(ApiRequest request); static Object convertGenericType(String fieldName, Object value, FieldType type); static Object convertDate(String fieldName, Object value); @PostConstruct void init(); Set<String> getSupportedMethods(); void setSupportedMethods(Set<String> supportedMethods); ReferenceValidator getReferenceValidator(); void setReferenceValidator(ReferenceValidator referenceValidator); }
ValidationHandler extends AbstractResponseGenerator { protected void validateOperationField(Schema schema, ApiRequest request, boolean create, ValidationContext context) { Map<String, Object> input = RequestUtils.toMap(request.getRequestObject()); Object obj = validateRawOperationField(schema, request.getType(), input, create, context, request.getId()); if (obj != null) { request.setRequestObject(obj); } }  @Override void generate(ApiRequest request); static Object convertGenericType(String fieldName, Object value, FieldType type); static Object convertDate(String fieldName, Object value); @PostConstruct void init(); Set<String> getSupportedMethods(); void setSupportedMethods(Set<String> supportedMethods); ReferenceValidator getReferenceValidator(); void setReferenceValidator(ReferenceValidator referenceValidator);  }