use of uk.gov.gchq.gaffer.data.element.id.EntityId 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<EntityId> seeds = new HashSet<>();
seeds.add(AccumuloTestData.SEED_A0);
seeds.add(AccumuloTestData.SEED_A23);
final View edgesOnlyView = new View.Builder().edge(TestGroups.EDGE).build();
final GetElementsWithinSet op = new GetElementsWithinSet.Builder().view(edgesOnlyView).input(seeds).build();
// Set graph to give us edges only
final Set<Element> results = returnElementsFromOperation(store, op, new User(), loadIntoMemory);
assertThat(results).contains(AccumuloTestData.EDGE_A0_A23);
// Set graph to return entities only
final View entitiesOnlyView = new View.Builder().entity(TestGroups.ENTITY).build();
final GetElementsWithinSet entitiesOnlyOp = new GetElementsWithinSet.Builder().view(entitiesOnlyView).input(seeds).build();
// Query for all edges in set {A0, A23}
final Set<Element> entitiesOnlyResults = returnElementsFromOperation(store, entitiesOnlyOp, new User(), loadIntoMemory);
assertThat(entitiesOnlyResults).contains(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 GetElementsWithinSet entitiesAndEdgesOp = new GetElementsWithinSet.Builder().view(view).input(seeds).build();
final Set<Element> entitiesAndEdgesResults = returnElementsFromOperation(store, entitiesAndEdgesOp, new User(), loadIntoMemory);
assertThat(entitiesAndEdgesResults).isEmpty();
}
use of uk.gov.gchq.gaffer.data.element.id.EntityId in project Gaffer by gchq.
the class AccumuloIDWithinSetRetrieverTest method shouldGetCorrectEdges.
private void shouldGetCorrectEdges(final boolean loadIntoMemory, final AccumuloStore store) throws StoreException {
// Query for all edges in set {A0, A23}
final Set<EntityId> seeds = new HashSet<>();
seeds.add(AccumuloTestData.SEED_A0);
seeds.add(AccumuloTestData.SEED_A23);
final GetElementsWithinSet op = new GetElementsWithinSet.Builder().view(defaultView).input(seeds).build();
final Set<Element> results = returnElementsFromOperation(store, op, new User(), loadIntoMemory);
assertThat(results).contains(AccumuloTestData.EDGE_A0_A23, AccumuloTestData.A0_ENTITY, AccumuloTestData.A23_ENTITY);
// Query for all edges in set {A1} - there shouldn't be any, but we will get the entity for A1
final GetElementsWithinSet a1Operation = new GetElementsWithinSet.Builder().view(defaultView).input(AccumuloTestData.SEED_A1_SET).build();
final Set<Element> a1Results = returnElementsFromOperation(store, a1Operation, new User(), loadIntoMemory);
assertThat(a1Results).hasSize(1).contains(AccumuloTestData.A1_ENTITY);
// Query for all edges in set {A1, A2} - there shouldn't be any edges but will
// get the two entities
final Set<EntityId> a1A2Seeds = new HashSet<>();
a1A2Seeds.add(AccumuloTestData.SEED_A1);
a1A2Seeds.add(AccumuloTestData.SEED_A2);
final GetElementsWithinSet a1A2Operation = new GetElementsWithinSet.Builder().view(defaultView).input(a1A2Seeds).build();
final Set<Element> a1A2Results = returnElementsFromOperation(store, a1A2Operation, new User(), loadIntoMemory);
assertThat(a1A2Results).hasSize(2).contains(AccumuloTestData.A1_ENTITY, AccumuloTestData.A2_ENTITY);
}
use of uk.gov.gchq.gaffer.data.element.id.EntityId in project Gaffer by gchq.
the class GetElementsHandlerTest method shouldReturnHBaseRetrieverWithIncludeMatchedVertexWhenSeedMatchingIsNull.
@Test
public void shouldReturnHBaseRetrieverWithIncludeMatchedVertexWhenSeedMatchingIsNull() throws OperationException, StoreException {
// Given
final Iterable<EntityId> ids = mock(Iterable.class);
final Context context = mock(Context.class);
final User user = mock(User.class);
final HBaseStore store = mock(HBaseStore.class);
final HBaseRetriever<GetElements> hbaseRetriever = mock(HBaseRetriever.class);
final GetElementsHandler handler = new GetElementsHandler();
final GetElements getElements = new GetElements.Builder().inputIds(ids).seedMatching(null).build();
given(context.getUser()).willReturn(user);
given(store.createRetriever(getElements, user, ids, true)).willReturn(hbaseRetriever);
// When
final HBaseRetriever<GetElements> result = (HBaseRetriever<GetElements>) handler.doOperation(getElements, context, store);
// Then
assertSame(hbaseRetriever, result);
}
use of uk.gov.gchq.gaffer.data.element.id.EntityId in project Gaffer by gchq.
the class GetElementsHandlerTest method shouldReturnHBaseRetrieverWithoutIncludeMatchdxVertex.
@Test
public void shouldReturnHBaseRetrieverWithoutIncludeMatchdxVertex() throws OperationException, StoreException {
// Given
final Iterable<EntityId> ids = mock(Iterable.class);
final Context context = mock(Context.class);
final User user = mock(User.class);
final HBaseStore store = mock(HBaseStore.class);
final HBaseRetriever<GetElements> hbaseRetriever = mock(HBaseRetriever.class);
final GetElementsHandler handler = new GetElementsHandler();
final GetElements getElements = new GetElements.Builder().inputIds(ids).seedMatching(SeedMatching.SeedMatchingType.EQUAL).build();
given(context.getUser()).willReturn(user);
given(store.createRetriever(getElements, user, ids, false)).willReturn(hbaseRetriever);
// When
final HBaseRetriever<GetElements> result = (HBaseRetriever<GetElements>) handler.doOperation(getElements, context, store);
// Then
assertSame(hbaseRetriever, result);
}
use of uk.gov.gchq.gaffer.data.element.id.EntityId in project Gaffer by gchq.
the class GetElementsHandlerTest method shouldReturnHBaseRetrieverWithIncludeMatchedVertex.
@Test
public void shouldReturnHBaseRetrieverWithIncludeMatchedVertex() throws OperationException, StoreException {
// Given
final Iterable<EntityId> ids = mock(Iterable.class);
final Context context = mock(Context.class);
final User user = mock(User.class);
final HBaseStore store = mock(HBaseStore.class);
final HBaseRetriever<GetElements> hbaseRetriever = mock(HBaseRetriever.class);
final GetElementsHandler handler = new GetElementsHandler();
final GetElements getElements = new GetElements.Builder().inputIds(ids).seedMatching(SeedMatching.SeedMatchingType.RELATED).build();
given(context.getUser()).willReturn(user);
given(store.createRetriever(getElements, user, ids, true)).willReturn(hbaseRetriever);
// When
final HBaseRetriever<GetElements> result = (HBaseRetriever<GetElements>) handler.doOperation(getElements, context, store);
// Then
assertSame(hbaseRetriever, result);
}
Aggregations