Search in sources :

Example 11 with OperationView

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();
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) Builder(uk.gov.gchq.gaffer.user.User.Builder) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) OperationView(uk.gov.gchq.gaffer.operation.graph.OperationView) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.jupiter.api.Test)

Example 12 with OperationView

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);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) Builder(uk.gov.gchq.gaffer.user.User.Builder) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) OperationView(uk.gov.gchq.gaffer.operation.graph.OperationView) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.jupiter.api.Test)

Example 13 with OperationView

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");
}
Also used : GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) OperationView(uk.gov.gchq.gaffer.operation.graph.OperationView) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.jupiter.api.Test)

Aggregations

OperationView (uk.gov.gchq.gaffer.operation.graph.OperationView)13 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)12 Test (org.junit.jupiter.api.Test)9 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)6 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)6 Context (uk.gov.gchq.gaffer.store.Context)6 NamedView (uk.gov.gchq.gaffer.data.elementdefinition.view.NamedView)4 Operation (uk.gov.gchq.gaffer.operation.Operation)4 Builder (uk.gov.gchq.gaffer.user.User.Builder)4 ArrayList (java.util.ArrayList)2 Operations (uk.gov.gchq.gaffer.operation.Operations)2 User (uk.gov.gchq.gaffer.user.User)2 Lists (com.google.common.collect.Lists)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1