@Test public void writeKettleRepositoryProducer_with_non_empty_params() throws IOException, BundleWriterException { KettleTransFromRepositoryProducer producer = mock( KettleTransFromRepositoryProducer.class ); when( producer.getDefinedArgumentNames() ).thenReturn( new String[] { "TEST_PARAM" } ); when( producer.getDefinedVariableNames() ).thenReturn( new ParameterMapping[] {} ); when( producer.getArguments() ).thenReturn( new FormulaArgument[] {} ); when( producer.getParameter() ).thenReturn( new FormulaParameter[] {} ); XmlWriter xmlWriter = mock( XmlWriter.class ); handler.writeKettleRepositoryProducer( mock( WriteableDocumentBundle.class ), "TEST_FILE_NAME", xmlWriter, "TEST_QUERY_NAME", producer ); verify( xmlWriter ).writeTag( eq( KettleDataFactoryModule.NAMESPACE ), eq( "query-repository" ), any( AttributeList.class ), eq( XmlWriter.OPEN ) ); verify( xmlWriter ).writeCloseTag(); }
public void writeKettleRepositoryProducer( final WriteableDocumentBundle bundle, final String dataSourceFileName, final XmlWriter xmlWriter, final String queryName, final KettleTransformationProducer producer ) throws IOException, BundleWriterException { if ( producer instanceof KettleTransFromRepositoryProducer == false ) { throw new BundleWriterException ( "Invalid object type registered for handler of " + KettleTransFromRepositoryProducer.class.getSimpleName() ); } KettleTransFromRepositoryProducer repositoryProducer = (KettleTransFromRepositoryProducer) producer; final AttributeList coreAttrs = new AttributeList(); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "name", queryName ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "repository", repositoryProducer.getRepositoryName() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "directory", repositoryProducer.getDirectoryName() ); coreAttrs .setAttribute( KettleDataFactoryModule.NAMESPACE, "transformation", repositoryProducer.getTransformationName() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "step", repositoryProducer.getStepName() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "username", repositoryProducer.getUsername() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "password", PasswordEncryptionService.getInstance().encrypt( repositoryProducer.getPassword() ) ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "stop-on-error", String.valueOf( repositoryProducer.isStopOnError() ) ); final String[] definedArgumentNames = repositoryProducer.getDefinedArgumentNames(); final ParameterMapping[] parameterMappings = repositoryProducer.getDefinedVariableNames(); if ( definedArgumentNames.length == 0 && parameterMappings.length == 0 ) { xmlWriter.writeTag( KettleDataFactoryModule.NAMESPACE, "query-repository", coreAttrs, XmlWriter.CLOSE ); return; } xmlWriter.writeTag( KettleDataFactoryModule.NAMESPACE, "query-repository", coreAttrs, XmlWriter.OPEN ); TransformationProducerWriteHandlerLib.writeParameterAndArguments( xmlWriter, repositoryProducer ); xmlWriter.writeCloseTag(); }
RepositoryTransformationProducerWriteHandler 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 KettleTransFromRepositoryProducer == false ) { throw new BundleWriterException ( "Invalid object type registered for handler of " + KettleTransFromRepositoryProducer.class.getSimpleName() ); } KettleTransFromRepositoryProducer repositoryProducer = (KettleTransFromRepositoryProducer) producer; final AttributeList coreAttrs = new AttributeList(); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "name", queryName ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "repository", repositoryProducer.getRepositoryName() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "directory", repositoryProducer.getDirectoryName() ); coreAttrs .setAttribute( KettleDataFactoryModule.NAMESPACE, "transformation", repositoryProducer.getTransformationName() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "step", repositoryProducer.getStepName() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "username", repositoryProducer.getUsername() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "password", PasswordEncryptionService.getInstance().encrypt( repositoryProducer.getPassword() ) ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "stop-on-error", String.valueOf( repositoryProducer.isStopOnError() ) ); final String[] definedArgumentNames = repositoryProducer.getDefinedArgumentNames(); final ParameterMapping[] parameterMappings = repositoryProducer.getDefinedVariableNames(); if ( definedArgumentNames.length == 0 && parameterMappings.length == 0 ) { xmlWriter.writeTag( KettleDataFactoryModule.NAMESPACE, "query-repository", coreAttrs, XmlWriter.CLOSE ); return; } xmlWriter.writeTag( KettleDataFactoryModule.NAMESPACE, "query-repository", coreAttrs, XmlWriter.OPEN ); TransformationProducerWriteHandlerLib.writeParameterAndArguments( xmlWriter, repositoryProducer ); xmlWriter.writeCloseTag(); } }
RepositoryTransformationProducerWriteHandler 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 KettleTransFromRepositoryProducer == false ) { throw new BundleWriterException ( "Invalid object type registered for handler of " + KettleTransFromRepositoryProducer.class.getSimpleName() ); } KettleTransFromRepositoryProducer repositoryProducer = (KettleTransFromRepositoryProducer) producer; final AttributeList coreAttrs = new AttributeList(); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "name", queryName ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "repository", repositoryProducer.getRepositoryName() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "directory", repositoryProducer.getDirectoryName() ); coreAttrs .setAttribute( KettleDataFactoryModule.NAMESPACE, "transformation", repositoryProducer.getTransformationName() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "step", repositoryProducer.getStepName() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "username", repositoryProducer.getUsername() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "password", PasswordEncryptionService.getInstance().encrypt( repositoryProducer.getPassword() ) ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "stop-on-error", String.valueOf( repositoryProducer.isStopOnError() ) ); final String[] definedArgumentNames = repositoryProducer.getDefinedArgumentNames(); final ParameterMapping[] parameterMappings = repositoryProducer.getDefinedVariableNames(); if ( definedArgumentNames.length == 0 && parameterMappings.length == 0 ) { xmlWriter.writeTag( KettleDataFactoryModule.NAMESPACE, "query-repository", coreAttrs, XmlWriter.CLOSE ); return; } xmlWriter.writeTag( KettleDataFactoryModule.NAMESPACE, "query-repository", coreAttrs, XmlWriter.OPEN ); TransformationProducerWriteHandlerLib.writeParameterAndArguments( xmlWriter, repositoryProducer ); xmlWriter.writeCloseTag(); } RepositoryTransformationProducerWriteHandler(); }
RepositoryTransformationProducerWriteHandler 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 KettleTransFromRepositoryProducer == false ) { throw new BundleWriterException ( "Invalid object type registered for handler of " + KettleTransFromRepositoryProducer.class.getSimpleName() ); } KettleTransFromRepositoryProducer repositoryProducer = (KettleTransFromRepositoryProducer) producer; final AttributeList coreAttrs = new AttributeList(); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "name", queryName ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "repository", repositoryProducer.getRepositoryName() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "directory", repositoryProducer.getDirectoryName() ); coreAttrs .setAttribute( KettleDataFactoryModule.NAMESPACE, "transformation", repositoryProducer.getTransformationName() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "step", repositoryProducer.getStepName() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "username", repositoryProducer.getUsername() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "password", PasswordEncryptionService.getInstance().encrypt( repositoryProducer.getPassword() ) ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "stop-on-error", String.valueOf( repositoryProducer.isStopOnError() ) ); final String[] definedArgumentNames = repositoryProducer.getDefinedArgumentNames(); final ParameterMapping[] parameterMappings = repositoryProducer.getDefinedVariableNames(); if ( definedArgumentNames.length == 0 && parameterMappings.length == 0 ) { xmlWriter.writeTag( KettleDataFactoryModule.NAMESPACE, "query-repository", coreAttrs, XmlWriter.CLOSE ); return; } xmlWriter.writeTag( KettleDataFactoryModule.NAMESPACE, "query-repository", coreAttrs, XmlWriter.OPEN ); TransformationProducerWriteHandlerLib.writeParameterAndArguments( xmlWriter, repositoryProducer ); xmlWriter.writeCloseTag(); } RepositoryTransformationProducerWriteHandler(); void writeKettleRepositoryProducer( final WriteableDocumentBundle bundle,
                                             final String dataSourceFileName,
                                             final XmlWriter xmlWriter,
                                             final String queryName,
                                             final KettleTransformationProducer producer ); }
