Search in sources :

Example 56 with StoreProperties

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

the class ExportToOtherGraphHandlerTest method shouldCreateNewGraphWithStoresSchema.

@Test
public void shouldCreateNewGraphWithStoresSchema() {
    // Given
    given(store.getSchema()).willReturn(schema);
    given(store.getGraphLibrary()).willReturn(null);
    final StoreProperties storeProperties1 = StoreProperties.loadStoreProperties(StreamUtil.storeProps(getClass()));
    final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID + 1).storeProperties(storeProperties1).build();
    // When
    Graph graph = createGraph(export);
    // Then
    assertEquals(GRAPH_ID + 1, graph.getGraphId());
    assertEquals(schema, graph.getSchema());
    assertEquals(storeProperties1, graph.getStoreProperties());
}
Also used : ExportToOtherGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph) ExportToOtherGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph) Graph(uk.gov.gchq.gaffer.graph.Graph) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) Test(org.junit.jupiter.api.Test)

Example 57 with StoreProperties

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

the class GraphSerialisableTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    config = new GraphConfig.Builder().graphId("testGraphId").addHook(new NamedViewResolver()).addHook(new FunctionAuthoriser(FunctionAuthoriserUtil.DEFAULT_UNAUTHORISED_FUNCTIONS)).view(new View.Builder().entity("e1").build()).build();
    schema = new Schema.Builder().entity("e1", new SchemaEntityDefinition.Builder().vertex("string").build()).type("string", String.class).build();
    final StoreProperties storeProperties = new StoreProperties();
    storeProperties.setStoreClass(TestStore.class);
    properties = storeProperties.getProperties();
    expected = new GraphSerialisable.Builder().schema(schema).properties(properties).config(config).build();
}
Also used : Builder(uk.gov.gchq.gaffer.graph.GraphSerialisable.Builder) NamedViewResolver(uk.gov.gchq.gaffer.graph.hook.NamedViewResolver) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Builder(uk.gov.gchq.gaffer.graph.GraphSerialisable.Builder) FunctionAuthoriser(uk.gov.gchq.gaffer.graph.hook.FunctionAuthoriser) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 58 with StoreProperties

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

the class GraphSerialisableTest method shouldConsumeGraph.

@Test
public void shouldConsumeGraph() {
    // Given
    final Graph graph = new Graph.Builder().addSchema(schema).addStoreProperties(new StoreProperties(properties)).config(config).build();
    final GraphSerialisable result = new GraphSerialisable.Builder().graph(graph).build();
    // When / Then
    assertEquals(expected, result);
}
Also used : Builder(uk.gov.gchq.gaffer.graph.GraphSerialisable.Builder) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) Test(org.junit.jupiter.api.Test)

Example 59 with StoreProperties

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

the class ExportToOtherGraphTest method shouldJSONSerialiseAndDeserialise.

@Test
public void shouldJSONSerialiseAndDeserialise() throws SerialisationException, JsonProcessingException {
    // Given
    final Schema schema = new Schema.Builder().entity(TestGroups.ENTITY, new SchemaEntityDefinition()).build();
    final StoreProperties storeProperties = StoreProperties.loadStoreProperties(StreamUtil.storeProps(getClass()));
    final ExportToOtherGraph op = new ExportToOtherGraph.Builder().graphId("graphId").parentSchemaIds("schema1", "schema2").parentStorePropertiesId("props1").schema(schema).storeProperties(storeProperties).build();
    // When
    final byte[] json = JSONSerialiser.serialise(op);
    final ExportToOtherGraph deserialisedOp = JSONSerialiser.deserialise(json, op.getClass());
    // Then
    assertEquals("graphId", deserialisedOp.getGraphId());
    assertEquals(Arrays.asList("schema1", "schema2"), deserialisedOp.getParentSchemaIds());
    assertEquals("props1", deserialisedOp.getParentStorePropertiesId());
    JsonAssert.assertEquals(schema.toJson(false), deserialisedOp.getSchema().toJson(false));
    assertEquals(storeProperties, deserialisedOp.getStoreProperties());
}
Also used : Schema(uk.gov.gchq.gaffer.store.schema.Schema) SchemaEntityDefinition(uk.gov.gchq.gaffer.store.schema.SchemaEntityDefinition) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 60 with StoreProperties

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

the class OperationChainHandlerTest method shouldHandleNestedOperationChain.

@Test
public void shouldHandleNestedOperationChain() throws OperationException {
    // Given
    final OperationChainValidator opChainValidator = mock(OperationChainValidator.class);
    final List<OperationChainOptimiser> opChainOptimisers = Collections.emptyList();
    final OperationChainHandler opChainHandler = new OperationChainHandler(opChainValidator, opChainOptimisers);
    final Context context = mock(Context.class);
    final Store store = mock(Store.class);
    final User user = mock(User.class);
    final StoreProperties storeProperties = new StoreProperties();
    final GetAdjacentIds op1 = mock(GetAdjacentIds.class);
    final GetElements op2 = mock(GetElements.class);
    final Limit op3 = mock(Limit.class);
    final OperationChain opChain1 = new OperationChain(Arrays.asList(op1, op2));
    final OperationChain opChain2 = new OperationChain(Arrays.asList(opChain1, op3));
    final Entity entityA = new Entity.Builder().group(TestGroups.ENTITY).vertex("A").build();
    final Entity entityB = new Entity.Builder().group(TestGroups.ENTITY).vertex("B").build();
    given(context.getUser()).willReturn(user);
    given(store.getProperties()).willReturn(storeProperties);
    given(opChainValidator.validate(any(), any(), any())).willReturn(new ValidationResult());
    given(store.handleOperation(op1, context)).willReturn(new WrappedCloseableIterable<>(Lists.newArrayList(new EntitySeed("A"), new EntitySeed("B"))));
    given(store.handleOperation(op2, context)).willReturn(new WrappedCloseableIterable<>(Lists.newArrayList(entityA, entityB)));
    given(store.handleOperation(op3, context)).willReturn(entityA);
    // When
    final Object result = opChainHandler.doOperation(opChain2, context, store);
    // Then
    assertSame(entityA, result);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) Entity(uk.gov.gchq.gaffer.data.element.Entity) User(uk.gov.gchq.gaffer.user.User) GetAdjacentIds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds) Store(uk.gov.gchq.gaffer.store.Store) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) OperationChainValidator(uk.gov.gchq.gaffer.store.operation.OperationChainValidator) ValidationResult(uk.gov.gchq.koryphe.ValidationResult) OperationChainOptimiser(uk.gov.gchq.gaffer.store.optimiser.OperationChainOptimiser) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Limit(uk.gov.gchq.gaffer.operation.impl.Limit) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) Test(org.junit.jupiter.api.Test)

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