use of uk.gov.gchq.gaffer.store.StoreTrait in project Gaffer by gchq.
the class GraphConfigurationControllerTest method shouldSerialiseAndDeserialiseGetStoreTraits.
@Test
public void shouldSerialiseAndDeserialiseGetStoreTraits() throws SerialisationException {
// Given
Store store = mock(Store.class);
Schema schema = new Schema();
StoreProperties props = new StoreProperties();
Set<StoreTrait> storeTraits = Sets.newHashSet(INGEST_AGGREGATION, PRE_AGGREGATION_FILTERING, POST_AGGREGATION_FILTERING);
when(store.getSchema()).thenReturn(schema);
when(store.getProperties()).thenReturn(props);
when(store.getTraits()).thenReturn(storeTraits);
Graph graph = new Graph.Builder().config(new GraphConfig("id")).addSchema(new Schema()).store(store).build();
when(graphFactory.getGraph()).thenReturn(graph);
GraphConfigurationController controller = new GraphConfigurationController(graphFactory);
// When
byte[] bytes = JSONSerialiser.serialise(controller.getStoreTraits());
final Set<String> traits = JSONSerialiser.deserialise(bytes, Set.class);
// Then
assertEquals(Sets.newHashSet(INGEST_AGGREGATION.name(), PRE_AGGREGATION_FILTERING.name(), POST_AGGREGATION_FILTERING.name()), traits);
}
use of uk.gov.gchq.gaffer.store.StoreTrait in project Gaffer by gchq.
the class FederatedGetTraitsHandlerTest method shouldGetCurrentTraitsWhenContainsStoreWithOtherTraitsWithOptions.
@Test
public void shouldGetCurrentTraitsWhenContainsStoreWithOtherTraitsWithOptions() throws Exception {
// Given
federatedStore.initialise(FED_STORE_ID, null, properties);
federatedStore.execute(new AddGraph.Builder().isPublic(true).graphId(ALT_STORE).storeProperties(storeProperties).schema(new Schema()).build(), new Context(testUser()));
federatedStore.execute(new AddGraph.Builder().isPublic(true).graphId(ACC_STORE).storeProperties(PROPERTIES).schema(new Schema()).build(), new Context(testUser()));
// When
final Set<StoreTrait> traits = federatedStore.execute(new GetTraits.Builder().option(FederatedStoreConstants.KEY_OPERATION_OPTIONS_GRAPH_IDS, ALT_STORE).currentTraits(true).build(), new Context(testUser()));
// Then
assertEquals(Sets.newHashSet(TRANSFORMATION, MATCHED_VERTEX, PRE_AGGREGATION_FILTERING, POST_AGGREGATION_FILTERING, POST_TRANSFORMATION_FILTERING), traits);
}
use of uk.gov.gchq.gaffer.store.StoreTrait in project Gaffer by gchq.
the class FederatedGetTraitsHandlerTest method shouldGetZeroTraitsForEmptyStore.
@Test
public void shouldGetZeroTraitsForEmptyStore() throws Exception {
// Given
federatedStore.initialise(FED_STORE_ID, null, properties);
// When
final Set<StoreTrait> traits = federatedStore.execute(new GetTraits.Builder().currentTraits(false).build(), new Context(testUser()));
// Then
assertEquals(Collections.emptySet(), traits);
}
use of uk.gov.gchq.gaffer.store.StoreTrait in project Gaffer by gchq.
the class FederatedGetTraitsHandlerTest method shouldGetCurrentTraitsWhenContainsStoreWithOtherTraits.
@Test
public void shouldGetCurrentTraitsWhenContainsStoreWithOtherTraits() throws Exception {
// Given
federatedStore.initialise(FED_STORE_ID, null, properties);
federatedStore.execute(new AddGraph.Builder().isPublic(true).graphId(ALT_STORE).storeProperties(storeProperties).schema(new Schema()).build(), new Context(testUser()));
// When
final Set<StoreTrait> traits = federatedStore.execute(new GetTraits.Builder().currentTraits(true).build(), new Context(testUser()));
// Then
assertEquals(Sets.newHashSet(TRANSFORMATION, MATCHED_VERTEX, PRE_AGGREGATION_FILTERING, POST_AGGREGATION_FILTERING, POST_TRANSFORMATION_FILTERING), traits);
}
use of uk.gov.gchq.gaffer.store.StoreTrait in project Gaffer by gchq.
the class FederatedGetTraitsHandlerTest method shouldGetAllTraitsWhenContainsStoreWithOtherTraitsWithOptions.
@Test
public void shouldGetAllTraitsWhenContainsStoreWithOtherTraitsWithOptions() throws Exception {
// Given
federatedStore.initialise(FED_STORE_ID, null, properties);
federatedStore.execute(new AddGraph.Builder().isPublic(true).graphId(ALT_STORE).storeProperties(storeProperties).schema(new Schema()).build(), new Context(testUser()));
federatedStore.execute(new AddGraph.Builder().isPublic(true).graphId(ACC_STORE).storeProperties(PROPERTIES).schema(new Schema()).build(), new Context(testUser()));
// When
final Set<StoreTrait> traits = federatedStore.execute(new GetTraits.Builder().option(FederatedStoreConstants.KEY_OPERATION_OPTIONS_GRAPH_IDS, ALT_STORE).currentTraits(false).build(), new Context(testUser()));
// Then
assertEquals(TestStoreImpl.STORE_TRAITS, traits);
}
Aggregations