Search in sources :

Example 16 with Operation

use of uk.gov.gchq.gaffer.operation.Operation in project Gaffer by gchq.

the class DisableOperationsTest method shouldDisableOperationsUsingOperationDeclarations.

@Test
public void shouldDisableOperationsUsingOperationDeclarations() {
    Class<? extends Operation>[] disabledOperations = getDisabledOperations();
    // Given
    System.setProperty(SystemProperty.STORE_PROPERTIES_PATH, storePropsPath.getAbsolutePath());
    System.setProperty(SystemProperty.SCHEMA_PATHS, schemaPath.getAbsolutePath());
    System.setProperty(SystemProperty.GRAPH_CONFIG_PATH, graphConfigPath.getAbsolutePath());
    final DefaultGraphFactory factory = new DefaultGraphFactory();
    // When
    final Graph graph = factory.createGraph();
    // Then
    for (final Class<? extends Operation> disabledOperation : disabledOperations) {
        assertFalse(graph.isSupported(disabledOperation), disabledOperation.getSimpleName() + " should not be supported");
    }
}
Also used : Graph(uk.gov.gchq.gaffer.graph.Graph) DefaultGraphFactory(uk.gov.gchq.gaffer.rest.factory.DefaultGraphFactory) Operation(uk.gov.gchq.gaffer.operation.Operation) Test(org.junit.jupiter.api.Test)

Example 17 with Operation

use of uk.gov.gchq.gaffer.operation.Operation in project Gaffer by gchq.

the class GraphConfigurationServiceTest method setup.

@BeforeEach
public void setup() {
    final Set<StoreTrait> traits = new HashSet<>(Arrays.asList(INGEST_AGGREGATION, PRE_AGGREGATION_FILTERING, POST_TRANSFORMATION_FILTERING, POST_AGGREGATION_FILTERING, TRANSFORMATION, STORE_VALIDATION));
    lenient().when(store.getSchema()).thenReturn(new Schema());
    lenient().when(store.getProperties()).thenReturn(new StoreProperties());
    final Graph graph = new Graph.Builder().config(new GraphConfig.Builder().graphId(GRAPH_ID).build()).store(store).build();
    final Set<Class<? extends Operation>> operations = new HashSet<>();
    operations.add(AddElements.class);
    lenient().when(graphFactory.getGraph()).thenReturn(graph);
    lenient().when(graph.getSupportedOperations()).thenReturn(operations);
    lenient().when(graph.isSupported(AddElements.class)).thenReturn(true);
    lenient().when(userFactory.createContext()).thenReturn(new Context());
    lenient().when(graph.getStoreTraits()).thenReturn(traits);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Operation(uk.gov.gchq.gaffer.operation.Operation) GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) Graph(uk.gov.gchq.gaffer.graph.Graph) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) HashSet(java.util.HashSet) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 18 with Operation

use of uk.gov.gchq.gaffer.operation.Operation in project Gaffer by gchq.

the class FederatedOperationChainValidator method shallowCloneWithDeepOptions.

/**
 * Return a clone of the given operations with a deep clone of options.
 * <p>
 * Because op.shallowClone() is used it can't be guaranteed that original options won't be modified.
 * So a deep clone of the options is made for the shallow clone of the operation.
 *
 * @param op the operation to clone
 * @return a clone of the operation with a deep clone of options.
 */
private Operation shallowCloneWithDeepOptions(final Operation op) {
    final Operation cloneForValidation = op.shallowClone();
    final Map<String, String> options = op.getOptions();
    final Map<String, String> optionsDeepClone = isNull(options) ? null : new HashMap<>(options);
    cloneForValidation.setOptions(optionsDeepClone);
    return cloneForValidation;
}
Also used : Operation(uk.gov.gchq.gaffer.operation.Operation)

Example 19 with Operation

use of uk.gov.gchq.gaffer.operation.Operation in project Gaffer by gchq.

the class IfTest method shouldThrowErrorForTryingToUpdateOperationsWithTooFewOps.

@Test
public void shouldThrowErrorForTryingToUpdateOperationsWithTooFewOps() {
    // Given
    final GetElements getElements = new GetElements.Builder().input(new EntitySeed("1")).build();
    final If<Object, Object> ifOp = new If.Builder<>().condition(false).build();
    final Collection<Operation> opList = Lists.newArrayList(getElements);
    // When / Then
    assertThatIllegalArgumentException().isThrownBy(() -> ifOp.updateOperations(opList)).withMessage("Unable to update operations - exactly 3 operations are required. Received 1 operations");
}
Also used : EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) Operation(uk.gov.gchq.gaffer.operation.Operation) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 20 with Operation

use of uk.gov.gchq.gaffer.operation.Operation in project Gaffer by gchq.

the class IfTest method shouldThrowErrorForTryingToUpdateOperationsWithTooManyOps.

@Test
public void shouldThrowErrorForTryingToUpdateOperationsWithTooManyOps() {
    // Given
    final GetElements getElements = new GetElements.Builder().input(new EntitySeed("2")).build();
    final GetAllElements getAllElements = new GetAllElements();
    final Limit limit = new Limit(5);
    final If<Object, Object> ifOp = new If.Builder<>().build();
    final Collection<Operation> opList = Lists.newArrayList(getElements, getAllElements, limit, limit);
    // When / Then
    assertThatIllegalArgumentException().isThrownBy(() -> ifOp.updateOperations(opList)).withMessage("Unable to update operations - exactly 3 operations are required. Received 4 operations");
}
Also used : EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) Operation(uk.gov.gchq.gaffer.operation.Operation) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Aggregations

Operation (uk.gov.gchq.gaffer.operation.Operation)136 Test (org.junit.jupiter.api.Test)88 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)49 NamedOperation (uk.gov.gchq.gaffer.named.operation.NamedOperation)44 Schema (uk.gov.gchq.gaffer.store.schema.Schema)41 Context (uk.gov.gchq.gaffer.store.Context)35 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)34 Store (uk.gov.gchq.gaffer.store.Store)28 StoreProperties (uk.gov.gchq.gaffer.store.StoreProperties)26 LinkedHashMap (java.util.LinkedHashMap)21 GetAdjacentIds (uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds)21 User (uk.gov.gchq.gaffer.user.User)21 ArrayList (java.util.ArrayList)18 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)18 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)17 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)16 HashSet (java.util.HashSet)15 HashMap (java.util.HashMap)13 TestStore (uk.gov.gchq.gaffer.integration.store.TestStore)13 OperationException (uk.gov.gchq.gaffer.operation.OperationException)13