Refine search
@Override public IndexHits<T> query( String key, Object queryOrQueryObject ) { KernelTransaction ktx = txBridge.get(); try ( Statement ignore = ktx.acquireStatement() ) { return type.query( ktx, name, key, queryOrQueryObject, gds ); } catch ( ExplicitIndexNotFoundKernelException e ) { throw new NotFoundException( type + " index '" + name + "' doesn't exist" ); } }
private NotFoundException newIndexNotFoundException( IndexDefinition index, KernelException e ) { return new NotFoundException( "No index was found corresponding to " + index + ".", e ); }
@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 ) ); } }
private Node mergeNodes(Node source, Node target, boolean delete, RefactorConfig conf) { try { Map<String, Object> properties = source.getAllProperties(); copyRelationships(source, copyLabels(source, target), delete); PropertiesManager.mergeProperties(properties, target, conf); if (conf.getMergeRelsAllowed()) { if(!conf.hasProperties()) { Map<String, Object> map = Collections.singletonMap("properties", "combine"); conf = new RefactorConfig(map); } mergeRelsWithSameTypeAndDirectionInMergeNodes(target, conf, Direction.OUTGOING); mergeRelsWithSameTypeAndDirectionInMergeNodes(target, conf, Direction.INCOMING); } if (delete) source.delete(); } catch (NotFoundException e) { log.warn("skipping a node for merging: " + e.getCause().getMessage()); } return target; }
public final <T> T getSingleManagementBean( Class<T> type ) { Iterator<T> beans = getManagementBeans( type ).iterator(); if ( beans.hasNext() ) { T bean = beans.next(); if ( beans.hasNext() ) { throw new NotFoundException( "More than one management bean for " + type.getName() ); } return bean; } throw new NotFoundException( "No management bean found for " + type.getName() ); }
@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" ) ); } }
@Override public IndexHits<T> get( String key, Object value ) { KernelTransaction ktx = txBridge.get(); try ( Statement ignore = ktx.acquireStatement() ) { return internalGet( key, value, ktx ) ; } catch ( ExplicitIndexNotFoundKernelException e ) { throw new NotFoundException( type + " index '" + name + "' doesn't exist" ); } }
public T getSingle() { final Iterator<T> expanded = iterator(); if ( expanded.hasNext() ) { final T result = expanded.next(); if ( expanded.hasNext() ) { throw new NotFoundException( "More than one relationship found for " + this ); } return result; } return null; }
@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" ) ); } }
@Override public IndexHits<T> query( Object queryOrQueryObject ) { KernelTransaction ktx = txBridge.get(); try ( Statement ignore = ktx.acquireStatement() ) { return type.query( ktx, name, queryOrQueryObject, gds ); } catch ( ExplicitIndexNotFoundKernelException e ) { throw new NotFoundException( type + " index '" + name + "' doesn't exist" ); } }
private static <T> int[] resolveAndValidateTokens( String tokenTypeName, T[] tokens, Function<T,String> getTokenName, ToIntFunction<String> getTokenId ) { int[] tokenIds = new int[tokens.length]; for ( int i = 0; i < tokenIds.length; i++ ) { String tokenName = getTokenName.apply( tokens[i] ); int tokenId = getTokenId.applyAsInt( tokenName ); if ( tokenId == TokenRead.NO_TOKEN ) { throw new NotFoundException( tokenTypeName + " " + tokenName + " not found." ); } tokenIds[i] = tokenId; } return tokenIds; }
@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 ) ); } }
@Override public void add( T entity, String key, Object value ) { KernelTransaction ktx = txBridge.get(); try ( Statement ignore = ktx.acquireStatement() ) { internalAdd( entity, key, value, ktx ); } catch ( EntityNotFoundException e ) { throw new NotFoundException( format( "%s %d not found", type, type.id( entity ) ), e ); } catch ( InvalidTransactionTypeKernelException e ) { throw new ConstraintViolationException( e.getMessage(), e ); } catch ( ExplicitIndexNotFoundKernelException e ) { throw new NotFoundException( type + " index '" + name + "' doesn't exist" ); } }
@Override public Object answer( InvocationOnMock invocation ) { Object[] arguments = invocation.getArguments(); @SuppressWarnings( "SuspiciousMethodCalls" ) Object result = properties.get( arguments[0] ); if ( result == null ) { if ( arguments.length == 2 ) { return arguments[1]; } else { throw new NotFoundException(); } } return result; }
@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() ) ); } }
@Override public void delete() { KernelTransaction ktx = txBridge.get(); try ( Statement ignore = ktx.acquireStatement() ) { type.drop( ktx.indexWrite(), name ); } catch ( InvalidTransactionTypeKernelException e ) { throw new ConstraintViolationException( e.getMessage(), e ); } catch ( ExplicitIndexNotFoundKernelException e ) { throw new NotFoundException( type + " index '" + name + "' doesn't exist" ); } }
private RecordProxy<NodeRecord,Void> getNodeRecord( long id ) { if ( id < 0 || id >= nodeStore.getHighId() ) { throw new NotFoundException( "id=" + id ); } return recordAccess.getNodeRecords().getOrLoad( id, null ); }
@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() ); } }
@Override public void remove( T entity ) { KernelTransaction ktx = txBridge.get(); try ( Statement ignore = ktx.acquireStatement() ) { internalRemove( ktx, type.id( entity ) ); } catch ( InvalidTransactionTypeKernelException e ) { throw new ConstraintViolationException( e.getMessage(), e ); } catch ( ExplicitIndexNotFoundKernelException e ) { throw new NotFoundException( type + " index '" + name + "' doesn't exist" ); } }
private RecordProxy<RelationshipRecord,Void> getRelationshipRecord( long id ) { if ( id < 0 || id >= relationshipStore.getHighId() ) { throw new NotFoundException( "id=" + id ); } return recordAccess.getRelRecords().getOrLoad( id, null ); }