@Test public void writeKettleRepositoryProducer() throws IOException, BundleWriterException { EmbeddedKettleTransformationProducer producer = mock( EmbeddedKettleTransformationProducer.class ); when( producer.getArguments() ).thenReturn( new FormulaArgument[] {} ); when( producer.getParameter() ).thenReturn( new FormulaParameter[] {} ); WriteableDocumentBundle bundle = mock( WriteableDocumentBundle.class ); when( bundle.createEntry( anyString(), anyString() ) ).thenReturn( mock( OutputStream.class ) ); XmlWriter xmlWriter = mock( XmlWriter.class ); handler.writeKettleRepositoryProducer( bundle, "TEST_FILE_NAME", xmlWriter, "TEST_QUERY_NAME", producer ); verify( xmlWriter ).writeTag( eq( KettleDataFactoryModule.NAMESPACE ), eq( "query-embedded" ), any( AttributeList.class ), eq( XmlWriter.OPEN ) ); verify( xmlWriter ).writeTag( KettleDataFactoryModule.NAMESPACE, "resource", XmlWriter.OPEN ); verify( xmlWriter ).writeText( "TEST_QUERY_NAME.ktr" ); }
public void writeKettleRepositoryProducer( final WriteableDocumentBundle bundle, final String dataSourceFileName, final XmlWriter xmlWriter, final String queryName, final KettleTransformationProducer producer ) throws IOException, BundleWriterException { if ( producer instanceof EmbeddedKettleTransformationProducer == false ) { throw new BundleWriterException ( "Invalid object type registered for handler of " + EmbeddedKettleTransformationProducer.class .getSimpleName() ); } EmbeddedKettleTransformationProducer fileProducer = (EmbeddedKettleTransformationProducer) producer; String absoluteResourceName = writeFile( bundle, dataSourceFileName, queryName, fileProducer ); final AttributeList coreAttrs = new AttributeList(); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "name", queryName ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "plugin-id", fileProducer.getPluginId() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "stop-on-error", String.valueOf( fileProducer.isStopOnError() ) ); xmlWriter.writeTag( KettleDataFactoryModule.NAMESPACE, "query-embedded", coreAttrs, XmlWriter.OPEN ); xmlWriter.writeTag( KettleDataFactoryModule.NAMESPACE, "resource", XmlWriter.OPEN ); final String resourceName = IOUtils.getInstance().createRelativePath( absoluteResourceName, dataSourceFileName ); xmlWriter.writeText( resourceName ); xmlWriter.writeCloseTag(); TransformationProducerWriteHandlerLib.writeParameterAndArguments( xmlWriter, fileProducer ); xmlWriter.writeCloseTag(); }
EmdeddedTransformationProducerWriteHandler implements TransformationProducerWriteHandler { public void writeKettleRepositoryProducer( final WriteableDocumentBundle bundle, final String dataSourceFileName, final XmlWriter xmlWriter, final String queryName, final KettleTransformationProducer producer ) throws IOException, BundleWriterException { if ( producer instanceof EmbeddedKettleTransformationProducer == false ) { throw new BundleWriterException ( "Invalid object type registered for handler of " + EmbeddedKettleTransformationProducer.class .getSimpleName() ); } EmbeddedKettleTransformationProducer fileProducer = (EmbeddedKettleTransformationProducer) producer; String absoluteResourceName = writeFile( bundle, dataSourceFileName, queryName, fileProducer ); final AttributeList coreAttrs = new AttributeList(); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "name", queryName ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "plugin-id", fileProducer.getPluginId() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "stop-on-error", String.valueOf( fileProducer.isStopOnError() ) ); xmlWriter.writeTag( KettleDataFactoryModule.NAMESPACE, "query-embedded", coreAttrs, XmlWriter.OPEN ); xmlWriter.writeTag( KettleDataFactoryModule.NAMESPACE, "resource", XmlWriter.OPEN ); final String resourceName = IOUtils.getInstance().createRelativePath( absoluteResourceName, dataSourceFileName ); xmlWriter.writeText( resourceName ); xmlWriter.writeCloseTag(); TransformationProducerWriteHandlerLib.writeParameterAndArguments( xmlWriter, fileProducer ); xmlWriter.writeCloseTag(); } }
EmdeddedTransformationProducerWriteHandler implements TransformationProducerWriteHandler { public void writeKettleRepositoryProducer( final WriteableDocumentBundle bundle, final String dataSourceFileName, final XmlWriter xmlWriter, final String queryName, final KettleTransformationProducer producer ) throws IOException, BundleWriterException { if ( producer instanceof EmbeddedKettleTransformationProducer == false ) { throw new BundleWriterException ( "Invalid object type registered for handler of " + EmbeddedKettleTransformationProducer.class .getSimpleName() ); } EmbeddedKettleTransformationProducer fileProducer = (EmbeddedKettleTransformationProducer) producer; String absoluteResourceName = writeFile( bundle, dataSourceFileName, queryName, fileProducer ); final AttributeList coreAttrs = new AttributeList(); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "name", queryName ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "plugin-id", fileProducer.getPluginId() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "stop-on-error", String.valueOf( fileProducer.isStopOnError() ) ); xmlWriter.writeTag( KettleDataFactoryModule.NAMESPACE, "query-embedded", coreAttrs, XmlWriter.OPEN ); xmlWriter.writeTag( KettleDataFactoryModule.NAMESPACE, "resource", XmlWriter.OPEN ); final String resourceName = IOUtils.getInstance().createRelativePath( absoluteResourceName, dataSourceFileName ); xmlWriter.writeText( resourceName ); xmlWriter.writeCloseTag(); TransformationProducerWriteHandlerLib.writeParameterAndArguments( xmlWriter, fileProducer ); xmlWriter.writeCloseTag(); } EmdeddedTransformationProducerWriteHandler(); }
EmdeddedTransformationProducerWriteHandler implements TransformationProducerWriteHandler { public void writeKettleRepositoryProducer( final WriteableDocumentBundle bundle, final String dataSourceFileName, final XmlWriter xmlWriter, final String queryName, final KettleTransformationProducer producer ) throws IOException, BundleWriterException { if ( producer instanceof EmbeddedKettleTransformationProducer == false ) { throw new BundleWriterException ( "Invalid object type registered for handler of " + EmbeddedKettleTransformationProducer.class .getSimpleName() ); } EmbeddedKettleTransformationProducer fileProducer = (EmbeddedKettleTransformationProducer) producer; String absoluteResourceName = writeFile( bundle, dataSourceFileName, queryName, fileProducer ); final AttributeList coreAttrs = new AttributeList(); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "name", queryName ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "plugin-id", fileProducer.getPluginId() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "stop-on-error", String.valueOf( fileProducer.isStopOnError() ) ); xmlWriter.writeTag( KettleDataFactoryModule.NAMESPACE, "query-embedded", coreAttrs, XmlWriter.OPEN ); xmlWriter.writeTag( KettleDataFactoryModule.NAMESPACE, "resource", XmlWriter.OPEN ); final String resourceName = IOUtils.getInstance().createRelativePath( absoluteResourceName, dataSourceFileName ); xmlWriter.writeText( resourceName ); xmlWriter.writeCloseTag(); TransformationProducerWriteHandlerLib.writeParameterAndArguments( xmlWriter, fileProducer ); xmlWriter.writeCloseTag(); } EmdeddedTransformationProducerWriteHandler(); void writeKettleRepositoryProducer( final WriteableDocumentBundle bundle,
                                             final String dataSourceFileName,
                                             final XmlWriter xmlWriter,
                                             final String queryName,
                                             final KettleTransformationProducer producer ); }