RepositoryTransformationProducerWriteHandler 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 KettleTransFromRepositoryProducer == false ) { throw new BundleWriterException ( "Invalid object type registered for handler of " + KettleTransFromRepositoryProducer.class.getSimpleName() ); } KettleTransFromRepositoryProducer repositoryProducer = (KettleTransFromRepositoryProducer) producer; final AttributeList coreAttrs = new AttributeList(); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "name", queryName ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "repository", repositoryProducer.getRepositoryName() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "directory", repositoryProducer.getDirectoryName() ); coreAttrs .setAttribute( KettleDataFactoryModule.NAMESPACE, "transformation", repositoryProducer.getTransformationName() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "step", repositoryProducer.getStepName() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "username", repositoryProducer.getUsername() ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "password", PasswordEncryptionService.getInstance().encrypt( repositoryProducer.getPassword() ) ); coreAttrs.setAttribute( KettleDataFactoryModule.NAMESPACE, "stop-on-error", String.valueOf( repositoryProducer.isStopOnError() ) ); final String[] definedArgumentNames = repositoryProducer.getDefinedArgumentNames(); final ParameterMapping[] parameterMappings = repositoryProducer.getDefinedVariableNames(); if ( definedArgumentNames.length == 0 && parameterMappings.length == 0 ) { xmlWriter.writeTag( KettleDataFactoryModule.NAMESPACE, "query-repository", coreAttrs, XmlWriter.CLOSE ); return; } xmlWriter.writeTag( KettleDataFactoryModule.NAMESPACE, "query-repository", coreAttrs, XmlWriter.OPEN ); TransformationProducerWriteHandlerLib.writeParameterAndArguments( xmlWriter, repositoryProducer ); xmlWriter.writeCloseTag(); } RepositoryTransformationProducerWriteHandler(); void writeKettleRepositoryProducer( final WriteableDocumentBundle bundle,
                                             final String dataSourceFileName,
                                             final XmlWriter xmlWriter,
                                             final String queryName,
                                             final KettleTransformationProducer producer );  }