use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.
the class StoreValidationIT method shouldRemoveInvalidElements.
@Test
@TraitRequirement(StoreTrait.STORE_VALIDATION)
public void shouldRemoveInvalidElements() throws OperationException, InterruptedException {
// Given
final User user = new User();
final Entity entity = new Entity(TestGroups.ENTITY_2, VERTEX);
entity.putProperty(TestPropertyNames.INT, 100);
// add elements but skip the validation
graph.execute(new AddElements.Builder().elements(Collections.<Element>singleton(entity)).validate(false).build(), user);
// When
final CloseableIterable<Entity> results1 = graph.execute(new GetEntities.Builder<>().addSeed(new EntitySeed(VERTEX)).build(), user);
// Then
final List<Entity> results1List = Lists.newArrayList(results1);
assertTrue(results1List.isEmpty());
}
use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.
the class TransformationIT method shouldNotStoreEntityPropertiesThatAreNotInSchema.
/**
* Tests that the entity stored does not contain any transient properties not stored in the Schemas.
*
* @throws OperationException should never be thrown.
*/
@Test
public void shouldNotStoreEntityPropertiesThatAreNotInSchema() throws OperationException {
// Given
final GetEntities<EntitySeed> getEntities = new GetEntities.Builder<EntitySeed>().addSeed(new EntitySeed(VERTEX)).build();
// When
final List<Entity> results = Lists.newArrayList(graph.execute(getEntities, getUser()));
assertNotNull(results);
assertEquals(1, results.size());
for (final Entity result : results) {
assertNull(result.getProperty(TestPropertyNames.TRANSIENT_1));
}
}
use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.
the class AccumuloSingleIDRetrieverTest method testEntitySeedQueryEdgesOnly.
private void testEntitySeedQueryEdgesOnly(final AccumuloStore store) throws AccumuloException, StoreException {
setupGraph(store, numEntries);
final User user = new User();
// Create set to query for
final Set<ElementSeed> ids = new HashSet<>();
for (int i = 0; i < numEntries; i++) {
ids.add(new EntitySeed("" + i));
}
final View view = new View.Builder().edge(TestGroups.EDGE).entity(TestGroups.ENTITY).build();
AccumuloSingleIDRetriever retriever = null;
final GetElements<ElementSeed, ?> operation = new GetElements<>(view, ids);
operation.setIncludeEntities(false);
try {
retriever = new AccumuloSingleIDRetriever(store, operation, user);
} catch (IteratorSettingException e) {
e.printStackTrace();
}
//Should find both i-B and i-C edges.
assertEquals(numEntries * 2, Iterables.size(retriever));
}
use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.
the class AccumuloSingleIDRetrieverTest method testEntitySeedQueryIncomingEdgesOnly.
private void testEntitySeedQueryIncomingEdgesOnly(final AccumuloStore store) throws AccumuloException, StoreException {
setupGraph(store, numEntries);
final User user = new User();
// Create set to query for
final Set<ElementSeed> ids = new HashSet<>();
for (int i = 0; i < numEntries; i++) {
ids.add(new EntitySeed("" + i));
}
final View view = new View.Builder().edge(TestGroups.EDGE).entity(TestGroups.ENTITY).build();
AccumuloSingleIDRetriever retriever = null;
final GetElements<ElementSeed, ?> operation = new GetElements<>(view, ids);
operation.setIncludeEntities(false);
operation.setIncludeIncomingOutGoing(IncludeIncomingOutgoingType.INCOMING);
try {
retriever = new AccumuloSingleIDRetriever(store, operation, user);
} catch (IteratorSettingException e) {
e.printStackTrace();
}
for (final Element element : retriever) {
Edge edge = (Edge) element;
assertEquals("B", edge.getDestination());
}
//Incoming option should find all edges i-B as undirected are both incoming and outgoing.
assertEquals(numEntries, Iterables.size(retriever));
}
use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.
the class ArrayListStoreTest method shouldAddAndGetEntitiesBySeed.
@Test
public void shouldAddAndGetEntitiesBySeed() throws OperationException {
final Graph graph = createGraph();
addElementsToGraph(graph);
//set up the operation to fetch the entities
final OperationChain<CloseableIterable<SimpleEntityDataObject>> opChain = new OperationChain.Builder().first(new GetEntities.Builder().addSeed(new EntitySeed(1)).view(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.INT).execute(new IsLessThan(2)).build()).build()).build()).build()).then(new GenerateObjects.Builder<Entity, SimpleEntityDataObject>().generator(new SimpleEntityGenerator()).build()).build();
//now do the hop
final CloseableIterable<SimpleEntityDataObject> results = graph.execute(opChain, new User());
//check the results by converting our edges back into SimpleDataObjects
if (!results.iterator().hasNext()) {
fail("No results returned");
} else {
for (final SimpleEntityDataObject obj : results) {
LOGGER.info(obj.toString());
}
final List<SimpleEntityDataObject> resultList = Lists.newArrayList(results);
int index = 0;
SimpleEntityDataObject obj = resultList.get(index);
assertEquals(1, obj.getId());
assertEquals(1, obj.getVisibility());
assertEquals("Red", obj.getProperties());
}
results.close();
}
Aggregations