Search in sources :

Example 1 with CsvGenerator

use of uk.gov.gchq.gaffer.data.generator.CsvGenerator in project gaffer-doc by gchq.

the class CsvGeneratorExample method elementsToCsv.

public void elementsToCsv() {
    // ---------------------------------------------------------
    final CsvGenerator function = new CsvGenerator.Builder().group("Group Label").vertex("Vertex Label").source("Source Label").property("count", "Count Label").constant("A Constant", "Some constant value").quoted(false).build();
    // ---------------------------------------------------------
    runExample(function, null, Lists.newArrayList(new Entity.Builder().group("Foo").vertex("vertex1").property("count", 1).build(), new Entity.Builder().group("Foo").vertex("vertex2").build(), new Edge.Builder().group("Bar").source("source1").dest("dest1").property("count", 1).build(), new Edge.Builder().group("Bar").source("source1").dest("dest1").build()));
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) CsvGenerator(uk.gov.gchq.gaffer.data.generator.CsvGenerator) Edge(uk.gov.gchq.gaffer.data.element.Edge)

Example 2 with CsvGenerator

use of uk.gov.gchq.gaffer.data.generator.CsvGenerator in project gaffer-doc by gchq.

the class CsvGeneratorExample method elementsToQuotedCsv.

public void elementsToQuotedCsv() {
    // ---------------------------------------------------------
    final CsvGenerator function = new CsvGenerator.Builder().group("Group Label").vertex("Vertex Label").source("Source Label").property("count", "Count Label").constant("A Constant", "Some constant value").quoted(true).build();
    // ---------------------------------------------------------
    runExample(function, null, Lists.newArrayList(new Entity.Builder().group("Foo").vertex("vertex1").property("count", 1).build(), new Entity.Builder().group("Foo").vertex("vertex2").build(), new Edge.Builder().group("Bar").source("source1").dest("dest1").property("count", 1).build(), new Edge.Builder().group("Bar").source("source1").dest("dest1").build()));
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) CsvGenerator(uk.gov.gchq.gaffer.data.generator.CsvGenerator) Edge(uk.gov.gchq.gaffer.data.element.Edge)

Example 3 with CsvGenerator

use of uk.gov.gchq.gaffer.data.generator.CsvGenerator in project Gaffer by gchq.

the class ToCsvTest method shouldShallowCloneOperation.

@Test
@Override
public void shouldShallowCloneOperation() {
    // Given
    final Entity input = new Entity(TestGroups.ENTITY);
    final CsvGenerator generator = new CsvGenerator.Builder().group("group").build();
    final ToCsv toCsv = new ToCsv.Builder().generator(generator).input(input).includeHeader(false).build();
    // When
    final ToCsv clone = toCsv.shallowClone();
    // Then
    assertNotSame(toCsv, clone);
    assertThat(clone.getInput().iterator().next()).isEqualTo(input);
    assertEquals(generator, clone.getElementGenerator());
    assertFalse(clone.isIncludeHeader());
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) CsvGenerator(uk.gov.gchq.gaffer.data.generator.CsvGenerator) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 4 with CsvGenerator

use of uk.gov.gchq.gaffer.data.generator.CsvGenerator in project Gaffer by gchq.

the class ToCsvTest method builderShouldCreatePopulatedOperation.

@Test
@Override
public void builderShouldCreatePopulatedOperation() {
    // Given
    final Entity input = new Entity(TestGroups.ENTITY);
    final CsvGenerator generator = new CsvGenerator.Builder().group("group").build();
    final ToCsv toCsv = new ToCsv.Builder().generator(generator).input(input).includeHeader(false).build();
    // Then
    assertThat(toCsv.getInput()).hasSize(1);
    assertFalse(toCsv.isIncludeHeader());
    assertEquals(generator, toCsv.getElementGenerator());
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) CsvGenerator(uk.gov.gchq.gaffer.data.generator.CsvGenerator) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Aggregations

Entity (uk.gov.gchq.gaffer.data.element.Entity)4 CsvGenerator (uk.gov.gchq.gaffer.data.generator.CsvGenerator)4 Test (org.junit.jupiter.api.Test)2 Edge (uk.gov.gchq.gaffer.data.element.Edge)2 OperationTest (uk.gov.gchq.gaffer.operation.OperationTest)2