DefaultClusterDeleteEventListener implements ClusterDeleteEventListener { @Override public void update(Object args, Observable observable) { EventType type = (EventType) args; if(!(observable instanceof ClusterDeleteEvent) || type != EventType.DELETE) { logger.info("[update] observable object not ShardDeleteEvent, skip. observable: {}, args: {}", observable.getClass().getName(), args.getClass().getName()); return; } ClusterDeleteEvent clusterDeleteEvent = (ClusterDeleteEvent) observable; for(ShardEvent shardEvent : clusterDeleteEvent.getShardEvents()) { shardEvent.onEvent(); } }  @Override void update(Object args, Observable observable);  }
@Test public void update() throws Exception { ClusterDeleteEvent clusterDeleteEvent = new ClusterDeleteEvent("cluster", Executors.newScheduledThreadPool(1)); shardDeleteEvent.addObserver(shardDeleteEventListener); clusterDeleteEvent.addShardEvent(shardDeleteEvent); listener.update(EventType.DELETE, clusterDeleteEvent); Mockito.verify(shardDeleteEvent).onEvent(); Mockito.verify(shardDeleteEventListener).update(any(), any()); }