use of uk.gov.gchq.gaffer.store.operation.handler.named.AddNamedOperationHandler in project Gaffer by gchq.
the class NamedOperationCacheIT method shouldAllowUpdatingOfNamedOperationsWithAllowedUsers.
private void shouldAllowUpdatingOfNamedOperationsWithAllowedUsers() throws OperationException {
// given
final Store store = mock(Store.class);
given(store.getProperties()).willReturn(properties);
new AddNamedOperationHandler().doOperation(add, context, store);
AddNamedOperation update = new AddNamedOperation.Builder().name(add.getOperationName()).description("a different operation").operationChain(add.getOperationChainAsString()).overwrite().score(0).build();
GetAllNamedOperations get = new GetAllNamedOperations();
// when
new AddNamedOperationHandler().doOperation(add, context, store);
List<NamedOperationDetail> results = Lists.newArrayList(getAllNamedOperationsHandler.doOperation(get, context, store));
NamedOperationDetail expectedNamedOp = new NamedOperationDetail.Builder().operationName(update.getOperationName()).operationChain(update.getOperationChainAsString()).description(update.getDescription()).creatorId(user.getUserId()).score(0).parameters(null).build();
ArrayList<NamedOperationDetail> expected = Lists.newArrayList(expectedNamedOp);
// then
assertThat(results).hasSameSizeAs(expected).isEqualTo(expected);
}
use of uk.gov.gchq.gaffer.store.operation.handler.named.AddNamedOperationHandler in project Gaffer by gchq.
the class NamedOperationCacheIT method shouldAllowUpdatingOfNamedOperations.
private void shouldAllowUpdatingOfNamedOperations() throws OperationException {
// given
final Store store = mock(Store.class);
final StoreProperties storeProps = mock(StoreProperties.class);
given(store.getProperties()).willReturn(storeProps);
new AddNamedOperationHandler().doOperation(add, context, store);
AddNamedOperation update = new AddNamedOperation.Builder().name(add.getOperationName()).description("a different operation").operationChain(add.getOperationChainAsString()).overwrite().score(0).build();
GetAllNamedOperations get = new GetAllNamedOperations();
// when
new AddNamedOperationHandler().doOperation(add, context, store);
List<NamedOperationDetail> results = Lists.newArrayList(getAllNamedOperationsHandler.doOperation(get, context, store));
NamedOperationDetail expectedNamedOp = new NamedOperationDetail.Builder().operationName(update.getOperationName()).operationChain(update.getOperationChainAsString()).description(update.getDescription()).creatorId(user.getUserId()).score(0).parameters(null).build();
ArrayList<NamedOperationDetail> expected = Lists.newArrayList(expectedNamedOp);
// then
assertThat(results).hasSameSizeAs(expected).isEqualTo(expected);
}
use of uk.gov.gchq.gaffer.store.operation.handler.named.AddNamedOperationHandler in project Gaffer by gchq.
the class Store method addCoreOpHandlers.
private void addCoreOpHandlers() {
// Add elements
addOperationHandler(AddElements.class, getAddElementsHandler());
// Get Elements
addOperationHandler(GetElements.class, (OperationHandler) getGetElementsHandler());
// Get Adjacent
addOperationHandler(GetAdjacentIds.class, (OperationHandler) getAdjacentIdsHandler());
// Get All Elements
addOperationHandler(GetAllElements.class, (OperationHandler) getGetAllElementsHandler());
// Export
addOperationHandler(ExportToSet.class, new ExportToSetHandler());
addOperationHandler(GetSetExport.class, new GetSetExportHandler());
addOperationHandler(GetExports.class, new GetExportsHandler());
// Jobs
if (null != getJobTracker()) {
addOperationHandler(GetJobDetails.class, new GetJobDetailsHandler());
addOperationHandler(GetAllJobDetails.class, new GetAllJobDetailsHandler());
addOperationHandler(GetJobResults.class, new GetJobResultsHandler());
}
// Output
addOperationHandler(ToArray.class, new ToArrayHandler<>());
addOperationHandler(ToEntitySeeds.class, new ToEntitySeedsHandler());
addOperationHandler(ToList.class, new ToListHandler<>());
addOperationHandler(ToMap.class, new ToMapHandler());
addOperationHandler(ToCsv.class, new ToCsvHandler());
addOperationHandler(ToSet.class, new ToSetHandler<>());
addOperationHandler(ToStream.class, new ToStreamHandler<>());
addOperationHandler(ToVertices.class, new ToVerticesHandler());
if (null != CacheServiceLoader.getService()) {
// Named operation
addOperationHandler(NamedOperation.class, new NamedOperationHandler());
addOperationHandler(AddNamedOperation.class, new AddNamedOperationHandler());
addOperationHandler(GetAllNamedOperations.class, new GetAllNamedOperationsHandler());
addOperationHandler(DeleteNamedOperation.class, new DeleteNamedOperationHandler());
// Named view
addOperationHandler(AddNamedView.class, new AddNamedViewHandler());
addOperationHandler(GetAllNamedViews.class, new GetAllNamedViewsHandler());
addOperationHandler(DeleteNamedView.class, new DeleteNamedViewHandler());
}
// ElementComparison
addOperationHandler(Max.class, new MaxHandler());
addOperationHandler(Min.class, new MinHandler());
addOperationHandler(Sort.class, new SortHandler());
// OperationChain
addOperationHandler(OperationChain.class, getOperationChainHandler());
addOperationHandler(OperationChainDAO.class, getOperationChainHandler());
// OperationChain validation
addOperationHandler(ValidateOperationChain.class, new ValidateOperationChainHandler());
// Walk tracking
addOperationHandler(GetWalks.class, new GetWalksHandler());
// Other
addOperationHandler(GenerateElements.class, new GenerateElementsHandler<>());
addOperationHandler(GenerateObjects.class, new GenerateObjectsHandler<>());
addOperationHandler(Validate.class, new ValidateHandler());
addOperationHandler(Count.class, new CountHandler());
addOperationHandler(CountGroups.class, new CountGroupsHandler());
addOperationHandler(Limit.class, new LimitHandler());
addOperationHandler(DiscardOutput.class, new DiscardOutputHandler());
addOperationHandler(GetSchema.class, new GetSchemaHandler());
addOperationHandler(uk.gov.gchq.gaffer.operation.impl.Map.class, new MapHandler());
addOperationHandler(If.class, new IfHandler());
addOperationHandler(While.class, new WhileHandler());
addOperationHandler(ForEach.class, new ForEachHandler());
addOperationHandler(ToSingletonList.class, new ToSingletonListHandler());
addOperationHandler(Reduce.class, new ReduceHandler());
addOperationHandler(Join.class, new JoinHandler());
addOperationHandler(CancelScheduledJob.class, new CancelScheduledJobHandler());
// Context variables
addOperationHandler(SetVariable.class, new SetVariableHandler());
addOperationHandler(GetVariable.class, new GetVariableHandler());
addOperationHandler(GetVariables.class, new GetVariablesHandler());
// Function
addOperationHandler(Filter.class, new FilterHandler());
addOperationHandler(Transform.class, new TransformHandler());
addOperationHandler(Aggregate.class, new AggregateHandler());
// GraphLibrary Adds
if (null != getGraphLibrary() && !(getGraphLibrary() instanceof NoGraphLibrary)) {
addOperationHandler(AddSchemaToLibrary.class, new AddSchemaToLibraryHandler());
addOperationHandler(AddStorePropertiesToLibrary.class, new AddStorePropertiesToLibraryHandler());
}
addOperationHandler(GetTraits.class, new GetTraitsHandler());
}
use of uk.gov.gchq.gaffer.store.operation.handler.named.AddNamedOperationHandler in project Gaffer by gchq.
the class NamedOperationCacheIT method shouldBeAbleToDeleteNamedOperationFromCache.
private void shouldBeAbleToDeleteNamedOperationFromCache() throws OperationException {
// given
final Store store = mock(Store.class);
given(store.getProperties()).willReturn(properties);
new AddNamedOperationHandler().doOperation(add, context, store);
DeleteNamedOperation del = new DeleteNamedOperation.Builder().name("op").build();
GetAllNamedOperations get = new GetAllNamedOperations();
// when
deleteNamedOperationHandler.doOperation(del, context, store);
List<NamedOperationDetail> results = Lists.newArrayList(getAllNamedOperationsHandler1.doOperation(get, context, store));
// then
assertThat(results).isEmpty();
}
Aggregations