EmdeddedTransformationProducerWriteHandler implements TransformationProducerWriteHandler { public void writeKettleRepositoryProducer( final WriteableDocumentBundle bundle, final String dataSourceFileName, final XmlWriter xmlWriter, final String queryName, final KettleTransformationProducer producer ) throws IOException, BundleWriterException { if ( producer instanceof EmbeddedKettleTransformationProducer == false ) { throw new BundleWriterException ( "Invalid object type registered for handler of " + EmbeddedKettleTransformationProducer.class .getSimpleName() ); } EmbeddedKettleTransformationProducer fileProducer = (EmbeddedKettleTransformationProducer) producer; String absoluteResourceName = writeFile( bundle, dataSourceFileName, queryName, fileProducer ); final AttributeList coreAttrs = new AttributeList(); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "name", queryName ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "plugin-id", fileProducer.getPluginId() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "stop-on-error", String.valueOf( fileProducer.isStopOnError() ) ); xmlWriter.writeTag( KettleDataFactoryModule.NAMESPACE, "query-embedded", coreAttrs, XmlWriter.OPEN ); xmlWriter.writeTag( KettleDataFactoryModule.NAMESPACE, "resource", XmlWriter.OPEN ); final String resourceName = IOUtils.getInstance().createRelativePath( absoluteResourceName, dataSourceFileName ); xmlWriter.writeText( resourceName ); xmlWriter.writeCloseTag(); TransformationProducerWriteHandlerLib.writeParameterAndArguments( xmlWriter, fileProducer ); xmlWriter.writeCloseTag(); } EmdeddedTransformationProducerWriteHandler(); void writeKettleRepositoryProducer( final WriteableDocumentBundle bundle,
                                             final String dataSourceFileName,
                                             final XmlWriter xmlWriter,
                                             final String queryName,
                                             final KettleTransformationProducer producer );  }