1111import java .io .IOException ;
1212import java .util .ArrayList ;
1313import java .util .Arrays ;
14+ import java .util .HashMap ;
1415import java .util .List ;
16+ import java .util .Map ;
1517import javax .annotation .Nonnull ;
18+ import org .apache .commons .collections .map .HashedMap ;
1619import org .apache .commons .io .FilenameUtils ;
1720import org .jenkinsci .Symbol ;
1821import org .kohsuke .stapler .DataBoundConstructor ;
@@ -222,17 +225,21 @@ public String constructCommandForTest(String inputArguments) {
222225 // Concatenate the input arguments
223226 private String getInputArguments () {
224227
225- final List <String > inputArgs = new ArrayList <String >();
228+ final List <String > inputArgsList = new ArrayList <String >();
229+ final Map <String ,String > args = new HashMap <String ,String >();
230+
226231 final List <Artifact > artifactList =
227232 new ArrayList <Artifact >(Arrays .asList (getPdfReportArtifact (), getTapArtifact (),
228233 getJunitArtifact (), getStmResultsArtifact (), getCoberturaArtifact (),
229234 getModelCoverageArtifact ()));
230235
231236 for (Artifact artifact : artifactList ) {
232- artifact .addFilePathArgTo (inputArgs );
237+ artifact .addFilePathArgTo (args );
233238 }
234239
235- return String .join ("," , inputArgs );
240+ args .forEach ((key , val ) -> inputArgsList .add ("'" + key + "'" + "," + "'" + val + "'" ));
241+
242+ return String .join ("," , inputArgsList );
236243 }
237244
238245
@@ -246,212 +253,142 @@ private String getInputArguments() {
246253 * 7Csort:date/jenkinsci-dev/AFYHSG3NUEI/UsVJIKoE4B8J
247254 *
248255 */
249- public static class PdfArtifact extends Artifact {
250- private String pdfReportFilePath ;
256+ public static class PdfArtifact extends AbstractArtifactImpl {
251257
252- @ DataBoundConstructor
253- public PdfArtifact () {
254-
255- }
258+ private static final String PDF_REPORT_PATH = "PDFReportPath" ;
256259
257- @ DataBoundSetter
258- public void setPdfReportFilePath (String pdfReportFilePath ) {
259- this .pdfReportFilePath = pdfReportFilePath ;
260- }
261-
262- public String getPdfReportFilePath () {
263- return this .pdfReportFilePath ;
264- }
265-
266- @ Override
267- public void addFilePathArgTo (List <String > inputArgs ) {
268- inputArgs .add (MatlabBuilderConstants .PDF_REPORT_PATH + "," + "'"
269- + getPdfReportFilePath () + "'" );
260+ @ DataBoundConstructor
261+ public PdfArtifact (String pdfReportFilePath ) {
262+ super (pdfReportFilePath );
270263 }
271264
272265 @ Override
273- public String getFilePath ( ) {
274- return getPdfReportFilePath ( );
266+ public void addFilePathArgTo ( Map < String , String > inputArgs ) {
267+ inputArgs . put ( PDF_REPORT_PATH , getFilePath () );
275268 }
276269 }
277270
278- public static class TapArtifact extends Artifact {
279- private String tapReportFilePath ;
271+ public static class TapArtifact extends AbstractArtifactImpl {
280272
281- @ DataBoundConstructor
282- public TapArtifact () {
283-
284- }
273+ private static final String TAP_RESULTS_PATH = "TAPResultsPath" ;
285274
286- @ DataBoundSetter
287- public void setTapReportFilePath (String tapReportFilePath ) {
288- this .tapReportFilePath = tapReportFilePath ;
289- }
290-
291- public String getTapReportFilePath () {
292- return tapReportFilePath ;
293- }
294-
295- @ Override
296- public void addFilePathArgTo (List <String > inputArgs ) {
297- inputArgs .add (MatlabBuilderConstants .TAP_RESULTS_PATH + "," + "'"
298- + getTapReportFilePath () + "'" );
275+ @ DataBoundConstructor
276+ public TapArtifact (String tapReportFilePath ) {
277+ super (tapReportFilePath );
299278 }
300279
301280 @ Override
302- public String getFilePath ( ) {
303- return getTapReportFilePath ( );
281+ public void addFilePathArgTo ( Map < String , String > inputArgs ) {
282+ inputArgs . put ( TAP_RESULTS_PATH , getFilePath () );
304283 }
305284 }
306285
307- public static class JunitArtifact extends Artifact {
308- private String junitReportFilePath ;
286+ public static class JunitArtifact extends AbstractArtifactImpl {
309287
310- @ DataBoundConstructor
311- public JunitArtifact () {
312-
313- }
288+ private static final String JUNIT_RESULTS_PATH = "JUnitResultsPath" ;
314289
315- @ DataBoundSetter
316- public void setJunitReportFilePath (String junitReportFilePath ) {
317- this .junitReportFilePath = junitReportFilePath ;
318- }
319-
320- public String getJunitReportFilePath () {
321- return this .junitReportFilePath ;
322- }
323-
324- @ Override
325- public void addFilePathArgTo (List <String > inputArgs ) {
326- inputArgs .add (MatlabBuilderConstants .JUNIT_RESULTS_PATH + "," + "'"
327- + getJunitReportFilePath () + "'" );
290+ @ DataBoundConstructor
291+ public JunitArtifact (String junitReportFilePath ) {
292+ super (junitReportFilePath );
328293 }
329294
330295 @ Override
331- public String getFilePath ( ) {
332- return getJunitReportFilePath ( );
296+ public void addFilePathArgTo ( Map < String , String > inputArgs ) {
297+ inputArgs . put ( JUNIT_RESULTS_PATH , getFilePath () );
333298 }
334299 }
335300
336- public static class CoberturaArtifact extends Artifact {
337- private String coberturaReportFilePath ;
301+ public static class CoberturaArtifact extends AbstractArtifactImpl {
338302
339- @ DataBoundConstructor
340- public CoberturaArtifact () {
341-
342- }
303+ private static final String COBERTURA_CODE_COVERAGE_PATH = "CoberturaCodeCoveragePath" ;
343304
344- @ DataBoundSetter
345- public void setCoberturaReportFilePath (String coberturaReportFilePath ) {
346- this .coberturaReportFilePath = coberturaReportFilePath ;
347- }
348-
349- public String getCoberturaReportFilePath () {
350- return this .coberturaReportFilePath ;
351- }
352-
353- @ Override
354- public void addFilePathArgTo (List <String > inputArgs ) {
355- inputArgs .add (MatlabBuilderConstants .COBERTURA_CODE_COVERAGE_PATH + "," + "'"
356- + getCoberturaReportFilePath () + "'" );
305+ @ DataBoundConstructor
306+ public CoberturaArtifact (String coberturaReportFilePath ) {
307+ super (coberturaReportFilePath );
357308 }
358309
359310 @ Override
360- public String getFilePath ( ) {
361- return getCoberturaReportFilePath ( );
311+ public void addFilePathArgTo ( Map < String , String > inputArgs ) {
312+ inputArgs . put ( COBERTURA_CODE_COVERAGE_PATH , getFilePath () );
362313 }
363314 }
364315
365- public static class StmResultsArtifact extends Artifact {
366- private String stmResultsFilePath ;
316+ public static class StmResultsArtifact extends AbstractArtifactImpl {
317+
318+ private static final String STM_RESULTS_PATH = "SimulinkTestResultsPath" ;
367319
368320 @ DataBoundConstructor
369- public StmResultsArtifact () {
370-
321+ public StmResultsArtifact (String stmResultsFilePath ) {
322+ super ( stmResultsFilePath );
371323 }
372324
373- @ DataBoundSetter
374- public void setStmResultsFilePath ( String stmResultsFilePath ) {
375- this . stmResultsFilePath = stmResultsFilePath ;
325+ @ Override
326+ public void addFilePathArgTo ( Map < String , String > inputArgs ) {
327+ inputArgs . put ( STM_RESULTS_PATH , getFilePath ()) ;
376328 }
329+ }
377330
378- public String getStmResultsFilePath () {
379- return stmResultsFilePath ;
380- }
331+ public static class ModelCovArtifact extends AbstractArtifactImpl {
381332
382- @ Override
383- public void addFilePathArgTo (List <String > inputArgs ) {
384- inputArgs .add (MatlabBuilderConstants .STM_RESULTS_PATH + "," + "'"
385- + getStmResultsFilePath () + "'" );
333+ private static final String COBERTURA_MODEL_COVERAGE_PATH = "CoberturaModelCoveragePath" ;
334+
335+ @ DataBoundConstructor
336+ public ModelCovArtifact (String modelCoverageFilePath ) {
337+ super (modelCoverageFilePath );
386338 }
387339
388340 @ Override
389- public String getFilePath ( ) {
390- return getStmResultsFilePath ( );
341+ public void addFilePathArgTo ( Map < String , String > inputArgs ) {
342+ inputArgs . put ( COBERTURA_MODEL_COVERAGE_PATH , getFilePath () );
391343 }
392344 }
393345
394- public static class ModelCovArtifact extends Artifact {
395- private String modelCoverageFilePath ;
346+ public static class NullArtifact implements Artifact {
396347
397- @ DataBoundConstructor
398- public ModelCovArtifact () {
399-
400- }
401-
402- @ DataBoundSetter
403- public void setModelCoverageFilePath (String modelCoverageFilePath ) {
404- this .modelCoverageFilePath = modelCoverageFilePath ;
405- }
348+ @ Override
349+ public void addFilePathArgTo (Map <String , String > inputArgs ) {
406350
407- public String getModelCoverageFilePath () {
408- return modelCoverageFilePath ;
409351 }
410352
411353 @ Override
412- public void addFilePathArgTo (List <String > inputArgs ) {
413- inputArgs .add (MatlabBuilderConstants .COBERTURA_MODEL_COVERAGE_PATH + "," + "'"
414- + getModelCoverageFilePath () + "'" );
354+ public boolean getDefault () {
355+ return false ;
415356 }
416357
417358 @ Override
418359 public String getFilePath () {
419-
420- return getModelCoverageFilePath ();
360+ return null ;
421361 }
362+
422363 }
423-
424- public static class NullArtifact extends Artifact {
425364
426- @ DataBoundConstructor
427- public NullArtifact () {
365+ public static abstract class AbstractArtifactImpl implements Artifact {
428366
429- }
430-
431- @ Override
432- public void addFilePathArgTo (List <String > inputArgs ) {
367+ private String filePath ;
433368
369+ protected AbstractArtifactImpl (String path ) {
370+ this .filePath = path ;
434371 }
435372
436- @ Override
437373 public boolean getDefault () {
438- return false ;
374+ return true ;
375+ }
376+
377+ public void setFilePath (String path ) {
378+ this .filePath = path ;
439379 }
440380
441- @ Override
442381 public String getFilePath () {
443- return null ;
382+ return this . filePath ;
444383 }
445384 }
446385
447-
448- public static abstract class Artifact {
449- public abstract void addFilePathArgTo (List <String > inputArgs );
450386
451- public abstract String getFilePath ();
387+ public interface Artifact {
388+ public void addFilePathArgTo (Map <String , String > inputArgs );
452389
453- public boolean getDefault () {
454- return true ;
455- }
390+ public String getFilePath ();
391+
392+ public boolean getDefault ();
456393 }
457394}
0 commit comments