@Test void removeEntityListenerTest() { String repoFullName = "EntityRepo"; EntityListener entityListener = Mockito.when(Mockito.mock(EntityListener.class).getEntityId()).thenReturn(1).getMock(); entityListenersService.register(repoFullName); entityListenersService.addEntityListener(repoFullName, entityListener); assertFalse(entityListenersService.isEmpty(repoFullName)); entityListenersService.removeEntityListener(repoFullName, entityListener); assertTrue(entityListenersService.isEmpty(repoFullName)); }
public boolean removeEntityListener(String repoFullName, EntityListener entityListener) { lock.writeLock().lock(); try { verifyRepoRegistered(repoFullName); SetMultimap<Object, EntityListener> entityListeners = this.entityListenersByRepo.get(repoFullName); if (entityListeners.containsKey(entityListener.getEntityId())) { entityListeners.remove(entityListener.getEntityId(), entityListener); return true; } return false; } finally { lock.writeLock().unlock(); } }
EntityListenersService { public boolean removeEntityListener(String repoFullName, EntityListener entityListener) { lock.writeLock().lock(); try { verifyRepoRegistered(repoFullName); SetMultimap<Object, EntityListener> entityListeners = this.entityListenersByRepo.get(repoFullName); if (entityListeners.containsKey(entityListener.getEntityId())) { entityListeners.remove(entityListener.getEntityId(), entityListener); return true; } return false; } finally { lock.writeLock().unlock(); } } }
EntityListenersService { public boolean removeEntityListener(String repoFullName, EntityListener entityListener) { lock.writeLock().lock(); try { verifyRepoRegistered(repoFullName); SetMultimap<Object, EntityListener> entityListeners = this.entityListenersByRepo.get(repoFullName); if (entityListeners.containsKey(entityListener.getEntityId())) { entityListeners.remove(entityListener.getEntityId(), entityListener); return true; } return false; } finally { lock.writeLock().unlock(); } }  }
EntityListenersService { public boolean removeEntityListener(String repoFullName, EntityListener entityListener) { lock.writeLock().lock(); try { verifyRepoRegistered(repoFullName); SetMultimap<Object, EntityListener> entityListeners = this.entityListenersByRepo.get(repoFullName); if (entityListeners.containsKey(entityListener.getEntityId())) { entityListeners.remove(entityListener.getEntityId(), entityListener); return true; } return false; } finally { lock.writeLock().unlock(); } }  void addEntityListener(String repoFullName, EntityListener entityListener); boolean removeEntityListener(String repoFullName, EntityListener entityListener); }
EntityListenersService { public boolean removeEntityListener(String repoFullName, EntityListener entityListener) { lock.writeLock().lock(); try { verifyRepoRegistered(repoFullName); SetMultimap<Object, EntityListener> entityListeners = this.entityListenersByRepo.get(repoFullName); if (entityListeners.containsKey(entityListener.getEntityId())) { entityListeners.remove(entityListener.getEntityId(), entityListener); return true; } return false; } finally { lock.writeLock().unlock(); } }  void addEntityListener(String repoFullName, EntityListener entityListener); boolean removeEntityListener(String repoFullName, EntityListener entityListener);  }