Search in sources :

Example 91 with Graph

use of uk.gov.gchq.gaffer.graph.Graph in project Gaffer by gchq.

the class FederatedStoreUtilTest method shouldUpdateOperationChainAndReturnNullIfNestedOperationViewHasNoGroups.

@Test
public void shouldUpdateOperationChainAndReturnNullIfNestedOperationViewHasNoGroups() {
    // Given
    final Graph graph = createGraph();
    final OperationChain<?> operation = new OperationChain.Builder().first(new GetElements.Builder().view(new View.Builder().edge(TestGroups.EDGE_2, new ViewElementDefinition()).entity(TestGroups.ENTITY_2, new ViewElementDefinition()).build()).build()).build();
    // When
    final OperationChain<?> updatedOp = FederatedStoreUtil.updateOperationForGraph(operation, graph);
    // Then
    assertNull(updatedOp);
}
Also used : Graph(uk.gov.gchq.gaffer.graph.Graph) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.jupiter.api.Test)

Example 92 with Graph

use of uk.gov.gchq.gaffer.graph.Graph in project Gaffer by gchq.

the class FederatedStoreUtilTest method shouldUpdateAddElementsFlagsWhenNullInputAndValidateFalse.

@Test
public void shouldUpdateAddElementsFlagsWhenNullInputAndValidateFalse() {
    // Given
    final Graph graph = createGraph();
    final AddElements operation = new AddElements.Builder().validate(false).skipInvalidElements(true).build();
    // When
    final AddElements updatedOp = FederatedStoreUtil.updateOperationForGraph(operation, graph);
    // Then
    assertNotSame(operation, updatedOp);
    assertNull(updatedOp.getInput());
    assertTrue(updatedOp.isValidate());
    assertTrue(updatedOp.isSkipInvalidElements());
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Graph(uk.gov.gchq.gaffer.graph.Graph) Test(org.junit.jupiter.api.Test)

Example 93 with Graph

use of uk.gov.gchq.gaffer.graph.Graph in project Gaffer by gchq.

the class FederatedStoreUtilTest method shouldUpdateNestedOperations.

@Test
public void shouldUpdateNestedOperations() {
    // Given
    final Graph graph = createGraph();
    final HashMap<String, String> options = new HashMap<>();
    options.put("key", "value");
    final HashMap<String, String> options2 = new HashMap<>();
    options2.put("key", "value");
    final GetElements operation = new GetElements.Builder().view(new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition()).edge(TestGroups.EDGE_2, new ViewElementDefinition()).entity(TestGroups.ENTITY, new ViewElementDefinition()).entity(TestGroups.ENTITY_2, new ViewElementDefinition()).build()).options(options2).build();
    final OperationChain opChain = new OperationChain.Builder().first(operation).options(options).build();
    // When
    final OperationChain<?> updatedOpChain = FederatedStoreUtil.updateOperationForGraph(opChain, graph);
    // Then
    assertNotSame(opChain, updatedOpChain);
    assertEquals(options, updatedOpChain.getOptions());
    assertEquals(1, updatedOpChain.getOperations().size());
    final GetElements updatedOperation = (GetElements) updatedOpChain.getOperations().get(0);
    assertNotSame(operation, updatedOperation);
    assertEquals(options2, updatedOperation.getOptions());
    assertNotSame(operation.getView(), updatedOperation.getView());
    assertEquals(Sets.newHashSet(TestGroups.ENTITY), updatedOperation.getView().getEntityGroups());
    assertEquals(Sets.newHashSet(TestGroups.EDGE), updatedOperation.getView().getEdgeGroups());
    assertSame(operation.getView().getEntity(TestGroups.ENTITY), updatedOperation.getView().getEntity(TestGroups.ENTITY));
    assertSame(operation.getView().getEdge(TestGroups.EDGE), updatedOperation.getView().getEdge(TestGroups.EDGE));
}
Also used : Graph(uk.gov.gchq.gaffer.graph.Graph) HashMap(java.util.HashMap) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) Test(org.junit.jupiter.api.Test)

Example 94 with Graph

use of uk.gov.gchq.gaffer.graph.Graph in project Gaffer by gchq.

the class FederatedStoreUtilTest method shouldUpdateOperationView.

@Test
public void shouldUpdateOperationView() {
    // Given
    final Graph graph = createGraph();
    final GetElements operation = new GetElements.Builder().view(new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition()).edge(TestGroups.EDGE_2, new ViewElementDefinition()).entity(TestGroups.ENTITY, new ViewElementDefinition()).entity(TestGroups.ENTITY_2, new ViewElementDefinition()).build()).build();
    // When
    final GetElements updatedOp = FederatedStoreUtil.updateOperationForGraph(operation, graph);
    // Then
    assertNotSame(operation, updatedOp);
    assertNotSame(operation.getView(), updatedOp.getView());
    assertEquals(Sets.newHashSet(TestGroups.ENTITY), updatedOp.getView().getEntityGroups());
    assertEquals(Sets.newHashSet(TestGroups.EDGE), updatedOp.getView().getEdgeGroups());
    assertSame(operation.getView().getEntity(TestGroups.ENTITY), updatedOp.getView().getEntity(TestGroups.ENTITY));
    assertSame(operation.getView().getEdge(TestGroups.EDGE), updatedOp.getView().getEdge(TestGroups.EDGE));
}
Also used : Graph(uk.gov.gchq.gaffer.graph.Graph) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.jupiter.api.Test)

Example 95 with Graph

use of uk.gov.gchq.gaffer.graph.Graph in project Gaffer by gchq.

the class FederatedStoreUtilTest method shouldNotUpdateAddElementsFlagsWhenNotRequired.

@Test
public void shouldNotUpdateAddElementsFlagsWhenNotRequired() {
    // Given
    final Graph graph = createGraph();
    final AddElements operation = new AddElements.Builder().validate(true).skipInvalidElements(true).build();
    // When
    final AddElements updatedOp = FederatedStoreUtil.updateOperationForGraph(operation, graph);
    // Then
    assertEquals(operation, updatedOp);
    assertNull(updatedOp.getInput());
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Graph(uk.gov.gchq.gaffer.graph.Graph) Test(org.junit.jupiter.api.Test)

Aggregations

Graph (uk.gov.gchq.gaffer.graph.Graph)311 Test (org.junit.jupiter.api.Test)172 User (uk.gov.gchq.gaffer.user.User)155 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)146 Element (uk.gov.gchq.gaffer.data.element.Element)116 Schema (uk.gov.gchq.gaffer.store.schema.Schema)84 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)83 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)76 Edge (uk.gov.gchq.gaffer.data.element.Edge)75 HashSet (java.util.HashSet)71 Entity (uk.gov.gchq.gaffer.data.element.Entity)68 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)60 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)58 ArrayList (java.util.ArrayList)56 OperationException (uk.gov.gchq.gaffer.operation.OperationException)55 Test (org.junit.Test)49 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)49 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)44 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)44 Set (java.util.Set)38