@Override public NeoStoreRecord clone() { NeoStoreRecord neoStoreRecord = new NeoStoreRecord(); neoStoreRecord.setNextProp( getNextProp() ); return neoStoreRecord; } }
private NeoStoreRecord readNeoStoreRecord( ReadableChannel channel ) throws IOException { long nextProp = channel.getLong(); NeoStoreRecord record = new NeoStoreRecord(); record.setNextProp( nextProp ); return record; }
public NeoStoreRecord graphPropertyRecord() { NeoStoreRecord result = new NeoStoreRecord(); result.setNextProp( getGraphNextProp() ); return result; }
private NeoStoreRecord readNeoStoreRecord( ReadableChannel channel ) throws IOException { long nextProp = channel.getLong(); NeoStoreRecord record = new NeoStoreRecord(); record.setNextProp( nextProp ); return record; }
private Command visitNeoStoreCommand( ReadableChannel channel ) throws IOException { long nextProp = channel.getLong(); NeoStoreRecord record = new NeoStoreRecord(); record.setNextProp( nextProp ); return new Command.NeoStoreCommand( null, record ); }
private Command visitNeoStoreCommand( ReadableChannel channel ) throws IOException { long nextProp = channel.getLong(); NeoStoreRecord record = new NeoStoreRecord(); record.setNextProp( nextProp ); return new Command.NeoStoreCommand( null, record ); }
@Test void shouldNotReportAnythingForRecordWithNoPropertyReference() { // given NeoStoreRecord record = new NeoStoreRecord(); // when ConsistencyReport.NeoStoreConsistencyReport report = check( record ); // then verifyNoMoreInteractions( report ); }
private static String neoStoreRecord( boolean used, long nextProp ) { NeoStoreRecord record = new NeoStoreRecord(); record.setInUse( used ); record.setNextProp( nextProp ); return record.toString(); } }
@Test public void shouldApplyNeoStoreCommandToTheStoreInRecovery() throws Exception { // given final BatchTransactionApplier applier = newApplier( true ); final NeoStoreRecord before = new NeoStoreRecord(); final NeoStoreRecord after = new NeoStoreRecord(); after.setNextProp( 42 ); final Command command = new Command.NeoStoreCommand( before, after ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( metaDataStore, times( 1 ) ).setGraphNextProp( after.getNextProp() ); }
@Test public void shouldApplyNeoStoreCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); final NeoStoreRecord before = new NeoStoreRecord(); final NeoStoreRecord after = new NeoStoreRecord(); after.setNextProp( 42 ); final Command command = new Command.NeoStoreCommand( before, after ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( metaDataStore, times( 1 ) ).setGraphNextProp( after.getNextProp() ); }
@Test void shouldFormatLogForChangedRecord() { // when logger.error( RecordType.NEO_STORE, new NeoStoreRecord(), new NeoStoreRecord(), "sample message", 1, 2 ); // then logProvider.assertExactly( INLOG.error( join( "sample message", "- " + neoStoreRecord( true, -1 ), "+ " + neoStoreRecord( true, -1 ), "Inconsistent with: 1 2" ) ) ); }
@Test void shouldReportPropertyNotInUse() { // given NeoStoreRecord record = new NeoStoreRecord(); PropertyRecord property = add( notInUse( new PropertyRecord( 7 ) ) ); record.setNextProp( property.getId() ); // when ConsistencyReport.NeoStoreConsistencyReport report = check( record ); // then verify( report ).propertyNotInUse( property ); verifyNoMoreInteractions( report ); }
@Test void shouldNotReportAnythingForRecordWithConsistentReferenceToProperty() { // given NeoStoreRecord record = new NeoStoreRecord(); record.setNextProp( add( inUse( new PropertyRecord( 7 ) ) ).getId() ); // when ConsistencyReport.NeoStoreConsistencyReport report = check( record ); // then verifyNoMoreInteractions( report ); }
@Test void shouldReportPropertyNotFirstInChain() { // given NeoStoreRecord record = new NeoStoreRecord(); PropertyRecord property = add( inUse( new PropertyRecord( 7 ) ) ); property.setPrevProp( 6 ); record.setNextProp( property.getId() ); // when ConsistencyReport.NeoStoreConsistencyReport report = check( record ); // then verify( report ).propertyNotFirstInChain( property ); verifyNoMoreInteractions( report ); } }
@Test void shouldFlattenAMultiLineMessageToASingleLine() { // when logger.error( RecordType.NEO_STORE, new NeoStoreRecord(), "multiple\n line\r\n message", 1, 2 ); // then logProvider.assertExactly( INLOG.error( join( "multiple line message", neoStoreRecord( true, -1 ), "Inconsistent with: 1 2" ) ) ); }
@Test void shouldFormatErrorForRecord() { // when logger.error( RecordType.NEO_STORE, new NeoStoreRecord(), "sample message", 1, 2 ); // then logProvider.assertExactly( INLOG.error( join( "sample message", neoStoreRecord( true, -1 ), "Inconsistent with: 1 2" ) ) ); }
@Test void shouldFormatWarningForRecord() { // when logger.warning( RecordType.NEO_STORE, new NeoStoreRecord(), "sample message", 1, 2 ); // then logProvider.assertExactly( INLOG.warn( join( "sample message", neoStoreRecord( true, -1 ), "Inconsistent with: 1 2" ) ) ); }
@Test public void shouldReadNeoStoreCommand() throws Throwable { // Given InMemoryClosableChannel channel = new InMemoryClosableChannel(); NeoStoreRecord before = new NeoStoreRecord(); NeoStoreRecord after = new NeoStoreRecord(); after.setNextProp( 42 ); new Command.NeoStoreCommand( before, after ).serialize( channel ); // When PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0(); Command command = reader.read( channel ); assertTrue( command instanceof Command.NeoStoreCommand); Command.NeoStoreCommand neoStoreCommand = (Command.NeoStoreCommand) command; // Then assertEquals( before.getNextProp(), neoStoreCommand.getBefore().getNextProp() ); assertEquals( after.getNextProp(), neoStoreCommand.getAfter().getNextProp() ); }
@Test void shouldReportNodeStoreReferencingSameChainAsNode() { // given OwnerCheck decorator = new OwnerCheck( true ); RecordCheck<NodeRecord, ConsistencyReport.NodeConsistencyReport> nodeChecker = decorator.decorateNodeChecker( dummyNodeCheck() ); RecordCheck<NeoStoreRecord, ConsistencyReport.NeoStoreConsistencyReport> neoStoreCheck = decorator.decorateNeoStoreChecker( dummyNeoStoreCheck() ); RecordAccessStub records = new RecordAccessStub(); NodeRecord node = records.add( inUse( new NodeRecord( 1, false, NONE, 7 ) ) ); NeoStoreRecord master = records.add( new NeoStoreRecord() ); master.setNextProp( node.getNextProp() ); // when ConsistencyReport.NodeConsistencyReport nodeReport = check( ConsistencyReport.NodeConsistencyReport.class, nodeChecker, node, records ); ConsistencyReport.NeoStoreConsistencyReport masterReport = check( ConsistencyReport.NeoStoreConsistencyReport.class, neoStoreCheck, master, records ); // then verifyZeroInteractions( nodeReport ); verify( masterReport ).multipleOwners( node ); }
@Test void shouldReportRelationshipWithReferenceToTheGraphGlobalChain() { // given OwnerCheck decorator = new OwnerCheck( true ); RecordCheck<RelationshipRecord, ConsistencyReport.RelationshipConsistencyReport> relationshipChecker = decorator.decorateRelationshipChecker( dummyRelationshipChecker() ); RecordCheck<NeoStoreRecord, ConsistencyReport.NeoStoreConsistencyReport> neoStoreCheck = decorator.decorateNeoStoreChecker( dummyNeoStoreCheck() ); RecordAccessStub records = new RecordAccessStub(); NeoStoreRecord master = records.add( new NeoStoreRecord() ); master.setNextProp( 7 ); RelationshipRecord relationship = records.add( inUse( new RelationshipRecord( 1, 0, 1, 0 ) ) ); relationship.setNextProp( 7 ); // when ConsistencyReport.NeoStoreConsistencyReport masterReport = check( ConsistencyReport.NeoStoreConsistencyReport.class, neoStoreCheck, master, records ); ConsistencyReport.RelationshipConsistencyReport relationshipReport = check( ConsistencyReport.RelationshipConsistencyReport.class, relationshipChecker, relationship, records ); // then verifyZeroInteractions( masterReport ); verify( relationshipReport ).multipleOwners( master ); }