use of org.neo4j.kernel.impl.transaction.command.Command in project neo4j by neo4j.
the class TxPullResponseEncodeDecodeTest method newCommittedTransactionRepresentation.
private CommittedTransactionRepresentation newCommittedTransactionRepresentation() {
final long arbitraryRecordId = 27L;
Command.NodeCommand command = new Command.NodeCommand(new NodeRecord(arbitraryRecordId), new NodeRecord(arbitraryRecordId));
PhysicalTransactionRepresentation physicalTransactionRepresentation = new PhysicalTransactionRepresentation(asList(new LogEntryCommand(command).getXaCommand()));
physicalTransactionRepresentation.setHeader(new byte[] {}, 0, 0, 0, 0, 0, 0);
LogEntryStart startEntry = new LogEntryStart(0, 0, 0L, 0L, new byte[] {}, LogPosition.UNSPECIFIED);
OnePhaseCommit commitEntry = new OnePhaseCommit(42, 0);
return new CommittedTransactionRepresentation(startEntry, physicalTransactionRepresentation, commitEntry);
}
use of org.neo4j.kernel.impl.transaction.command.Command in project neo4j by neo4j.
the class LogEntryParserV2_1Test method shouldParseCommandsUsingAGivenFactory.
@Test
public void shouldParseCommandsUsingAGivenFactory() throws IOException {
// given
final Command.NodeCommand nodeCommand = new Command.NodeCommand(new NodeRecord(0), new NodeRecord(0));
final LogEntryCommand command = new LogEntryCommand(version, nodeCommand);
final InMemoryClosableChannel channel = new InMemoryClosableChannel();
// ignored data
// identifier
channel.putInt(123);
// actual read data
nodeCommand.serialize(channel);
channel.getCurrentPosition(marker);
// when
final LogEntryParser<LogEntry> parser = version.entryParser(LogEntryByteCodes.COMMAND);
final LogEntry logEntry = parser.parse(version, channel, marker, commandReader);
// then
assertEquals(command, entryOf(logEntry));
assertFalse(parser.skip());
}
use of org.neo4j.kernel.impl.transaction.command.Command in project neo4j by neo4j.
the class VersionAwareLogEntryReaderTest method shouldReadACommandLogEntry.
@Test
public void shouldReadACommandLogEntry() throws IOException {
// given
LogEntryVersion version = LogEntryVersion.CURRENT;
Command.NodeCommand nodeCommand = new Command.NodeCommand(new NodeRecord(11), new NodeRecord(11));
final LogEntryCommand command = new LogEntryCommand(version, nodeCommand);
final InMemoryClosableChannel channel = new InMemoryClosableChannel();
channel.put(version.byteCode());
channel.put(LogEntryByteCodes.COMMAND);
nodeCommand.serialize(channel);
// when
final LogEntry logEntry = logEntryReader.readLogEntry(channel);
// then
assertEquals(command, logEntry);
}
use of org.neo4j.kernel.impl.transaction.command.Command in project neo4j by neo4j.
the class NodeCommandTest method shouldSerializeSecondaryUnitUsage.
@Test
public void shouldSerializeSecondaryUnitUsage() throws Exception {
// Given
// a record that is changed to include a secondary unit
NodeRecord before = new NodeRecord(13, false, 1, 2);
before.setInUse(true);
before.setRequiresSecondaryUnit(false);
// this and the previous line set the defaults, they are here for clarity
before.setSecondaryUnitId(NO_ID);
NodeRecord after = new NodeRecord(13, false, 1, 2);
after.setInUse(true);
after.setRequiresSecondaryUnit(true);
after.setSecondaryUnitId(14L);
Command.NodeCommand command = new Command.NodeCommand(before, after);
// Then
assertSerializationWorksFor(command);
}
use of org.neo4j.kernel.impl.transaction.command.Command in project neo4j by neo4j.
the class SchemaRuleCommandTest method shouldWriteSchemaRuleToLog.
@Test
public void shouldWriteSchemaRuleToLog() throws Exception {
// GIVEN
SchemaRecord beforeRecords = serialize(rule, id, false, false);
SchemaRecord afterRecords = serialize(rule, id, true, true);
SchemaRuleCommand command = new SchemaRuleCommand(beforeRecords, afterRecords, rule);
InMemoryClosableChannel buffer = new InMemoryClosableChannel();
when(neoStores.getSchemaStore()).thenReturn(schemaStore);
// WHEN
command.serialize(buffer);
Command readCommand = reader.read(buffer);
// THEN
assertThat(readCommand, instanceOf(SchemaRuleCommand.class));
assertSchemaRule((SchemaRuleCommand) readCommand);
}
Aggregations