@Test public void when_apivalidation_valid_no_api_error() { when(apiValidation.validate(any())).thenReturn(okResult); toTest.checkApiVersion(errors, input); verify(errors,never()).rejectValue(eq(ProjectJsonInput.PROPERTY_NAME), eq("api.error.projectid.invalid"), any()); verify(errors,never()).rejectValue(eq(ProjectJsonInput.PROPERTY_API_VERSION), any(), any()); }
public void checkApiVersion(Errors errors, ProjectJsonInput input) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, ProjectJsonInput.PROPERTY_API_VERSION, "field.required"); String apiVersion = input.getApiVersion(); if (apiVersion == null) { return; } ValidationResult apiValidationResult = apiVersionValidation.validate(apiVersion); if (!apiValidationResult.isValid()) { errors.rejectValue(ProjectJsonInput.PROPERTY_API_VERSION, "api.error.unsupported.version", apiValidationResult.getErrorDescription()); } }
ProjectJsonInputValidation { public void checkApiVersion(Errors errors, ProjectJsonInput input) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, ProjectJsonInput.PROPERTY_API_VERSION, "field.required"); String apiVersion = input.getApiVersion(); if (apiVersion == null) { return; } ValidationResult apiValidationResult = apiVersionValidation.validate(apiVersion); if (!apiValidationResult.isValid()) { errors.rejectValue(ProjectJsonInput.PROPERTY_API_VERSION, "api.error.unsupported.version", apiValidationResult.getErrorDescription()); } } }
ProjectJsonInputValidation { public void checkApiVersion(Errors errors, ProjectJsonInput input) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, ProjectJsonInput.PROPERTY_API_VERSION, "field.required"); String apiVersion = input.getApiVersion(); if (apiVersion == null) { return; } ValidationResult apiValidationResult = apiVersionValidation.validate(apiVersion); if (!apiValidationResult.isValid()) { errors.rejectValue(ProjectJsonInput.PROPERTY_API_VERSION, "api.error.unsupported.version", apiValidationResult.getErrorDescription()); } }  }
ProjectJsonInputValidation { public void checkApiVersion(Errors errors, ProjectJsonInput input) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, ProjectJsonInput.PROPERTY_API_VERSION, "field.required"); String apiVersion = input.getApiVersion(); if (apiVersion == null) { return; } ValidationResult apiValidationResult = apiVersionValidation.validate(apiVersion); if (!apiValidationResult.isValid()) { errors.rejectValue(ProjectJsonInput.PROPERTY_API_VERSION, "api.error.unsupported.version", apiValidationResult.getErrorDescription()); } }  boolean supports(Class<?> clazz); ProjectJsonInput asInput(Object target); void checkProjectId(Errors errors, ProjectJsonInput input); void checkApiVersion(Errors errors, ProjectJsonInput input); void checkOwnerUserId(Errors errors, ProjectJsonInput input); }
ProjectJsonInputValidation { public void checkApiVersion(Errors errors, ProjectJsonInput input) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, ProjectJsonInput.PROPERTY_API_VERSION, "field.required"); String apiVersion = input.getApiVersion(); if (apiVersion == null) { return; } ValidationResult apiValidationResult = apiVersionValidation.validate(apiVersion); if (!apiValidationResult.isValid()) { errors.rejectValue(ProjectJsonInput.PROPERTY_API_VERSION, "api.error.unsupported.version", apiValidationResult.getErrorDescription()); } }  boolean supports(Class<?> clazz); ProjectJsonInput asInput(Object target); void checkProjectId(Errors errors, ProjectJsonInput input); void checkApiVersion(Errors errors, ProjectJsonInput input); void checkOwnerUserId(Errors errors, ProjectJsonInput input);  }