@Override public LabelTokenRecord newRecord() { return new LabelTokenRecord( -1 ); } }
@Override public LabelTokenRecord newUnused( long key, Void additionalData ) { return andMarkAsCreated( new LabelTokenRecord( toIntExact( key ) ) ); }
public void label( int id, String name, int... dynamicIds ) { LabelTokenRecord before = new LabelTokenRecord( id ); LabelTokenRecord after = withName( new LabelTokenRecord( id ), dynamicIds, name ); otherCommands.add( new Command.LabelTokenCommand( before, after ) ); }
public static LabelTokenCommand createLabelToken( int id, int nameId ) { LabelTokenRecord before = new LabelTokenRecord( id ); LabelTokenRecord after = new LabelTokenRecord( id ); populateTokenRecord( after, nameId ); return new LabelTokenCommand( before, after ); }
@Override protected LabelTokenRecord createNullRecord( long id ) { return new LabelTokenRecord( (int) id ).initialize( false, 0 ); }
private long[] createLabels( int labelCount ) { long[] labelIds = new long[labelCount]; for ( int i = 0; i < labelIds.length; i++ ) { labelIds[i] = i; add( inUse( new LabelTokenRecord( i ) ) ); } return labelIds; }
@Test void shouldNotReportAnythingForRecordNotInUse() { // given LabelTokenRecord key = notInUse( new LabelTokenRecord( 42 ) ); // when LabelTokenConsistencyReport report = check( key ); // then verifyNoMoreInteractions( report ); }
@Test void shouldNotReportAnythingForRecordThatDoesNotReferenceADynamicBlock() { // given LabelTokenRecord key = inUse( new LabelTokenRecord( 42 ) ); // when LabelTokenConsistencyReport report = check( key ); // then verifyNoMoreInteractions( report ); }
@Override public Generator<LabelTokenRecord> labelToken() { return ( recordSize, format, recordId ) -> new LabelTokenRecord( toIntExact( recordId ) ).initialize( random.nextBoolean(), random.nextInt( tokenBits ) ); }
public void create( LabelTokenRecord labelToken ) { labelToken.setCreated(); update( new LabelTokenRecord( labelToken.getIntId() ), labelToken ); }
@Test public void shouldApplyLabelTokenCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); final LabelTokenRecord before = new LabelTokenRecord( 42 ); final LabelTokenRecord after = new LabelTokenRecord( 42 ); after.setInUse( true ); after.setNameId( 323 ); final Command command = new LabelTokenCommand( before, after ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( labelTokenStore, times( 1 ) ).updateRecord( after ); }
private LabelTokenRecord createLabelTokenRecord( int id ) { LabelTokenRecord labelTokenRecord = new LabelTokenRecord( id ); labelTokenRecord.setInUse( true ); labelTokenRecord.setNameId( 333 ); labelTokenRecord.addNameRecord( new DynamicRecord( 43 ) ); return labelTokenRecord; }
@Override public LabelTokenRecord clone() { LabelTokenRecord labelTokenRecord = new LabelTokenRecord( getIntId() ); labelTokenRecord.setInUse( inUse() ); if ( isCreated() ) { labelTokenRecord.setCreated(); } labelTokenRecord.setNameId( getNameId() ); labelTokenRecord.addNameRecords( getNameRecords() ); return labelTokenRecord; } }
@Test void shouldReportDynamicBlockNotInUse() { // given LabelTokenRecord key = inUse( new LabelTokenRecord( 42 ) ); DynamicRecord name = addLabelName( notInUse( new DynamicRecord( 6 ) ) ); key.setNameId( (int) name.getId() ); // when LabelTokenConsistencyReport report = check( key ); // then verify( report ).nameBlockNotInUse( name ); verifyNoMoreInteractions( report ); }
@Test void shouldReportEmptyName() { // given LabelTokenRecord key = inUse( new LabelTokenRecord( 42 ) ); DynamicRecord name = addLabelName( inUse( new DynamicRecord( 6 ) ) ); key.setNameId( (int) name.getId() ); // when LabelTokenConsistencyReport report = check( key ); // then verify( report ).emptyName( name ); verifyNoMoreInteractions( report ); } }
private int createNewLabelId( String stringKey ) { int keyId = (int) labelTokenStore.nextId(); LabelTokenRecord record = new LabelTokenRecord( keyId ); record.setInUse( true ); record.setCreated(); Collection<DynamicRecord> keyRecords = labelTokenStore.allocateNameRecords( encodeString( stringKey ) ); record.setNameId( (int) Iterables.first( keyRecords ).getId() ); record.addNameRecords( keyRecords ); labelTokenStore.updateRecord( record ); tokenHolders.labelTokens().addToken( new NamedToken( stringKey, keyId ) ); return keyId; }
@Test void shouldReportInvalidPropertyReferenceFromUniquenessConstraintRule() throws Exception { // given int schemaRuleId = 0; int indexRuleId = 1; DynamicRecord record = inUse( dynamicRecord( schemaRuleId ) ); ConstraintRule rule = uniquenessConstraintRule( schemaRuleId, labelId, propertyKeyId, indexRuleId ); when( checker().ruleAccess.loadSingleSchemaRule( schemaRuleId ) ).thenReturn( rule ); add( inUse( new LabelTokenRecord( labelId ) ) ); PropertyKeyTokenRecord propertyKeyToken = add( notInUse( new PropertyKeyTokenRecord( propertyKeyId ) ) ); // when ConsistencyReport.SchemaConsistencyReport report = check( record ); // then verify( report ).propertyKeyNotInUse( propertyKeyToken ); }
@Override protected LabelTokenRecord createExistingRecord( boolean light ) { LabelTokenRecord record = new LabelTokenRecord( ID ); record.setNameId( NAME_RECORD_ID ); record.setInUse( true ); if ( !light ) { DynamicRecord nameRecord = new DynamicRecord( NAME_RECORD_ID ); nameRecord.setInUse( true ); nameRecord.setData( NAME_RECORD_DATA ); record.addNameRecord( nameRecord ); } return record; }
@Test void shouldReportInvalidLabelReferences() throws Exception { // given int schemaRuleId = 0; DynamicRecord record = inUse( dynamicRecord( schemaRuleId ) ); IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor( "in-memory", "1.0" ); StoreIndexDescriptor rule = indexRule( schemaRuleId, labelId, propertyKeyId, providerDescriptor ); when( checker().ruleAccess.loadSingleSchemaRule( schemaRuleId ) ).thenReturn( rule ); LabelTokenRecord labelTokenRecord = add( notInUse( new LabelTokenRecord( labelId ) ) ); add(inUse( new PropertyKeyTokenRecord( propertyKeyId ) ) ); // when ConsistencyReport.SchemaConsistencyReport report = check( record ); // then verify( report ).labelNotInUse( labelTokenRecord ); }
@Test void shouldReportLabelNotInUse() { // given NodeRecord node = inUse( new NodeRecord( 42, false, NONE, NONE ) ); new InlineNodeLabels( node ).add( 1, null, null ); LabelTokenRecord labelRecordNotInUse = notInUse( new LabelTokenRecord( 1 ) ); add( labelRecordNotInUse ); add( node ); // when ConsistencyReport.NodeConsistencyReport report = check( node ); // then verify( report ).labelNotInUse( labelRecordNotInUse ); }