@Test void testDeleteStream() { Entity entity = mock(Entity.class); Stream<Entity> entityStream = Stream.of(entity); Stream<Entity> validatedEntityStream = Stream.of(entity); when(defaultValueReferenceValidator.validateEntitiesNotReferenced(entityStream, entityType)) .thenReturn(validatedEntityStream); repositoryValidationDecorator.delete(entityStream); @SuppressWarnings("unchecked") ArgumentCaptor<Stream<Entity>> captor = ArgumentCaptor.forClass(Stream.class); verify(delegateRepository).delete(captor.capture()); verify(defaultValueReferenceValidator).validateEntitiesNotReferenced(entityStream, entityType); assertEquals(singletonList(entity), captor.getValue().collect(toList())); }
@Override public void delete(Entity entity) { defaultValueReferenceValidator.validateEntityNotReferenced(entity); delegate().delete(entity); }
RepositoryValidationDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void delete(Entity entity) { defaultValueReferenceValidator.validateEntityNotReferenced(entity); delegate().delete(entity); } }
RepositoryValidationDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void delete(Entity entity) { defaultValueReferenceValidator.validateEntityNotReferenced(entity); delegate().delete(entity); } RepositoryValidationDecorator(
      DataService dataService,
      Repository<Entity> delegateRepository,
      EntityAttributesValidator entityAttributesValidator,
      DefaultValueReferenceValidator defaultValueReferenceValidator); }
RepositoryValidationDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void delete(Entity entity) { defaultValueReferenceValidator.validateEntityNotReferenced(entity); delegate().delete(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 delete(Entity entity) { defaultValueReferenceValidator.validateEntityNotReferenced(entity); delegate().delete(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);  }