VoValidationServiceImpl implements VoValidationService { @Override public VoValidationResult validate(final VoValidationRequest request) { final String subject = request.getSubject(); final Map<String, VoValidationService> subjectValidators = this.validators.get(subject); if (subjectValidators != null) { final String field = request.getField(); final VoValidationService subjectFieldValidator = subjectValidators.get(field); if (subjectFieldValidator != null) { return subjectFieldValidator.validate(request); } return new VoValidationResult(request, "INVALID_FIELD"); } return new VoValidationResult(request, "INVALID_SUBJECT"); } VoValidationServiceImpl(final Map<String, Map<String, VoValidationService>> validators); @Override VoValidationResult validate(final VoValidationRequest request);  }
@Test public void testValidatorsInvalid() throws Exception { VoValidationRequest request = new VoValidationRequest(); request.setSubject("non-existent"); request.setField("field"); request.setSubjectId(1000L); request.setValue("ABC"); assertEquals("INVALID_SUBJECT", voValidationService.validate(request).getErrorCode()); }