Search in sources :

Example 16 with RawIterator

use of org.neo4j.collection.RawIterator in project neo4j by neo4j.

the class CsvInputTest method shouldReportDuplicateNodeSourceFiles.

@Test
public void shouldReportDuplicateNodeSourceFiles() {
    // given
    String sourceDescription = "The single data source";
    Supplier<CharReadable> source = () -> wrap(dataWithSourceDescription(":ID", sourceDescription), 3);
    Iterable<DataFactory> data = datas(config -> new Data() {

        @Override
        public RawIterator<CharReadable, IOException> stream() {
            // Contains two of the same file
            return asRawIterator(iterator(source.get(), source.get()));
        }

        @Override
        public Decorator decorator() {
            return NO_DECORATOR;
        }
    });
    CsvInput.Monitor monitor = mock(CsvInput.Monitor.class);
    // when
    new CsvInput(data, defaultFormatNodeFileHeader(), datas(), defaultFormatRelationshipFileHeader(), IdType.INTEGER, COMMAS, monitor, INSTANCE);
    // then
    verify(monitor).duplicateSourceFile(sourceDescription);
}
Also used : CharReadable(org.neo4j.csv.reader.CharReadable) Matchers.containsString(org.hamcrest.Matchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) RawIterator(org.neo4j.collection.RawIterator) Iterators.asRawIterator(org.neo4j.internal.helpers.collection.Iterators.asRawIterator) Test(org.junit.Test)

Example 17 with RawIterator

use of org.neo4j.collection.RawIterator in project neo4j by neo4j.

the class CsvInputTest method shouldReportNoNodeLabels.

@Test
public void shouldReportNoNodeLabels() {
    // given
    String sourceDescription = "source";
    Supplier<CharReadable> headerSource = () -> wrap(dataWithSourceDescription(":ID", sourceDescription), 3);
    Iterable<DataFactory> data = datas(config -> new Data() {

        @Override
        public RawIterator<CharReadable, IOException> stream() {
            return asRawIterator(iterator(headerSource.get()));
        }

        @Override
        public Decorator decorator() {
            return NO_DECORATOR;
        }
    });
    CsvInput.Monitor monitor = mock(CsvInput.Monitor.class);
    // when
    new CsvInput(data, defaultFormatNodeFileHeader(), datas(), defaultFormatRelationshipFileHeader(), IdType.INTEGER, COMMAS, monitor, INSTANCE);
    // then
    verify(monitor).noNodeLabelsSpecified(sourceDescription);
}
Also used : CharReadable(org.neo4j.csv.reader.CharReadable) Matchers.containsString(org.hamcrest.Matchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) RawIterator(org.neo4j.collection.RawIterator) Iterators.asRawIterator(org.neo4j.internal.helpers.collection.Iterators.asRawIterator) Test(org.junit.Test)

Example 18 with RawIterator

use of org.neo4j.collection.RawIterator in project neo4j by neo4j.

the class CsvInputTest method shouldReportDuplicateRelationshipSourceFiles.

@Test
public void shouldReportDuplicateRelationshipSourceFiles() {
    // given
    String sourceDescription = "The single data source";
    Supplier<CharReadable> source = () -> wrap(dataWithSourceDescription(":START_ID,:END_ID,:TYPE", sourceDescription), 3);
    Iterable<DataFactory> data = datas(config -> new Data() {

        @Override
        public RawIterator<CharReadable, IOException> stream() {
            // Contains two of the same file
            return asRawIterator(iterator(source.get(), source.get()));
        }

        @Override
        public Decorator decorator() {
            return NO_DECORATOR;
        }
    });
    CsvInput.Monitor monitor = mock(CsvInput.Monitor.class);
    // when
    new CsvInput(datas(), defaultFormatNodeFileHeader(), data, defaultFormatRelationshipFileHeader(), IdType.INTEGER, COMMAS, monitor, INSTANCE);
    // then
    verify(monitor).duplicateSourceFile(sourceDescription);
}
Also used : CharReadable(org.neo4j.csv.reader.CharReadable) Matchers.containsString(org.hamcrest.Matchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) RawIterator(org.neo4j.collection.RawIterator) Iterators.asRawIterator(org.neo4j.internal.helpers.collection.Iterators.asRawIterator) Test(org.junit.Test)

Aggregations

RawIterator (org.neo4j.collection.RawIterator)18 Test (org.junit.Test)8 ProcedureException (org.neo4j.internal.kernel.api.exceptions.ProcedureException)8 AnyValue (org.neo4j.values.AnyValue)8 Matchers.containsString (org.hamcrest.Matchers.containsString)7 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 CharReadable (org.neo4j.csv.reader.CharReadable)7 Iterators.asRawIterator (org.neo4j.internal.helpers.collection.Iterators.asRawIterator)7 List (java.util.List)6 Test (org.junit.jupiter.api.Test)6 Arrays (java.util.Arrays)5 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)5 Iterators.asList (org.neo4j.internal.helpers.collection.Iterators.asList)5 ProcedureCallContext (org.neo4j.internal.kernel.api.procs.ProcedureCallContext)5 Collectors (java.util.stream.Collectors)4 ArrayUtils.toArray (org.apache.commons.lang3.ArrayUtils.toArray)4 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)4 Matchers.contains (org.hamcrest.Matchers.contains)4 Assertions.assertArrayEquals (org.junit.jupiter.api.Assertions.assertArrayEquals)4 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)4