use of uk.gov.gchq.gaffer.data.element.id.ElementId in project Gaffer by gchq.
the class AbstractExamplesFactoryTest method shouldUseSchemaToCreateGetElementsInput.
@Test
public void shouldUseSchemaToCreateGetElementsInput() throws InstantiationException, IllegalAccessException {
// Given
TestExamplesFactory examplesFactory = new TestExamplesFactory(SCHEMA);
// When
GetElements operation = (GetElements) examplesFactory.generateExample(GetElements.class);
// Then
int size = 0;
for (ElementId e : operation.getInput()) {
size++;
if (e instanceof EntityId) {
assertEquals(String.class, ((EntityId) e).getVertex().getClass());
} else {
assertEquals(String.class, ((EdgeId) e).getDestination().getClass());
assertEquals(String.class, ((EdgeId) e).getSource().getClass());
}
}
assertEquals(2, size);
}
use of uk.gov.gchq.gaffer.data.element.id.ElementId in project Gaffer by gchq.
the class GetElementsInRangesTest method shouldShallowCloneOperation.
@Test
@Override
public void shouldShallowCloneOperation() {
// Given
final Pair<ElementId, ElementId> seed = new Pair<>(AccumuloTestData.SEED_A, AccumuloTestData.SEED_B);
final View view = new View.Builder().edge("testEdgeGroup").build();
final GetElementsInRanges getElementsInRanges = new GetElementsInRanges.Builder().inOutType(SeededGraphFilters.IncludeIncomingOutgoingType.EITHER).input(seed).directedType(DirectedType.UNDIRECTED).option(AccumuloTestData.TEST_OPTION_PROPERTY_KEY, "true").view(view).build();
// When
final GetElementsInRanges clone = getElementsInRanges.shallowClone();
// Then
assertNotSame(getElementsInRanges, clone);
assertEquals("true", clone.getOption(AccumuloTestData.TEST_OPTION_PROPERTY_KEY));
assertEquals(SeededGraphFilters.IncludeIncomingOutgoingType.EITHER, clone.getIncludeIncomingOutGoing());
assertEquals(DirectedType.UNDIRECTED, clone.getDirectedType());
assertThat(clone.getInput().iterator().next()).isEqualTo(seed);
assertEquals(view, clone.getView());
}
use of uk.gov.gchq.gaffer.data.element.id.ElementId in project Gaffer by gchq.
the class SummariseGroupOverRangesTest method shouldShallowCloneOperation.
@Test
@Override
public void shouldShallowCloneOperation() {
// Given
final Pair<ElementId, ElementId> seed = new Pair<>(AccumuloTestData.SEED_A, AccumuloTestData.SEED_B);
final View view = new View.Builder().edge("testEdgeGroup").build();
final SummariseGroupOverRanges summariseGroupOverRanges = new SummariseGroupOverRanges.Builder().inOutType(SeededGraphFilters.IncludeIncomingOutgoingType.EITHER).input(seed).directedType(DirectedType.UNDIRECTED).option(AccumuloTestData.TEST_OPTION_PROPERTY_KEY, "true").view(view).build();
// When
final SummariseGroupOverRanges clone = summariseGroupOverRanges.shallowClone();
// Then
assertNotSame(summariseGroupOverRanges, clone);
assertEquals("true", clone.getOption(AccumuloTestData.TEST_OPTION_PROPERTY_KEY));
assertEquals(SeededGraphFilters.IncludeIncomingOutgoingType.EITHER, clone.getIncludeIncomingOutGoing());
assertEquals(DirectedType.UNDIRECTED, clone.getDirectedType());
assertThat(clone.getInput().iterator().next()).isEqualTo(seed);
assertEquals(view, clone.getView());
}
use of uk.gov.gchq.gaffer.data.element.id.ElementId in project Gaffer by gchq.
the class AccumuloSingleIDRetrieverTest method testUndirectedEdgeIdQueries.
private void testUndirectedEdgeIdQueries(final AccumuloStore store) throws StoreException {
setupGraph(store, NUM_ENTRIES);
final User user = new User();
// Create set to query for
final Set<ElementId> ids = new HashSet<>();
for (int i = 0; i < NUM_ENTRIES; i++) {
ids.add(new EdgeSeed("" + i, "B", false));
ids.add(new EdgeSeed("" + i, "C", true));
}
final View view = new View.Builder().edge(TestGroups.EDGE).build();
AccumuloSingleIDRetriever<?> retriever = null;
final GetElements operation = new GetElements.Builder().view(view).input(ids).build();
operation.setDirectedType(DirectedType.UNDIRECTED);
try {
retriever = new AccumuloSingleIDRetriever<>(store, operation, user);
} catch (final IteratorSettingException e) {
throw new RuntimeException(e);
}
for (final Element element : retriever) {
Edge edge = (Edge) element;
assertEquals("B", edge.getDestination());
}
// We should have only 1000 returned the i-B edges that are undirected
assertEquals(NUM_ENTRIES, Iterables.size(retriever));
}
use of uk.gov.gchq.gaffer.data.element.id.ElementId in project Gaffer by gchq.
the class AccumuloSingleIDRetrieverTest method testEntityIdQueryEdgesOnly.
private void testEntityIdQueryEdgesOnly(final AccumuloStore store) throws StoreException {
setupGraph(store, NUM_ENTRIES);
final User user = new User();
// Create set to query for
final Set<ElementId> ids = new HashSet<>();
for (int i = 0; i < NUM_ENTRIES; i++) {
ids.add(new EntitySeed("" + i));
}
final View view = new View.Builder().edge(TestGroups.EDGE).build();
AccumuloSingleIDRetriever retriever = null;
final GetElements operation = new GetElements.Builder().view(view).input(ids).build();
try {
retriever = new AccumuloSingleIDRetriever(store, operation, user);
} catch (final IteratorSettingException e) {
throw new RuntimeException(e);
}
// Should find both i-B and i-C edges.
assertEquals(NUM_ENTRIES * 2, Iterables.size(retriever));
}
Aggregations