use of uk.gov.gchq.gaffer.integration.domain.EntityDomainObject 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));
}
use of uk.gov.gchq.gaffer.integration.domain.EntityDomainObject 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));
}
use of uk.gov.gchq.gaffer.integration.domain.EntityDomainObject in project Gaffer by gchq.
the class BasicEntityGenerator method getObject.
@Override
public EntityDomainObject getObject(final Element element) {
if (element instanceof Entity) {
final Entity entity = ((Entity) element);
final EntityDomainObject basicEntity = new EntityDomainObject();
basicEntity.setName((String) entity.getVertex());
basicEntity.setIntProperty((Integer) entity.getProperty(TestPropertyNames.INT));
basicEntity.setStringproperty((String) entity.getProperty(TestPropertyNames.STRING));
return basicEntity;
}
throw new IllegalArgumentException("Edges cannot be handled with this generator.");
}
Aggregations