### Question:
GenericResourceValidator implements ResourceValidator<ResourceType> { @Override public List<Exception> validate(ResourceType resource, boolean skipRepoFieldsValidation, Map<String, String[]> additionalParameters) { final List<Exception> validationErrors = new ArrayList<Exception>(); if(!skipRepoFieldsValidation) { genericValidate(resource, validationErrors); } internalValidate(resource, validationErrors, additionalParameters); return validationErrors; }  @Override List<Exception> validate(ResourceType resource, boolean skipRepoFieldsValidation, Map<String, String[]> additionalParameters); @Override List<Exception> validate(ResourceType resource);  }### Answer:
@Test public void validate() { validator.validate(resource); verify(validator).internalValidate(same(resource), any(List.class), any(Map.class)); }
@Test public void validate_labelContainsAttributePlaceholder_exception() throws Exception { when(profileAttributesResolver.containsAttribute(resource.getLabel())).thenReturn(true); final List<Exception> exceptions = validator.validate(resource); assertNotNull(exceptions); assertFalse(exceptions.isEmpty()); }
@Test public void validate_labelIsNull_exception() throws Exception { final List<Exception> exceptions = validator.validate(new ResourceLookupImpl()); assertNotNull(exceptions); assertFalse(exceptions.isEmpty()); }
@Test public void validate_longDescription_exception() throws Exception { ResourceLookupImpl rli = new ResourceLookupImpl(); rli.setDescription("filkRLwnVcsmZoFbTJewiqsohAXWobiqOAwmiVhLDrrd" + "dQoyRFOPUMhDDRtPbOdpsBxIFBIZoLgGelTeUhRWSNIHwvkkqSWtKZMGgEhoEECcZWKDmrtfwTZWtbLhkzJvZnjuy" + "qQysiIApMkPuWDUcAzUEVcfZYtenGoWXqa" + "YXwcaymjrZTfQYNZbNNTjxCQuTgUgXtgtUsdpEUdsEHmBfPDldcPLNSHGDKNcuPzJwjnDiHNruTaoPBGxFcP"); final List<Exception> exceptions = validator.validate(rli); assertNotNull(exceptions); assertFalse(exceptions.isEmpty()); }
@Test public void validate_labelIsNull_slipRepoFieldsValidation_success() throws Exception { Exception exception = null; try { validator.validate(new ResourceLookupImpl(), true, new HashMap<String, String[]>()); } catch (Exception e){ exception = e; } assertNull(exception); }
@Test public void validate_descriptionContainsAttributePlaceholder_exception() throws Exception { when(profileAttributesResolver.containsAttribute(resource.getDescription())).thenReturn(true); final List<Exception> exceptions = validator.validate(resource); assertNotNull(exceptions); assertFalse(exceptions.isEmpty()); }
@Test public void validate_nameContainsAttributePlaceholder_exception() throws Exception { when(profileAttributesResolver.containsAttribute(resource.getName())).thenReturn(true); final List<Exception> exceptions = validator.validate(resource); assertNotNull(exceptions); assertFalse(exceptions.isEmpty()); }