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");
}
}
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);
}
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;
}
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");
}
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");
}
Aggregations