@Test void addEntityDoesNotRequireValidationDueToRepoCapabilities() { when(delegateRepository.getCapabilities()) .thenReturn(new HashSet<>(Arrays.asList(RepositoryCapability.VALIDATE_NOTNULL_CONSTRAINT))); Entity entity0 = mock(Entity.class); when(entity0.getEntityType()).thenReturn(entityType); when(entity0.getIdValue()).thenReturn("id0"); when(entity0.getEntity(attrXrefName)) .thenReturn(null); when(entity0.getEntity(attrNillableXrefName)).thenReturn(null); when(entity0.getEntities(attrMrefName)).thenReturn(Arrays.asList(refEntity0)); when(entity0.getEntities(attrNillableMrefName)).thenReturn(emptyList()); when(entity0.getString(attrUniqueStringName)).thenReturn("unique0"); when(entity0.getEntity(attrUniqueXrefName)).thenReturn(refEntity0); when(entity0.get(attrIdName)).thenReturn("id0"); when(entity0.get(attrXrefName)) .thenReturn(null); when(entity0.get(attrNillableXrefName)).thenReturn(null); when(entity0.get(attrMrefName)).thenReturn(Arrays.asList(refEntity0)); when(entity0.get(attrNillableMrefName)).thenReturn(emptyList()); when(entity0.get(attrUniqueStringName)).thenReturn("unique0"); when(entity0.get(attrUniqueXrefName)).thenReturn(refEntity0); repositoryValidationDecorator.add(entity0); verify(delegateRepository, times(1)).add(entity0); }
@Override public void add(Entity entity) { try (ValidationResource validationResource = new ValidationResource()) { validate(entity, validationResource, ValidationMode.ADD); } delegate().add(entity); }
RepositoryValidationDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void add(Entity entity) { try (ValidationResource validationResource = new ValidationResource()) { validate(entity, validationResource, ValidationMode.ADD); } delegate().add(entity); } }
RepositoryValidationDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void add(Entity entity) { try (ValidationResource validationResource = new ValidationResource()) { validate(entity, validationResource, ValidationMode.ADD); } delegate().add(entity); } RepositoryValidationDecorator(
      DataService dataService,
      Repository<Entity> delegateRepository,
      EntityAttributesValidator entityAttributesValidator,
      DefaultValueReferenceValidator defaultValueReferenceValidator); }
RepositoryValidationDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void add(Entity entity) { try (ValidationResource validationResource = new ValidationResource()) { validate(entity, validationResource, ValidationMode.ADD); } delegate().add(entity); } RepositoryValidationDecorator(
      DataService dataService,
      Repository<Entity> delegateRepository,
      EntityAttributesValidator entityAttributesValidator,
      DefaultValueReferenceValidator defaultValueReferenceValidator); @Override void update(Entity entity); @Override void update(Stream<Entity> entities); @Override void add(Entity entity); @Override Integer add(Stream<Entity> entities); @Override void delete(Entity entity); @Override void deleteById(Object id); @Override void deleteAll(); @Override void delete(Stream<Entity> entities); @Override void deleteAll(Stream<Object> ids); }
RepositoryValidationDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void add(Entity entity) { try (ValidationResource validationResource = new ValidationResource()) { validate(entity, validationResource, ValidationMode.ADD); } delegate().add(entity); } RepositoryValidationDecorator(
      DataService dataService,
      Repository<Entity> delegateRepository,
      EntityAttributesValidator entityAttributesValidator,
      DefaultValueReferenceValidator defaultValueReferenceValidator); @Override void update(Entity entity); @Override void update(Stream<Entity> entities); @Override void add(Entity entity); @Override Integer add(Stream<Entity> entities); @Override void delete(Entity entity); @Override void deleteById(Object id); @Override void deleteAll(); @Override void delete(Stream<Entity> entities); @Override void deleteAll(Stream<Object> ids);  }