use of org.neo4j.logging.FormattedLog in project neo4j by neo4j.
the class InconsistencyReportReaderTest method shouldReadBasicEntities.
@Test
public void shouldReadBasicEntities() throws Exception {
// GIVEN
ByteArrayOutputStream out = new ByteArrayOutputStream(1_000);
FormattedLog log = FormattedLog.toOutputStream(out);
InconsistencyMessageLogger logger = new InconsistencyMessageLogger(log);
long nodeId = 5;
long relationshipGroupId = 10;
long relationshipId = 15;
long propertyId = 20;
logger.error(RecordType.NODE, new NodeRecord(nodeId), "Some error", "something");
logger.error(RecordType.RELATIONSHIP, new RelationshipRecord(relationshipId), "Some error", "something");
logger.error(RecordType.RELATIONSHIP_GROUP, new RelationshipGroupRecord(relationshipGroupId), "Some error", "something");
logger.error(RecordType.PROPERTY, new PropertyRecord(propertyId), "Some error", "something");
String text = out.toString();
PrimitiveLongSet nodes = Primitive.longSet();
PrimitiveLongSet relationships = Primitive.longSet();
PrimitiveLongSet relationshipGroups = Primitive.longSet();
PrimitiveLongSet properties = Primitive.longSet();
// WHEN
InconsistencyReportReader reader = new InconsistencyReportReader(new Inconsistencies() {
@Override
public void relationshipGroup(long id) {
relationshipGroups.add(id);
}
@Override
public void relationship(long id) {
relationships.add(id);
}
@Override
public void property(long id) {
properties.add(id);
}
@Override
public void node(long id) {
nodes.add(id);
}
});
reader.read(new StringReader(text));
// THEN
assertEquals(asSet(iterator(nodeId)), nodes);
assertEquals(asSet(iterator(relationshipId)), relationships);
assertEquals(asSet(iterator(relationshipGroupId)), relationshipGroups);
assertEquals(asSet(iterator(propertyId)), properties);
}
Aggregations