Search in sources :

Example 1 with OtherGraphExporter

use of uk.gov.gchq.gaffer.operation.export.graph.OtherGraphExporter in project Gaffer by gchq.

the class ExportToOtherGraphHandlerTest method shouldCreateExporter.

@Test
public void shouldCreateExporter() throws OperationException {
    // Given
    graphLibrary.add(GRAPH_ID + 1, SCHEMA_ID, schema, STORE_PROPS_ID, storeProperties);
    final Context context = mock(Context.class);
    final User user = new User();
    given(context.getUser()).willReturn(user);
    final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID + 1).build();
    final ExportToOtherGraphHandler handler = new ExportToOtherGraphHandler();
    // When
    OtherGraphExporter exporter = handler.createExporter(export, context, store);
    // Then
    assertNotNull(exporter);
    TestStore.mockStore = mock(Store.class);
    final Iterable elements = mock(Iterable.class);
    exporter.add("key", elements);
    final ArgumentCaptor<OperationChain> opChainCaptor = ArgumentCaptor.forClass(OperationChain.class);
    verify(TestStore.mockStore).execute(opChainCaptor.capture(), Mockito.any(Context.class));
    final List<Operation> ops = opChainCaptor.getValue().getOperations();
    assertThat(ops).hasSize(1);
    assertSame(elements, ((AddElements) ops.get(0)).getInput());
    assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> exporter.get("key")).extracting("message").isNotNull();
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) User(uk.gov.gchq.gaffer.user.User) Store(uk.gov.gchq.gaffer.store.Store) TestStore(uk.gov.gchq.gaffer.integration.store.TestStore) Operation(uk.gov.gchq.gaffer.operation.Operation) ExportToOtherGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph) OtherGraphExporter(uk.gov.gchq.gaffer.operation.export.graph.OtherGraphExporter) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 TestStore (uk.gov.gchq.gaffer.integration.store.TestStore)1 Operation (uk.gov.gchq.gaffer.operation.Operation)1 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)1 ExportToOtherGraph (uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph)1 OtherGraphExporter (uk.gov.gchq.gaffer.operation.export.graph.OtherGraphExporter)1 Context (uk.gov.gchq.gaffer.store.Context)1 Store (uk.gov.gchq.gaffer.store.Store)1 User (uk.gov.gchq.gaffer.user.User)1