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