@SuppressWarnings("resource") @Test void updateEntityWithListeners() { @SuppressWarnings("unchecked") Repository<Entity> decoratedRepository = Mockito.mock(Repository.class); Mockito.when(decoratedRepository.getName()).thenReturn("entityFullName"); EntityListenerRepositoryDecorator entityListenerRepositoryDecorator = new EntityListenerRepositoryDecorator(decoratedRepository, entityListenersService); EntityListener entityListener0 = Mockito.when(Mockito.mock(EntityListener.class).getEntityId()).thenReturn(1).getMock(); EntityListener entityListener1 = Mockito.when(Mockito.mock(EntityListener.class).getEntityId()).thenReturn(1).getMock(); entityListenersService.addEntityListener("entityFullName", entityListener0); entityListenersService.addEntityListener("entityFullName", entityListener1); Entity entity = Mockito.when(Mockito.mock(Entity.class).getIdValue()).thenReturn(1).getMock(); entityListenerRepositoryDecorator.update(entity); Mockito.verify(decoratedRepository).update(entity); Mockito.verify(entityListener0, Mockito.times(1)).postUpdate(entity); Mockito.verify(entityListener1, Mockito.times(1)).postUpdate(entity); }
@Override public void update(Entity entity) { entityListenersService.updateEntity(delegate().getName(), entity); delegate().update(entity); }
EntityListenerRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void update(Entity entity) { entityListenersService.updateEntity(delegate().getName(), entity); delegate().update(entity); } }
EntityListenerRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void update(Entity entity) { entityListenersService.updateEntity(delegate().getName(), entity); delegate().update(entity); } EntityListenerRepositoryDecorator(
      Repository<Entity> delegateRepository, EntityListenersService entityListenersService); }
EntityListenerRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void update(Entity entity) { entityListenersService.updateEntity(delegate().getName(), entity); delegate().update(entity); } EntityListenerRepositoryDecorator(
      Repository<Entity> delegateRepository, EntityListenersService entityListenersService); @Override void update(Entity entity); @Override void update(Stream<Entity> entities); }
EntityListenerRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public void update(Entity entity) { entityListenersService.updateEntity(delegate().getName(), entity); delegate().update(entity); } EntityListenerRepositoryDecorator(
      Repository<Entity> delegateRepository, EntityListenersService entityListenersService); @Override void update(Entity entity); @Override void update(Stream<Entity> entities);  }