### Question:
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);  }### Answer:
@Test public void when_apivalidation_invalid_api_error() { when(input.getApiVersion()).thenReturn("x"); when(apiValidation.validate(any())).thenReturn(failedResult); toTest.checkApiVersion(errors, input); verify(errors).rejectValue(eq(ProjectJsonInput.PROPERTY_API_VERSION), eq("api.error.unsupported.version"), any()); }
@Test public void when_apivalidation_null_required_field_api_error() { when(input.getApiVersion()).thenReturn(null); when(apiValidation.validate(any())).thenReturn(okResult); toTest.checkApiVersion(errors, input); verify(errors).rejectValue(eq(ProjectJsonInput.PROPERTY_API_VERSION), eq("field.required"), any(),any()); }
@Test public void when_apivalidation_empty_required_field_api_error() { when(input.getApiVersion()).thenReturn(""); when(apiValidation.validate(any())).thenReturn(okResult); toTest.checkApiVersion(errors, input); verify(errors).rejectValue(eq(ProjectJsonInput.PROPERTY_API_VERSION), eq("field.required"), any(),any()); }
@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()); }