@Test public void readPropertyCommandWithFixedReferenceFormat302() throws IOException { InMemoryClosableChannel channel = new InMemoryClosableChannel(); PropertyRecord before = new PropertyRecord( 1 ); PropertyRecord after = new PropertyRecord( 2 ); before.setUseFixedReferences( true ); after.setUseFixedReferences( true ); new Command.PropertyCommand( before, after ).serialize( channel ); PhysicalLogCommandReaderV3_0_2 reader = new PhysicalLogCommandReaderV3_0_2(); Command command = reader.read( channel ); assertTrue( command instanceof Command.PropertyCommand); Command.PropertyCommand neoStoreCommand = (Command.PropertyCommand) command; // Then assertEquals( before.getNextProp(), neoStoreCommand.getBefore().getNextProp() ); assertEquals( after.getNextProp(), neoStoreCommand.getAfter().getNextProp() ); assertTrue( neoStoreCommand.getBefore().isUseFixedReferences() ); assertTrue( neoStoreCommand.getAfter().isUseFixedReferences() ); }
@Test public void readPropertyCommandWithFixedReferenceFormat300() throws IOException { InMemoryClosableChannel channel = new InMemoryClosableChannel(); PropertyRecord before = new PropertyRecord( 1 ); PropertyRecord after = new PropertyRecord( 2 ); before.setUseFixedReferences( true ); after.setUseFixedReferences( true ); new Command.PropertyCommand( before, after ).serialize( channel ); PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0(); Command command = reader.read( channel ); assertTrue( command instanceof Command.PropertyCommand); Command.PropertyCommand neoStoreCommand = (Command.PropertyCommand) command; // Then assertEquals( before.getNextProp(), neoStoreCommand.getBefore().getNextProp() ); assertEquals( after.getNextProp(), neoStoreCommand.getAfter().getNextProp() ); assertTrue( neoStoreCommand.getBefore().isUseFixedReferences() ); assertTrue( neoStoreCommand.getAfter().isUseFixedReferences() ); }
@Test public void shouldReadSomeCommands() throws Exception { // GIVEN InMemoryClosableChannel channel = new InMemoryClosableChannel(); Commands.createNode( 0 ).serialize( channel ); Commands.createNode( 1 ).serialize( channel ); Commands.createRelationshipTypeToken( 0, 0 ).serialize( channel ); Commands.createRelationship( 0, 0, 1, 0 ).serialize( channel ); Commands.createPropertyKeyToken( 0, 0 ).serialize( channel ); Commands.createProperty( 0, PropertyType.SHORT_STRING, 0 ).serialize( channel ); CommandReader reader = new PhysicalLogCommandReaderV3_0(); // THEN assertTrue( reader.read( channel ) instanceof Command.NodeCommand ); assertTrue( reader.read( channel ) instanceof Command.NodeCommand ); assertTrue( reader.read( channel ) instanceof Command.RelationshipTypeTokenCommand ); assertTrue( reader.read( channel ) instanceof Command.RelationshipCommand ); assertTrue( reader.read( channel ) instanceof Command.PropertyKeyTokenCommand ); assertTrue( reader.read( channel ) instanceof Command.PropertyCommand ); }
@Test public void readPropertyCommandWithNonRequiredSecondaryUnit() throws IOException { InMemoryClosableChannel channel = new InMemoryClosableChannel(); PropertyRecord before = new PropertyRecord( 1 ); PropertyRecord after = new PropertyRecord( 2 ); after.setRequiresSecondaryUnit( false ); after.setSecondaryUnitId( 78 ); new Command.PropertyCommand( before, after ).serialize( channel ); PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0(); Command command = reader.read( channel ); assertTrue( command instanceof Command.PropertyCommand); Command.PropertyCommand neoStoreCommand = (Command.PropertyCommand) command; // Then assertEquals( before.getNextProp(), neoStoreCommand.getBefore().getNextProp() ); assertEquals( after.getNextProp(), neoStoreCommand.getAfter().getNextProp() ); verifySecondaryUnit( after, neoStoreCommand.getAfter() ); }
@Test public void readPropertyCommandWithSecondaryUnit() throws IOException { InMemoryClosableChannel channel = new InMemoryClosableChannel(); PropertyRecord before = new PropertyRecord( 1 ); PropertyRecord after = new PropertyRecord( 2 ); after.setRequiresSecondaryUnit( true ); after.setSecondaryUnitId( 78 ); new Command.PropertyCommand( before, after ).serialize( channel ); PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0(); Command command = reader.read( channel ); assertTrue( command instanceof Command.PropertyCommand); Command.PropertyCommand neoStoreCommand = (Command.PropertyCommand) command; // Then assertEquals( before.getNextProp(), neoStoreCommand.getBefore().getNextProp() ); assertEquals( after.getNextProp(), neoStoreCommand.getAfter().getNextProp() ); verifySecondaryUnit( after, neoStoreCommand.getAfter() ); }