ExportToOtherGraphHandler extends ExportToHandler<ExportToOtherGraph, OtherGraphExporter> { @Override protected OtherGraphExporter createExporter(final ExportToOtherGraph export, final Context context, final Store store) { return new OtherGraphExporter(context, new GraphForExportDelegate.Builder() .store(store) .graphId(export.getGraphId()) .schema(export.getSchema()) .storeProperties(export.getStoreProperties()) .parentSchemaIds(export.getParentSchemaIds()) .parentStorePropertiesId(export.getParentStorePropertiesId()) .build()); }    }
@Test public void shouldCreateExporter() throws OperationException { 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(); OtherGraphExporter exporter = handler.createExporter(export, context, store); 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(); assertEquals(1, ops.size()); assertSame(elements, ((AddElements) ops.get(0)).getInput()); try { exporter.get("key"); fail("exception expected"); } catch (final UnsupportedOperationException e) { assertNotNull(e.getMessage()); } }