use of uk.gov.gchq.gaffer.operation.graph.OperationView in project Gaffer by gchq.
the class UpdateViewHookTest method shouldApplyWhiteLists.
@Test
public void shouldApplyWhiteLists() throws Exception {
opChain = new OperationChain.Builder().first(new GetAllElements.Builder().view(new View.Builder().entity("wrong1").entity("white1").entity("white2").build()).build()).build();
updateViewHook.setWhiteListElementGroups(Sets.newHashSet("white2", "white1"));
updateViewHook.preExecute(opChain, new Context(new User.Builder().opAuth("opA").build()));
Object op = opChain.getOperations().get(0);
assertThat(op).isInstanceOf(OperationView.class);
assertThat(((OperationView) op).getView().getEntities().keySet()).contains("white1", "white2").hasSize(2);
}
use of uk.gov.gchq.gaffer.operation.graph.OperationView in project Gaffer by gchq.
the class UpdateViewHookTest method shouldNotMergeWithWrongUser.
@Test
public void shouldNotMergeWithWrongUser() throws Exception {
updateViewHook.setViewToMerge(viewToMerge);
updateViewHook.setWithOpAuth(Sets.newHashSet("opA"));
opChain = new OperationChain<>(new GetAllElements());
updateViewHook.preExecute(opChain, new Context(new User()));
Object op = opChain.getOperations().get(0);
assertThat(op).isInstanceOf(OperationView.class);
assertThat(((OperationView) op).getView()).isNull();
}
use of uk.gov.gchq.gaffer.operation.graph.OperationView in project Gaffer by gchq.
the class UpdateViewHookTest method shouldDoNothingWithNullMerge.
@Test
public void shouldDoNothingWithNullMerge() throws Exception {
GetAllElements operationView = new GetAllElements();
operationView.setView(new View());
View view = updateViewHook.mergeView(operationView, null).build();
assertThat(view.getGroups()).isEmpty();
}
use of uk.gov.gchq.gaffer.operation.graph.OperationView in project Gaffer by gchq.
the class UpdateViewHookTest method shouldNotAddExtraGroupsToUsersViewInGetAdjacentIds.
@Test
public void shouldNotAddExtraGroupsToUsersViewInGetAdjacentIds() throws Exception {
opChain = new OperationChain.Builder().first(new GetAdjacentIds.Builder().view(new View.Builder().edge("edge1").build()).build()).build();
updateViewHook.setViewToMerge(new View.Builder().entity("entity2").edge("edge2").build());
updateViewHook.preExecute(opChain, new Context(new User.Builder().opAuth("opA").build()));
Object op = opChain.getOperations().get(0);
assertThat(op).isInstanceOf(OperationView.class);
assertThat(((OperationView) op).getView().getEntityGroups()).isEmpty();
assertThat(((OperationView) op).getView().getEdgeGroups()).containsExactly("edge1");
}
use of uk.gov.gchq.gaffer.operation.graph.OperationView in project Gaffer by gchq.
the class NamedViewResolverTest method shouldBuildFullViewWhenAViewToBeMergedIsSupplied.
@Test
public void shouldBuildFullViewWhenAViewToBeMergedIsSupplied() throws CacheOperationFailedException {
// Given
final View viewToMerge = new View.Builder().edge(TestGroups.EDGE).build();
final View finalExpectedView = new View.Builder().edge(TestGroups.EDGE).merge(FULL_VIEW).build();
given(CACHE.getNamedView(NAMED_VIEW_NAME, CONTEXT.getUser())).willReturn(FULL_NAMED_VIEW_DETAIL);
given(CACHE.getNamedView(NAMED_VIEW_NAME + 1, CONTEXT.getUser())).willReturn(null);
final OperationChain<?> opChain = new OperationChain.Builder().first(new GetElements.Builder().view(new NamedView.Builder().name(NAMED_VIEW_NAME).merge(viewToMerge).build()).build()).build();
// When
RESOLVER.preExecute(opChain, CONTEXT);
// Then
JsonAssert.assertEquals(finalExpectedView.toCompactJson(), ((OperationView) opChain.getOperations().get(0)).getView().toCompactJson());
}
Aggregations