AgentStoreObserver implements StoreUpdateObserver<String, M> { @Override public void handleNew(String key, M value) { List<PatchOperation> operations = agent.newModel(key, value); if (!operations.isEmpty()) { emitter.emit(new PatchSet(key, operations)); } }  @Override void handleNew(String key, M value); @Override void handleUpdate(String key, M oldValue, M newValue); @Override void handleRemove(String key, M oldValue);  }
@Test public void handleNewTest() throws Exception { given(agent.newModel("key", JSON_STRING_1)).willReturn(OPERATIONS); observer.handleNew("key", JSON_STRING_1); verify(agent).newModel("key", JSON_STRING_1); verify(emitter).emit(patchSet.capture()); assertThat(patchSet.getValue().getOperations(), is(OPERATIONS)); }
@Test public void dontSendPatchOnNewEmptyOps() throws Exception { given(agent.newModel("key", JSON_STRING_1)).willReturn(Collections.emptyList()); observer.handleNew("key", JSON_STRING_1); then(emitter).shouldHaveZeroInteractions(); }