### Question:
HTMLPublisherConverter extends SingleTypedConverter<HtmlPublisher> { @Override public boolean convert(ConverterRequest request, ConverterResult result, Object target) { HtmlPublisher htmlPublisher = (HtmlPublisher) target; ModelASTBuildCondition buildCondition = ModelASTUtils.buildOrFindBuildCondition( result.getModelASTPipelineDef(), "always" ); htmlPublisher.getReportTargets().stream().forEach( reportTarget -> { ModelASTStep publishHTML = new ModelASTStep( this ); publishHTML.setName( "publishHTML" ); ModelASTUtils.addStep(buildCondition, publishHTML); Map<ModelASTKey, ModelASTValue> args = new HashMap<>(); { ModelASTKey allowMissing = new ModelASTKey( this ); allowMissing.setKey( "allowMissing" ); args.put( allowMissing, ModelASTValue.fromConstant( reportTarget.getAllowMissing(), this ) ); } { ModelASTKey alwaysLinkToLastBuild = new ModelASTKey( this ); alwaysLinkToLastBuild.setKey( "alwaysLinkToLastBuild" ); args.put( alwaysLinkToLastBuild, ModelASTValue.fromConstant( reportTarget.getAlwaysLinkToLastBuild(), this ) ); } { ModelASTKey keepAll = new ModelASTKey( this ); keepAll.setKey( "keepAll" ); args.put( keepAll, ModelASTValue.fromConstant( reportTarget.getKeepAll(), this ) ); } { ModelASTKey reportDir = new ModelASTKey( this ); reportDir.setKey( "reportDir" ); args.put( reportDir, ModelASTValue.fromConstant( reportTarget.getReportDir(), this ) ); } { ModelASTKey reportFiles = new ModelASTKey( this ); reportFiles.setKey( "reportFiles" ); args.put( reportFiles, ModelASTValue.fromConstant( reportTarget.getReportFiles(), this ) ); } { ModelASTKey reportName = new ModelASTKey( this ); reportName.setKey( "reportName" ); args.put( reportName, ModelASTValue.fromConstant( reportTarget.getReportName(), this ) ); } { ModelASTKey reportTitles = new ModelASTKey( this ); reportTitles.setKey( "reportTitles" ); args.put( reportTitles, ModelASTValue.fromConstant( reportTarget.getReportTitles(), this ) ); } ModelASTNamedArgumentList stepArgs = new ModelASTNamedArgumentList( null); stepArgs.setArguments( args ); publishHTML.setArgs( stepArgs ); } ); return true; }  @Override boolean convert(ConverterRequest request, ConverterResult result, Object target);  }### Answer:
@Test public void simpletest() throws Exception { String projectName = Long.toString( System.currentTimeMillis() ); FreeStyleProject p = j.createFreeStyleProject( projectName ); HtmlPublisherTarget htmlPublisherTarget = new HtmlPublisherTarget( "reportName", "reportDir", "reportFiles", true, true, true); HtmlPublisher publisher = new HtmlPublisher( Arrays.asList( htmlPublisherTarget ) ); p.getPublishersList().add( publisher ); HTMLPublisherConverter converter = j.jenkins.getExtensionList( HTMLPublisherConverter.class ).get( 0 ); assertTrue( converter.canConvert( publisher ) ); ConverterResult result = new ConverterResult(); converter.convert( new ConverterRequest().job( p ), result, publisher ); ModelASTPostBuild postBuild = result.getModelASTPipelineDef().getPostBuild(); assertEquals( 1, postBuild.getConditions().size() ); String groovy = postBuild.getConditions().get( 0 ).toGroovy(); assertThat( groovy, containsString( "always" ) ); assertThat( groovy, containsString( "publishHTML(" ) ); assertThat( groovy, containsString( "keepAll: true" ) ); assertThat( groovy, containsString( "reportName: 'reportName'" ) ); assertThat( groovy, containsString( "alwaysLinkToLastBuild: true" ) ); assertThat( groovy, containsString( "allowMissing: true" ) ); assertThat( groovy, containsString( "reportFiles: 'reportFiles'" ) ); assertThat( groovy, containsString( "reportDir: 'reportDir'" ) ); }