use of uk.gov.gchq.gaffer.operation.graph.OperationView in project Gaffer by gchq.
the class UpdateViewHookTest method shouldNotAddExtraGroupsToEmptyUsersView.
@Test
public void shouldNotAddExtraGroupsToEmptyUsersView() throws Exception {
opChain = new OperationChain.Builder().first(new GetAllElements.Builder().view(new View()).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()).isEmpty();
}
use of uk.gov.gchq.gaffer.operation.graph.OperationView in project Gaffer by gchq.
the class UpdateViewHookTest method shouldApplyWhiteAndBlackLists.
@Test
public void shouldApplyWhiteAndBlackLists() 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.setBlackListElementGroups(Sets.newHashSet("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()).containsExactly("white2").hasSize(1);
}
use of uk.gov.gchq.gaffer.operation.graph.OperationView in project Gaffer by gchq.
the class UpdateViewHookTest method shouldMerge.
@Test
public void shouldMerge() throws Exception {
GetAllElements operationView = new GetAllElements();
operationView.setView(new View());
View view = updateViewHook.mergeView(operationView, viewToMerge).build();
Set<String> groups = view.getGroups();
assertThat(groups).isNotEmpty().contains("testGroup");
}
Aggregations