Search in sources :

Example 1 with BasicGenerator

use of uk.gov.gchq.gaffer.integration.generators.BasicGenerator in project Gaffer by gchq.

the class GeneratorsIT method shouldConvertFromDomainObjects.

@Test
public void shouldConvertFromDomainObjects() throws OperationException, UnsupportedEncodingException {
    // Given
    final OperationChain<Void> opChain = new OperationChain.Builder().first(new GenerateElements.Builder<DomainObject>().generator(new BasicGenerator()).objects(Arrays.asList(new EntityDomainObject(NEW_VERTEX, "1", null), new EdgeDomainObject(NEW_SOURCE, NEW_DEST, false, 1, 1L))).build()).then(new AddElements()).build();
    // When - add
    graph.execute(opChain, getUser());
    // Then - check they were added correctly
    final List<Element> results = Lists.newArrayList(graph.execute(new GetElements.Builder<>().addSeed(new EntitySeed(NEW_VERTEX)).addSeed(new EdgeSeed(NEW_SOURCE, NEW_DEST, false)).build(), getUser()));
    final Edge expectedEdge = new Edge(TestGroups.EDGE, NEW_SOURCE, NEW_DEST, false);
    expectedEdge.putProperty(TestPropertyNames.INT, 1);
    expectedEdge.putProperty(TestPropertyNames.COUNT, 1L);
    final Entity expectedEntity = new Entity(TestGroups.ENTITY, NEW_VERTEX);
    expectedEntity.putProperty(TestPropertyNames.STRING, "1");
    assertNotNull(results);
    assertEquals(2, results.size());
    assertThat(results, IsCollectionContaining.hasItems(expectedEntity, expectedEdge));
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Entity(uk.gov.gchq.gaffer.data.element.Entity) BasicGenerator(uk.gov.gchq.gaffer.integration.generators.BasicGenerator) Element(uk.gov.gchq.gaffer.data.element.Element) EntityDomainObject(uk.gov.gchq.gaffer.integration.domain.EntityDomainObject) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) EdgeDomainObject(uk.gov.gchq.gaffer.integration.domain.EdgeDomainObject) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Edge(uk.gov.gchq.gaffer.data.element.Edge) Test(org.junit.Test)

Example 2 with BasicGenerator

use of uk.gov.gchq.gaffer.integration.generators.BasicGenerator in project Gaffer by gchq.

the class GeneratorsIT method shouldConvertToDomainObjects.

@Test
public void shouldConvertToDomainObjects() throws OperationException, UnsupportedEncodingException {
    // Given
    final OperationChain<CloseableIterable<DomainObject>> opChain = new OperationChain.Builder().first(new GetElements.Builder<>().addSeed(new EntitySeed(SOURCE_1)).build()).then(new GenerateObjects.Builder<Element, DomainObject>().generator(new BasicGenerator()).outputType(new TypeReference<CloseableIterable<DomainObject>>() {
    }).build()).build();
    // When
    final List<DomainObject> results = Lists.newArrayList(graph.execute(opChain, getUser()));
    final EntityDomainObject entityDomainObject = new EntityDomainObject(SOURCE_1, "3", null);
    final EdgeDomainObject edgeDomainObject = new EdgeDomainObject(SOURCE_1, DEST_1, false, 1, 1L);
    // Then
    assertNotNull(results);
    assertEquals(2, results.size());
    assertThat(results, IsCollectionContaining.hasItems(entityDomainObject, edgeDomainObject));
}
Also used : BasicGenerator(uk.gov.gchq.gaffer.integration.generators.BasicGenerator) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) Element(uk.gov.gchq.gaffer.data.element.Element) EntityDomainObject(uk.gov.gchq.gaffer.integration.domain.EntityDomainObject) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) EdgeDomainObject(uk.gov.gchq.gaffer.integration.domain.EdgeDomainObject) GenerateObjects(uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) EdgeDomainObject(uk.gov.gchq.gaffer.integration.domain.EdgeDomainObject) DomainObject(uk.gov.gchq.gaffer.integration.domain.DomainObject) EntityDomainObject(uk.gov.gchq.gaffer.integration.domain.EntityDomainObject) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Element (uk.gov.gchq.gaffer.data.element.Element)2 EdgeDomainObject (uk.gov.gchq.gaffer.integration.domain.EdgeDomainObject)2 EntityDomainObject (uk.gov.gchq.gaffer.integration.domain.EntityDomainObject)2 BasicGenerator (uk.gov.gchq.gaffer.integration.generators.BasicGenerator)2 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)2 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)2 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)1 Edge (uk.gov.gchq.gaffer.data.element.Edge)1 Entity (uk.gov.gchq.gaffer.data.element.Entity)1 DomainObject (uk.gov.gchq.gaffer.integration.domain.DomainObject)1 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)1 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)1 GenerateObjects (uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects)1