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
@@ -247,149 +254,141 @@ private String getInputArguments() {
247254 *
248255 */
249256 public static class PdfArtifact extends AbstractArtifactImpl {
250-
257+
258+ static final String PDF_REPORT_PATH = "PDFReportPath" ;
259+
251260 @ DataBoundConstructor
252261 public PdfArtifact (String pdfReportFilePath ) {
253- super (pdfReportFilePath );
262+ super (pdfReportFilePath );
254263 }
255-
264+
256265 @ Override
257- public void addFilePathArgTo (List <String > inputArgs ) {
258- inputArgs .add (MatlabBuilderConstants .PDF_REPORT_PATH + "," + "'"
259- + getFilePath () + "'" );
266+ public void addFilePathArgTo (Map <String , String > inputArgs ) {
267+ inputArgs .put (PDF_REPORT_PATH , getFilePath ());
260268 }
261269 }
262270
263271 public static class TapArtifact extends AbstractArtifactImpl {
264272
273+ static final String TAP_RESULTS_PATH = "TAPResultsPath" ;
274+
265275 @ DataBoundConstructor
266276 public TapArtifact (String tapReportFilePath ) {
267277 super (tapReportFilePath );
268- }
269-
278+ }
270279
271280 @ Override
272- public void addFilePathArgTo (List <String > inputArgs ) {
273- inputArgs .add (MatlabBuilderConstants .TAP_RESULTS_PATH + "," + "'"
274- + getFilePath () + "'" );
281+ public void addFilePathArgTo (Map <String , String > inputArgs ) {
282+ inputArgs .put (TAP_RESULTS_PATH , getFilePath ());
275283 }
276-
277284 }
278285
279286 public static class JunitArtifact extends AbstractArtifactImpl {
280287
288+ static final String JUNIT_RESULTS_PATH = "JUnitResultsPath" ;
289+
281290 @ DataBoundConstructor
282291 public JunitArtifact (String junitReportFilePath ) {
283292 super (junitReportFilePath );
284- }
293+ }
285294
286295 @ Override
287- public void addFilePathArgTo (List <String > inputArgs ) {
288- inputArgs .add (MatlabBuilderConstants .JUNIT_RESULTS_PATH + "," + "'"
289- + getFilePath () + "'" );
296+ public void addFilePathArgTo (Map <String , String > inputArgs ) {
297+ inputArgs .put (JUNIT_RESULTS_PATH , getFilePath ());
290298 }
291-
292299 }
293300
294301 public static class CoberturaArtifact extends AbstractArtifactImpl {
295302
303+ static final String COBERTURA_CODE_COVERAGE_PATH = "CoberturaCodeCoveragePath" ;
304+
296305 @ DataBoundConstructor
297306 public CoberturaArtifact (String coberturaReportFilePath ) {
298307 super (coberturaReportFilePath );
299- }
300-
308+ }
301309
302310 @ Override
303- public void addFilePathArgTo (List <String > inputArgs ) {
304- inputArgs .add (MatlabBuilderConstants .COBERTURA_CODE_COVERAGE_PATH + "," + "'"
305- + getFilePath () + "'" );
311+ public void addFilePathArgTo (Map <String , String > inputArgs ) {
312+ inputArgs .put (COBERTURA_CODE_COVERAGE_PATH , getFilePath ());
306313 }
307-
308314 }
309315
310316 public static class StmResultsArtifact extends AbstractArtifactImpl {
311317
318+ static final String STM_RESULTS_PATH = "SimulinkTestResultsPath" ;
319+
312320 @ DataBoundConstructor
313321 public StmResultsArtifact (String stmResultsFilePath ) {
314322 super (stmResultsFilePath );
315- }
316-
317-
323+ }
318324
319325 @ Override
320- public void addFilePathArgTo (List <String > inputArgs ) {
321- inputArgs .add (MatlabBuilderConstants .STM_RESULTS_PATH + "," + "'"
322- + getFilePath () + "'" );
326+ public void addFilePathArgTo (Map <String , String > inputArgs ) {
327+ inputArgs .put (STM_RESULTS_PATH , getFilePath ());
323328 }
324-
325329 }
326330
327331 public static class ModelCovArtifact extends AbstractArtifactImpl {
328332
333+ static final String COBERTURA_MODEL_COVERAGE_PATH = "CoberturaModelCoveragePath" ;
334+
329335 @ DataBoundConstructor
330336 public ModelCovArtifact (String modelCoverageFilePath ) {
331337 super (modelCoverageFilePath );
332- }
333-
338+ }
334339
335340 @ Override
336- public void addFilePathArgTo (List <String > inputArgs ) {
337- inputArgs .add (MatlabBuilderConstants .COBERTURA_MODEL_COVERAGE_PATH + "," + "'"
338- + getFilePath () + "'" );
341+ public void addFilePathArgTo (Map <String , String > inputArgs ) {
342+ inputArgs .put (COBERTURA_MODEL_COVERAGE_PATH , getFilePath ());
339343 }
340-
341344 }
342-
343- public static class NullArtifact implements Artifact {
345+
346+ public static class NullArtifact implements Artifact {
344347
345348 @ Override
346- public void addFilePathArgTo (List < String > inputArgs ) {
349+ public void addFilePathArgTo (Map < String , String > inputArgs ) {
347350
348351 }
349352
350353 @ Override
351354 public boolean getDefault () {
352-
353355 return false ;
354356 }
355357
356358 @ Override
357359 public String getFilePath () {
358-
359360 return null ;
360361 }
361362
362363 }
363-
364- //Andys code
364+
365365 public static abstract class AbstractArtifactImpl implements Artifact {
366366
367367 private String filePath ;
368368
369- protected AbstractArtifactImpl (String path ){
369+ protected AbstractArtifactImpl (String path ) {
370370 this .filePath = path ;
371371 }
372372
373-
374- public boolean getDefault (){
373+ public boolean getDefault () {
375374 return true ;
376375 }
377376
378- public void setFilePath (String path ){
377+ public void setFilePath (String path ) {
379378 this .filePath = path ;
380379 }
381- public String getFilePath (){
380+
381+ public String getFilePath () {
382382 return this .filePath ;
383383 }
384384 }
385385
386-
386+
387387 public interface Artifact {
388- public void addFilePathArgTo (List < String > inputArgs );
388+ public void addFilePathArgTo (Map < String , String > inputArgs );
389389
390390 public String getFilePath ();
391391
392392 public boolean getDefault ();
393- //public List<String> getNameAndValue();
394393 }
395394}
0 commit comments