use of uk.gov.gchq.gaffer.data.element.Element in project Gaffer by gchq.
the class IsEdgeValidatorTest method shouldValidateWhenEdge.
@Test
public void shouldValidateWhenEdge() {
// Given
final Element element = new Edge(TestGroups.EDGE);
// When
final boolean valid = new IsEdgeValidator().validate(element);
// Then
assertTrue(valid);
}
use of uk.gov.gchq.gaffer.data.element.Element in project Gaffer by gchq.
the class IsEntityValidatorTest method shouldValidateWhenEntity.
@Test
public void shouldValidateWhenEntity() {
// Given
final Element element = new Entity(TestGroups.ENTITY);
// When
final boolean valid = new IsEntityValidator().validate(element);
// Then
assertTrue(valid);
}
use of uk.gov.gchq.gaffer.data.element.Element in project Gaffer by gchq.
the class MapGeneratorTest method shouldGenerateAnEmptyMap.
@Test
public void shouldGenerateAnEmptyMap() {
// Given
final Object vertex = "source vertex";
final String prop1 = "property 1";
final int count = 10;
final Element element = new Entity.Builder().group(TestGroups.ENTITY).vertex(vertex).property(TestPropertyNames.PROP_1, prop1).property(TestPropertyNames.COUNT, count).build();
final MapGenerator generator = new MapGenerator();
// When
final Map<String, Object> map = generator.getObject(element);
// Then
final Map<String, Object> expectedMap = new LinkedHashMap<>();
assertEquals(expectedMap, map);
}
use of uk.gov.gchq.gaffer.data.element.Element in project Gaffer by gchq.
the class AccumuloIDWithinSetRetrieverTest method returnElementsFromOperation.
private Set<Element> returnElementsFromOperation(final AccumuloStore store, final GetElements operation, final User user, final boolean loadIntoMemory) throws StoreException {
final AccumuloRetriever<?> retriever = new AccumuloIDWithinSetRetriever(store, operation, user, loadIntoMemory);
final Set<Element> results = new HashSet<>();
for (final Element elm : retriever) {
results.add(elm);
}
retriever.close();
return results;
}
use of uk.gov.gchq.gaffer.data.element.Element in project Gaffer by gchq.
the class AccumuloIDWithinSetRetrieverTest method shouldStillApplyOtherFilter.
private void shouldStillApplyOtherFilter(final boolean loadIntoMemory, final AccumuloStore store) throws StoreException {
// Query for all edges in set {A0, A23}
final Set<EntitySeed> seeds = new HashSet<>();
seeds.add(AccumuloTestData.SEED_A0);
seeds.add(AccumuloTestData.SEED_A23);
final GetElements<EntitySeed, ?> op = new GetElements<>(defaultView, seeds);
// Set graph to give us edges only
op.setIncludeEntities(false);
final Set<Element> results = returnElementsFromOperation(store, op, new User(), loadIntoMemory);
assertThat(results, IsCollectionContaining.hasItem(AccumuloTestData.EDGE_A0_A23));
// Set graph to return entities only
final GetElements<EntitySeed, ?> entitiesOnlyOp = new GetElements<>(defaultView, seeds);
entitiesOnlyOp.setIncludeEntities(true);
entitiesOnlyOp.setIncludeEdges(IncludeEdgeType.NONE);
// Query for all edges in set {A0, A23}
final Set<Element> entitiesOnlyResults = returnElementsFromOperation(store, entitiesOnlyOp, new User(), loadIntoMemory);
assertThat(entitiesOnlyResults, IsCollectionContaining.hasItems(AccumuloTestData.A0_ENTITY, AccumuloTestData.A23_ENTITY));
// Set graph to return both entities and edges again, and to only return summary type "X" (which will result
// in no data)
final View view = new View.Builder().edge("X").build();
final GetElements<EntitySeed, ?> entitiesAndEdgesOp = new GetElements<>(view, seeds);
entitiesAndEdgesOp.setIncludeEdges(IncludeEdgeType.ALL);
entitiesAndEdgesOp.setIncludeEntities(true);
final Set<Element> entitiesAndEdgesResults = returnElementsFromOperation(store, entitiesAndEdgesOp, new User(), loadIntoMemory);
assertEquals(0, entitiesAndEdgesResults.size());
}
Aggregations