@Test public void replaceNew() throws PatchApplicationException { PatchSet patchSet = patchSet(REPLACE, "", map1); JsonNode result = underTest.processPatch(patchSet); assertThat(result, is(jsonNode1)); assertThat(store.get(DOCUMENT_ID), is(jsonNode1)); }
JsonNode processPatch(PatchSet patchSet) throws PatchApplicationException { String documentId = patchSet.getDocumentId(); List<PatchOperation> operations = patchSet.getOperations(); synchronized (store) { JsonNode document = store.getOrDefault(documentId, NullNode.getInstance()); JsonNode updatedDocument = patchApplier.apply(document, operations); if (updatedDocument.isMissingNode()) { log.info("Removing document {}", documentId); store.remove(documentId); } else { log.info("Updating document {}", documentId); log.info("New document : {}", updatedDocument); store.put(documentId, updatedDocument); } return updatedDocument; } }
PatchProcessor { JsonNode processPatch(PatchSet patchSet) throws PatchApplicationException { String documentId = patchSet.getDocumentId(); List<PatchOperation> operations = patchSet.getOperations(); synchronized (store) { JsonNode document = store.getOrDefault(documentId, NullNode.getInstance()); JsonNode updatedDocument = patchApplier.apply(document, operations); if (updatedDocument.isMissingNode()) { log.info("Removing document {}", documentId); store.remove(documentId); } else { log.info("Updating document {}", documentId); log.info("New document : {}", updatedDocument); store.put(documentId, updatedDocument); } return updatedDocument; } } }
PatchProcessor { JsonNode processPatch(PatchSet patchSet) throws PatchApplicationException { String documentId = patchSet.getDocumentId(); List<PatchOperation> operations = patchSet.getOperations(); synchronized (store) { JsonNode document = store.getOrDefault(documentId, NullNode.getInstance()); JsonNode updatedDocument = patchApplier.apply(document, operations); if (updatedDocument.isMissingNode()) { log.info("Removing document {}", documentId); store.remove(documentId); } else { log.info("Updating document {}", documentId); log.info("New document : {}", updatedDocument); store.put(documentId, updatedDocument); } return updatedDocument; } }  }
PatchProcessor { JsonNode processPatch(PatchSet patchSet) throws PatchApplicationException { String documentId = patchSet.getDocumentId(); List<PatchOperation> operations = patchSet.getOperations(); synchronized (store) { JsonNode document = store.getOrDefault(documentId, NullNode.getInstance()); JsonNode updatedDocument = patchApplier.apply(document, operations); if (updatedDocument.isMissingNode()) { log.info("Removing document {}", documentId); store.remove(documentId); } else { log.info("Updating document {}", documentId); log.info("New document : {}", updatedDocument); store.put(documentId, updatedDocument); } return updatedDocument; } }   }
PatchProcessor { JsonNode processPatch(PatchSet patchSet) throws PatchApplicationException { String documentId = patchSet.getDocumentId(); List<PatchOperation> operations = patchSet.getOperations(); synchronized (store) { JsonNode document = store.getOrDefault(documentId, NullNode.getInstance()); JsonNode updatedDocument = patchApplier.apply(document, operations); if (updatedDocument.isMissingNode()) { log.info("Removing document {}", documentId); store.remove(documentId); } else { log.info("Updating document {}", documentId); log.info("New document : {}", updatedDocument); store.put(documentId, updatedDocument); } return updatedDocument; } }    }