@ExceptionHandler(NotFoundException.class) @ResponseStatus(HttpStatus.NOT_FOUND) @ResponseBody public Map<String, String> handleNotFound(NotFoundException e) { LOG.warn("Not Found: " + e.getMessage(), e); return Collections.singletonMap("message", e.getMessage()); }
@Test public void shouldRecoverTransactionWhereNodeIsDeletedInTheFuture() throws Exception { // GIVEN Node node; try (Transaction tx = db.beginTx()) { node = db.createNode(label); node.setProperty("key", "value"); tx.success(); } rotateLog(); try (Transaction tx = db.beginTx()) { node.setProperty("other-key", 1); tx.success(); } try (Transaction tx = db.beginTx()) { node.delete(); tx.success(); } flushAll(); // WHEN FileSystemAbstraction uncleanFs = fsRule.snapshot(shutdownDb(db)); db = (GraphDatabaseAPI) new TestGraphDatabaseFactory().setFileSystem(uncleanFs).newImpermanentDatabase(); // THEN // -- really the problem was that recovery threw exception, so mostly assert that. try (Transaction tx = db.beginTx()) { node = db.getNodeById(node.getId()); fail("Should not exist"); } catch (NotFoundException e) { assertEquals("Node " + node.getId() + " not found", e.getMessage()); } }