Search in sources :

Example 1 with GetAllNamedOperations

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

the class NamedOperationCacheIT method shouldBeAbleToAddNamedOperationToCache.

private void shouldBeAbleToAddNamedOperationToCache() throws OperationException {
    // given
    GetAllNamedOperations get = new GetAllNamedOperations.Builder().build();
    final Store store = mock(Store.class);
    given(store.getProperties()).willReturn(properties);
    // when
    addNamedOperationHandler.doOperation(add, context, store);
    NamedOperationDetail expectedNamedOp = new NamedOperationDetail.Builder().operationName(add.getOperationName()).operationChain(add.getOperationChainAsString()).creatorId(user.getUserId()).description(add.getDescription()).score(0).parameters(null).build();
    List<NamedOperationDetail> expected = Lists.newArrayList(expectedNamedOp);
    List<NamedOperationDetail> results = Lists.newArrayList(new GetAllNamedOperationsHandler().doOperation(get, context, store));
    // then
    assertThat(results).hasSize(1).isEqualTo(expected);
}
Also used : GetAllNamedOperationsHandler(uk.gov.gchq.gaffer.store.operation.handler.named.GetAllNamedOperationsHandler) GetAllNamedOperations(uk.gov.gchq.gaffer.named.operation.GetAllNamedOperations) Store(uk.gov.gchq.gaffer.store.Store) NamedOperationDetail(uk.gov.gchq.gaffer.named.operation.NamedOperationDetail)

Example 2 with GetAllNamedOperations

use of uk.gov.gchq.gaffer.named.operation.GetAllNamedOperations 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);
}
Also used : GetAllNamedOperations(uk.gov.gchq.gaffer.named.operation.GetAllNamedOperations) Store(uk.gov.gchq.gaffer.store.Store) AddNamedOperation(uk.gov.gchq.gaffer.named.operation.AddNamedOperation) NamedOperationDetail(uk.gov.gchq.gaffer.named.operation.NamedOperationDetail) AddNamedOperationHandler(uk.gov.gchq.gaffer.store.operation.handler.named.AddNamedOperationHandler)

Example 3 with GetAllNamedOperations

use of uk.gov.gchq.gaffer.named.operation.GetAllNamedOperations 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);
}
Also used : GetAllNamedOperations(uk.gov.gchq.gaffer.named.operation.GetAllNamedOperations) Store(uk.gov.gchq.gaffer.store.Store) AddNamedOperation(uk.gov.gchq.gaffer.named.operation.AddNamedOperation) NamedOperationDetail(uk.gov.gchq.gaffer.named.operation.NamedOperationDetail) AddNamedOperationHandler(uk.gov.gchq.gaffer.store.operation.handler.named.AddNamedOperationHandler) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties)

Example 4 with GetAllNamedOperations

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

the class GetAllNamedOperationsHandlerTest method shouldReturnNamedOperationWithNoInputType.

@Test
public void shouldReturnNamedOperationWithNoInputType() throws Exception {
    // Given
    AddNamedOperation addNamedOperation = new AddNamedOperation.Builder().name(expectedOperationDetailWithoutInputType.getOperationName()).description(expectedOperationDetailWithoutInputType.getDescription()).operationChain(expectedOperationDetailWithoutInputType.getOperationChainWithDefaultParams()).build();
    addNamedOperationHandler.doOperation(addNamedOperation, context, store);
    // When
    CloseableIterable<NamedOperationDetail> allNamedOperationsList = getAllNamedOperationsHandler.doOperation(new GetAllNamedOperations(), context, store);
    // Then
    assertEquals(1, Iterables.size(allNamedOperationsList));
    assertTrue(Iterables.contains(allNamedOperationsList, expectedOperationDetailWithoutInputType));
}
Also used : GetAllNamedOperations(uk.gov.gchq.gaffer.named.operation.GetAllNamedOperations) AddNamedOperation(uk.gov.gchq.gaffer.named.operation.AddNamedOperation) NamedOperationDetail(uk.gov.gchq.gaffer.named.operation.NamedOperationDetail) Test(org.junit.jupiter.api.Test)

Example 5 with GetAllNamedOperations

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

the class OperationServiceIT method shouldReturnNamedOpDetailWithLabelWhenLabelIsAddedToNamedOp.

@Test
public void shouldReturnNamedOpDetailWithLabelWhenLabelIsAddedToNamedOp() throws Exception {
    // Given
    final AddNamedOperation namedOperation = new AddNamedOperation.Builder().name("My Operation With Label").labels(Arrays.asList("test label")).operationChain("{\"operations\":[{\"class\":\"uk.gov.gchq.gaffer.operation.impl.add.AddElements\",\"skipInvalidElements\":false,\"validate\":true}]}").build();
    client.executeOperation(namedOperation);
    // When
    final Response response = client.executeOperation(new GetAllNamedOperations());
    final List<NamedOperationDetail> namedOperationDetails = response.readEntity(new GenericType<List<NamedOperationDetail>>() {
    });
    // Then
    final NamedOperationDetail expected = new NamedOperationDetail.Builder().operationName("My Operation With Label").labels(Arrays.asList("test label")).operationChain("{\"operations\":[{\"class\":\"uk.gov.gchq.gaffer.operation.impl.add.AddElements\",\"skipInvalidElements\":false,\"validate\":true}]}").inputType("uk.gov.gchq.gaffer.data.element.Element[]").creatorId("UNKNOWN").parameters(null).build();
    assertThat(namedOperationDetails.iterator().next()).isEqualTo(expected);
}
Also used : Response(javax.ws.rs.core.Response) GetAllNamedOperations(uk.gov.gchq.gaffer.named.operation.GetAllNamedOperations) AddNamedOperation(uk.gov.gchq.gaffer.named.operation.AddNamedOperation) NamedOperationDetail(uk.gov.gchq.gaffer.named.operation.NamedOperationDetail) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.jupiter.api.Test)

Aggregations

GetAllNamedOperations (uk.gov.gchq.gaffer.named.operation.GetAllNamedOperations)10 NamedOperationDetail (uk.gov.gchq.gaffer.named.operation.NamedOperationDetail)10 AddNamedOperation (uk.gov.gchq.gaffer.named.operation.AddNamedOperation)8 Test (org.junit.jupiter.api.Test)5 Store (uk.gov.gchq.gaffer.store.Store)4 AddNamedOperationHandler (uk.gov.gchq.gaffer.store.operation.handler.named.AddNamedOperationHandler)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Response (javax.ws.rs.core.Response)1 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)1 Element (uk.gov.gchq.gaffer.data.element.Element)1 EntityId (uk.gov.gchq.gaffer.data.element.id.EntityId)1 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)1 RoadAndRoadUseWithTimesAndCardinalitiesElementGenerator (uk.gov.gchq.gaffer.doc.user.generator.RoadAndRoadUseWithTimesAndCardinalitiesElementGenerator)1 Graph (uk.gov.gchq.gaffer.graph.Graph)1 DeleteNamedOperation (uk.gov.gchq.gaffer.named.operation.DeleteNamedOperation)1 NamedOperation (uk.gov.gchq.gaffer.named.operation.NamedOperation)1 ParameterDetail (uk.gov.gchq.gaffer.named.operation.ParameterDetail)1 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)1 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)1