public static String[] getPropertyKeys( TokenNameLookup tokenNameLookup, int[] propertyIds ) { String[] propertyKeys = new String[propertyIds.length]; for ( int i = 0; i < propertyIds.length; i++ ) { propertyKeys[i] = tokenNameLookup.propertyKeyGetName( propertyIds[i] ); } return propertyKeys; }
private TokenNameLookup getDefaultTokenNameLookup() { TokenNameLookup tokenNameLookup = mock( TokenNameLookup.class ); Mockito.when( tokenNameLookup.labelGetName( labelId( LABEL1 ) ) ).thenReturn( LABEL1 ); Mockito.when( tokenNameLookup.propertyKeyGetName( propId( PROP1 ) ) ).thenReturn( PROP1 ); Mockito.when( tokenNameLookup.relationshipTypeGetName( typeId( TYPE1 ) ) ).thenReturn( TYPE1 ); return tokenNameLookup; }
@Override public String userDescription( TokenNameLookup tokenNameLookup ) { return String.format( entityType + ":%s(%s)", String.join( ", ", tokenNameLookup.entityTokensGetNames( entityType, entityTokens ) ), SchemaUtil.niceProperties( tokenNameLookup, propertyIds ) ); }
@Override public String getUserMessage( TokenNameLookup tokenNameLookup ) { return format( "Relationship(%s) with type `%s` must have the property `%s`", relationshipId, tokenNameLookup.relationshipTypeGetName( schema.getRelTypeId() ), tokenNameLookup.propertyKeyGetName( schema.getPropertyId() ) ); } }
.thenReturn( InternalIndexState.FAILED ); when(mockLookup.labelGetName( 1 )).thenReturn( "LabelOne" ); when( mockLookup.labelGetName( 2 ) ).thenReturn( "LabelTwo" ); when( mockLookup.propertyKeyGetName( 1 ) ).thenReturn( "propertyOne" ); when( mockLookup.propertyKeyGetName( 2 ) ).thenReturn( "propertyTwo" );
@Override public String userDescription( TokenNameLookup tokenNameLookup ) { return String.format( ":%s(%s)", tokenNameLookup.labelGetName( labelId ), SchemaUtil.niceProperties( tokenNameLookup, propertyIds ) ); }
@Override public String userDescription( TokenNameLookup tokenNameLookup ) { return String.format( "-[:%s(%s)]-", tokenNameLookup.relationshipTypeGetName( relTypeId ), SchemaUtil.niceProperties( tokenNameLookup, propertyIds ) ); }
.thenReturn( StoreMigrationParticipant.NOT_PARTICIPATING ); when( nameLookup.labelGetName( anyInt() ) ).thenAnswer( new NameLookupAnswer( "label" ) ); when( nameLookup.propertyKeyGetName( anyInt() ) ).thenAnswer( new NameLookupAnswer( "property" ) );
@Override public String prettyPrint( TokenNameLookup tokenNameLookup ) { String typeName = escapeLabelOrRelTyp( tokenNameLookup.relationshipTypeGetName( schema.getRelTypeId() ) ); String relName = typeName.toLowerCase(); String propertyName = tokenNameLookup.propertyKeyGetName( schema.getPropertyId() ); return String.format( "CONSTRAINT ON ()-[ %s:%s ]-() ASSERT exists(%s.%s)", relName, typeName, relName, propertyName ); } }
@Override public String prettyPrint( TokenNameLookup tokenNameLookup ) { String labelName = escapeLabelOrRelTyp( tokenNameLookup.labelGetName( schema.getLabelId() ) ); String nodeName = labelName.toLowerCase(); String properties = SchemaUtil.niceProperties( tokenNameLookup, schema.getPropertyIds(), nodeName + ".", false ); return String.format( "CONSTRAINT ON ( %s:%s ) ASSERT exists(%s)", nodeName, labelName, properties ); } }
@Override public String userDescription( TokenNameLookup tokenNameLookup ) { return String.format( "-[:%s(%s)]-", tokenNameLookup.relationshipTypeGetName( relTypeId ), SchemaUtil.niceProperties( tokenNameLookup, propertyIds ) ); }
when(mockLookup.labelGetName( 1 )).thenReturn( "LabelOne" ); when(mockLookup.labelGetName( 2 )).thenReturn( "LabelTwo" ); when(mockLookup.propertyKeyGetName( 1 )).thenReturn( "propertyOne" ); when(mockLookup.propertyKeyGetName( 2 )).thenReturn( "propertyTwo" ); when( storeView.indexSample( anyLong(), any( DoubleLongRegister.class ) ) ).thenReturn( newDoubleLongRegister( 32L, 32L ) );
@Override public String getUserMessage( TokenNameLookup tokenNameLookup ) { return format( "%s has no property with propertyKey=\"%s\".", entity, tokenNameLookup.propertyKeyGetName( propertyKeyId ) ); } }
@Override public String getUserMessage( TokenNameLookup tokenNameLookup ) { return format( "Relationship(%s) with type `%s` must have the property `%s`", relationshipId, tokenNameLookup.relationshipTypeGetName( schema.getRelTypeId() ), tokenNameLookup.propertyKeyGetName( schema.getPropertyId() ) ); } }
@Override public String getUserMessage( TokenNameLookup tokenNameLookup ) { String propertyNoun = (schema.getPropertyIds().length > 1) ? "properties" : "property"; return format( "Node(%d) with label `%s` must have the %s `%s`", nodeId, tokenNameLookup.labelGetName( schema.getLabelId() ), propertyNoun, SchemaUtil.niceProperties( tokenNameLookup, schema.getPropertyIds() ) ); } }
List<String> tokenNames = Arrays.asList( tokens.entityTokensGetNames( schema.entityType(), schema.getEntityTokenIds() ) ); List<String> propertyNames = propertyNames( tokens, index ); String description = "INDEX ON " + schema.userDescription( tokens );
@Test public void shouldStoreIndexFailureWhenFailingToCreateOnlineAccessorAfterRecoveringPopulatingIndex() throws Exception { // given long indexId = 1; StoreIndexDescriptor indexRule = index.withId( indexId ); IndexingService indexing = newIndexingServiceWithMockedDependencies( populator, accessor, withData(), indexRule ); IOException exception = new IOException( "Expected failure" ); when( nameLookup.labelGetName( labelId ) ).thenReturn( "TheLabel" ); when( nameLookup.propertyKeyGetName( propertyKeyId ) ).thenReturn( "propertyKey" ); when( indexProvider.getInitialState( indexRule ) ).thenReturn( POPULATING ); when( indexProvider.getOnlineAccessor( any( StoreIndexDescriptor.class ), any( IndexSamplingConfig.class ) ) ) .thenThrow( exception ); life.start(); ArgumentCaptor<Boolean> closeArgs = ArgumentCaptor.forClass( Boolean.class ); // when waitForIndexesToGetIntoState( indexing, InternalIndexState.FAILED, indexId ); verify( populator, timeout( 10000 ).times( 2 ) ).close( closeArgs.capture() ); // then assertEquals( FAILED, indexing.getIndexProxy( 1 ).getState() ); assertEquals( asList( true, false ), closeArgs.getAllValues() ); assertThat( storedFailure(), containsString( format( "java.io.IOException: Expected failure%n\tat " ) ) ); internalLogProvider.assertAtLeastOnce( inLog( IndexPopulationJob.class ).error( equalTo( "Failed to populate index: [:TheLabel(propertyKey) [provider: {key=quantum-dex, version=25.0}]]" ), causedBy( exception ) ) ); internalLogProvider.assertNone( inLog( IndexPopulationJob.class ).info( "Index population completed. Index is now online: [%s]", ":TheLabel(propertyKey) [provider: {key=quantum-dex, version=25.0}]" ) ); }
private static List<String> propertyNames( TokenNameLookup tokens, IndexReference index ) { int[] propertyIds = index.properties(); List<String> propertyNames = new ArrayList<>( propertyIds.length ); for ( int propertyId : propertyIds ) { propertyNames.add( tokens.propertyKeyGetName( propertyId ) ); } return propertyNames; }
@Override public String prettyPrint( TokenNameLookup tokenNameLookup ) { String typeName = escapeLabelOrRelTyp( tokenNameLookup.relationshipTypeGetName( schema.getRelTypeId() ) ); String relName = typeName.toLowerCase(); String propertyName = tokenNameLookup.propertyKeyGetName( schema.getPropertyId() ); return String.format( "CONSTRAINT ON ()-[ %s:%s ]-() ASSERT exists(%s.%s)", relName, typeName, relName, propertyName ); } }
@Override public String prettyPrint( TokenNameLookup tokenNameLookup ) { String labelName = escapeLabelOrRelTyp( tokenNameLookup.labelGetName( schema.getLabelId() ) ); String nodeName = labelName.toLowerCase(); return String.format( "CONSTRAINT ON ( %s:%s ) ASSERT %s IS %s", nodeName, labelName, formatProperties( schema.getPropertyIds(), tokenNameLookup, nodeName ), constraintTypeText() ); }