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