@Test public void shouldThrowHumaneExceptionsWhenPropertyDoesNotExist() { // Given a database without PROPERTY_KEY in it // When try ( Transaction ignored = db.beginTx() ) { Node node = db.createNode(); node.getProperty( PROPERTY_KEY ); } // Then catch ( NotFoundException exception ) { assertThat( exception.getMessage(), containsString( PROPERTY_KEY ) ); } }
@Test public void shouldThrowIllegalStateForActionsAfterDeletedOnIndex2() { restartTx(); index.delete(); restartTx(); try { index.add( node, key, value ); fail(); } catch ( NotFoundException e ) { assertThat( e.getMessage(), containsString( "doesn't exist" ) ); } }
@Test public void shouldThrowIllegalStateForActionsAfterDeletedOnIndex() { restartTx(); index.delete(); restartTx(); try { index.query( key, "own" ); fail( "Should fail" ); } catch ( NotFoundException e ) { assertThat( e.getMessage(), containsString( "doesn't exist" ) ); } }
@Test public void shouldThrowHumaneExceptionsWhenPropertyDoesNotExistOnNode() { // Given a database with PROPERTY_KEY in it createNodeWith( PROPERTY_KEY ); // When trying to get property from node without it try ( Transaction ignored = db.beginTx() ) { Node node = db.createNode(); node.getProperty( PROPERTY_KEY ); fail( "Expected exception to have been thrown" ); } // Then catch ( NotFoundException exception ) { assertThat( exception.getMessage(), containsString( PROPERTY_KEY ) ); } }
@Test public void shouldBeAbleToDropIndexWhileItIsPopulating() { // GIVEN startDb(); DoubleLatch populationCompletionLatch = provider.installPopulationJobCompletionLatch(); IndexDefinition index = createIndex(); populationCompletionLatch.waitForAllToStart(); // await population job to start // WHEN dropIndex( index, populationCompletionLatch ); // THEN assertThat( getIndexes( db, myLabel ), inTx( db, hasSize( 0 ) ) ); try { getIndexState( db, index ); fail( "This index should have been deleted" ); } catch ( NotFoundException e ) { assertThat( e.getMessage(), CoreMatchers.containsString( myLabel.name() ) ); } }
@Test public void shouldRecoverTransactionWhereNodeIsDeletedInTheFuture() throws Exception { // GIVEN Node node = createNodeWithProperty( "key", "value", label ); checkPoint(); setProperty( node, "other-key", 1 ); deleteNode( node ); flush.flush( db ); // WHEN crashAndRestart(); // THEN // -- really the problem was that recovery threw exception, so mostly assert that. try ( Transaction tx = db.beginTx() ) { node = db.getNodeById( node.getId() ); tx.success(); fail( "Should not exist" ); } catch ( NotFoundException e ) { assertEquals( "Node " + node.getId() + " not found", e.getMessage() ); } }
assertTrue( e.getMessage().contains( "already deleted" ) );
@ExceptionHandler(NotFoundException.class) @ResponseStatus(HttpStatus.NOT_FOUND) public Map<String, String> handleNotFound(NotFoundException e) { return Collections.singletonMap("message", e.getMessage()); } }
log.info(e.getMessage()); return null;
@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()); }
@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()); }
log.info(e.getMessage()); return null;
log.info(e.getMessage()); return null;
log.info(e.getMessage()); return null;