Search in sources :

Example 1 with StoreProperties

use of uk.gov.gchq.gaffer.store.StoreProperties in project gaffer-doc by gchq.

the class ExportToOtherGraphExample method simpleExportWithCustomGraph.

public void simpleExportWithCustomGraph() {
    // ---------------------------------------------------------
    final Schema schema = Schema.fromJson(StreamUtil.openStreams(getClass(), "operations/schema"));
    final StoreProperties storeProperties = StoreProperties.loadStoreProperties(StreamUtil.openStream(getClass(), "othermockaccumulostore.properties"));
    final OperationChain<Iterable<? extends Element>> opChain = new OperationChain.Builder().first(new GetAllElements.Builder().view(new View.Builder().edge("edge").build()).build()).then(new ExportToOtherGraph.Builder().graphId("newGraphId").schema(schema).storeProperties(storeProperties).build()).build();
    // ---------------------------------------------------------
    showExample(opChain, "This example will export all Edges with group 'edge' to another Gaffer graph with new ID 'newGraphId'. " + "The new graph will have the custom provided schema (note it must contain the same Edge group 'edge' otherwise the exported edges will be invalid') and custom store properties. " + "The store properties could be any store properties e.g. Accumulo, HBase, Map, Proxy store properties.");
}
Also used : Schema(uk.gov.gchq.gaffer.store.schema.Schema) Element(uk.gov.gchq.gaffer.data.element.Element) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View)

Example 2 with StoreProperties

use of uk.gov.gchq.gaffer.store.StoreProperties 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 3 with StoreProperties

use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.

the class AddNamedOperationHandlerTest method before.

@BeforeEach
public void before() throws CacheOperationFailedException {
    storedOperations.clear();
    addNamedOperation.setOperationName(OPERATION_NAME);
    doAnswer(invocationOnMock -> {
        Object[] args = invocationOnMock.getArguments();
        storedOperations.put(((NamedOperationDetail) args[0]).getOperationName(), (NamedOperationDetail) args[0]);
        return null;
    }).when(mockCache).addNamedOperation(any(NamedOperationDetail.class), anyBoolean(), any(User.class), eq(EMPTY_ADMIN_AUTH));
    doAnswer(invocationOnMock -> new WrappedCloseableIterable<>(storedOperations.values())).when(mockCache).getAllNamedOperations(any(User.class), eq(EMPTY_ADMIN_AUTH));
    doAnswer(invocationOnMock -> {
        String name = (String) invocationOnMock.getArguments()[0];
        NamedOperationDetail result = storedOperations.get(name);
        if (result == null) {
            throw new CacheOperationFailedException();
        }
        return result;
    }).when(mockCache).getNamedOperation(anyString(), any(User.class), eq(EMPTY_ADMIN_AUTH));
    given(store.getProperties()).willReturn(new StoreProperties());
}
Also used : User(uk.gov.gchq.gaffer.user.User) NamedOperationDetail(uk.gov.gchq.gaffer.named.operation.NamedOperationDetail) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CacheOperationFailedException(uk.gov.gchq.gaffer.named.operation.cache.exception.CacheOperationFailedException) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with StoreProperties

use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.

the class DeleteNamedViewHandlerTest method before.

@BeforeEach
public void before() throws OperationException {
    properties.set("gaffer.cache.service.class", "uk.gov.gchq.gaffer.cache.impl.HashMapCacheService");
    CacheServiceLoader.initialise(properties.getProperties());
    given(store.getProperties()).willReturn(new StoreProperties());
    testParameters.put("testParam", mock(ViewParameterDetail.class));
    view = new View.Builder().edge(TestGroups.EDGE).build();
    addNamedView = new AddNamedView.Builder().name(testNamedViewName).view(view).writeAccessRoles(WRITE_ACCESS_ROLE).overwrite(false).build();
    addNamedViewHandler.doOperation(addNamedView, context, store);
}
Also used : ViewParameterDetail(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewParameterDetail) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) DeleteNamedView(uk.gov.gchq.gaffer.named.view.DeleteNamedView) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) AddNamedView(uk.gov.gchq.gaffer.named.view.AddNamedView) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with StoreProperties

use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.

the class GetAllNamedViewsHandlerTest method initialiseCache.

private void initialiseCache() {
    given(store.getProperties()).willReturn(new StoreProperties());
    StoreProperties properties = new StoreProperties();
    properties.set("gaffer.cache.service.class", "uk.gov.gchq.gaffer.cache.impl.HashMapCacheService");
    CacheServiceLoader.initialise(properties.getProperties());
}
Also used : StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties)

Aggregations

StoreProperties (uk.gov.gchq.gaffer.store.StoreProperties)170 Test (org.junit.jupiter.api.Test)136 Schema (uk.gov.gchq.gaffer.store.schema.Schema)102 Store (uk.gov.gchq.gaffer.store.Store)74 Context (uk.gov.gchq.gaffer.store.Context)47 TestStore (uk.gov.gchq.gaffer.integration.store.TestStore)42 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)39 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)26 Graph (uk.gov.gchq.gaffer.graph.Graph)26 Operation (uk.gov.gchq.gaffer.operation.Operation)24 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)21 OperationView (uk.gov.gchq.gaffer.operation.graph.OperationView)20 User (uk.gov.gchq.gaffer.user.User)18 NamedOperation (uk.gov.gchq.gaffer.named.operation.NamedOperation)17 BeforeEach (org.junit.jupiter.api.BeforeEach)16 GraphHook (uk.gov.gchq.gaffer.graph.hook.GraphHook)16 SchemaEdgeDefinition (uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition)16 ExportToOtherGraph (uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph)14 HashSet (java.util.HashSet)13 FunctionAuthoriser (uk.gov.gchq.gaffer.graph.hook.FunctionAuthoriser)13