@SafeVarargs public static RelationshipRecordCheck relationshipRecordCheckBackwardPass( RecordField<RelationshipRecord,ConsistencyReport.RelationshipConsistencyReport>... additional ) { return new RelationshipRecordCheck( union( ArrayUtil.<RecordField<RelationshipRecord,ConsistencyReport.RelationshipConsistencyReport>>array( NodeField.SOURCE, NodeField.TARGET ), additional ) ); }
@SafeVarargs static NodeRecordCheck forDenseNodes( RecordField<NodeRecord,ConsistencyReport.NodeConsistencyReport>... additional ) { RecordField<NodeRecord,ConsistencyReport.NodeConsistencyReport>[] basic = ArrayUtil.<RecordField<NodeRecord,ConsistencyReport.NodeConsistencyReport>>array( RelationshipGroupField.NEXT_GROUP, LabelsField.LABELS ); return new NodeRecordCheck( union( basic, additional ) ); }
@SafeVarargs static NodeRecordCheck forSparseNodes( RecordField<NodeRecord,ConsistencyReport.NodeConsistencyReport>... additional ) { RecordField<NodeRecord,ConsistencyReport.NodeConsistencyReport>[] basic = ArrayUtil.<RecordField<NodeRecord,ConsistencyReport.NodeConsistencyReport>>array( LabelsField.LABELS ); return new NodeRecordCheck( union( basic, additional ) ); }
@Test void shouldProduceUnionOfTwoArrays() { // GIVEN String[] first = {"one", "three"}; String[] other = {"two", "four", "five"}; // WHEN String[] union = ArrayUtil.union( first, other ); // THEN assertEquals( asSet( "one", "two", "three", "four", "five" ), asSet( union ) ); }
@Test void shouldProduceUnionWhereFirstIsNull() { // GIVEN String[] first = null; String[] other = {"one", "two"}; // WHEN String[] union = ArrayUtil.union( first, other ); // THEN assertEquals( asSet( "one", "two" ), asSet( union ) ); }
@Test void shouldProduceUnionWhereOtherIsNull() { // GIVEN String[] first = {"one", "two"}; String[] other = null; // WHEN String[] union = ArrayUtil.union( first, other ); // THEN assertEquals( asSet( "one", "two" ), asSet( union ) ); }
@Test public void shouldAddMissingLabels() throws Exception { // GIVEN String[] toAdd = new String[] {"Add1", "Add2"}; InputEntityVisitor node = additiveLabels( toAdd ).apply( entity ); // WHEN String[] nodeLabels = new String[] {"SomeOther"}; node( node, "source", 1, 0, "id", NO_PROPERTIES, null, nodeLabels, null ); // THEN assertEquals( asSet( ArrayUtil.union( toAdd, nodeLabels ) ), asSet( entity.labels() ) ); }
@Test public void shouldProvideAdditiveLabels() throws Exception { // GIVEN String[] addedLabels = {"Two", "AddTwo"}; DataFactory data = data( ":ID,name,:LABEL\n" + "0,First,\n" + "1,Second,One\n" + "2,Third,One;Two", additiveLabels( addedLabels ) ); Iterable<DataFactory> dataIterable = dataIterable( data ); Input input = new CsvInput( dataIterable, defaultFormatNodeFileHeader(), datas(), defaultFormatRelationshipFileHeader(), IdType.ACTUAL, config( COMMAS ), silentBadCollector( 0 ) ); // WHEN/THEN try ( InputIterator nodes = input.nodes().iterator() ) { assertNextNode( nodes, 0L, properties( "name", "First" ), labels( addedLabels ) ); assertNextNode( nodes, 1L, properties( "name", "Second" ), labels( union( new String[] {"One"}, addedLabels ) ) ); assertNextNode( nodes, 2L, properties( "name", "Third" ), labels( union( new String[] {"One"}, addedLabels ) ) ); assertFalse( readNext( nodes ) ); } }