Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 81bbc38

Browse files
author
Nikhil Bhoski
committed
Final changes for NullObject pattern.
1 parent 275f108 commit 81bbc38

File tree

1 file changed

+20
-82
lines changed

1 file changed

+20
-82
lines changed

src/main/java/com/mathworks/ci/RunMatlabTestsBuilder.java

Lines changed: 20 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import org.kohsuke.stapler.DataBoundConstructor;
1919
import org.kohsuke.stapler.DataBoundSetter;
2020
import org.kohsuke.stapler.StaplerRequest;
21-
import org.w3c.dom.views.AbstractView;
2221
import hudson.EnvVars;
2322
import hudson.Extension;
2423
import hudson.FilePath;
@@ -54,32 +53,32 @@ public RunMatlabTestsBuilder() {
5453

5554

5655
@DataBoundSetter
57-
public void setTapArtifact(Artifact tapArtifact) {
56+
public void setTapArtifact(TapArtifact tapArtifact) {
5857
this.tapArtifact = tapArtifact;
5958
}
6059

6160
@DataBoundSetter
62-
public void setJunitArtifact(Artifact junitArtifact) {
61+
public void setJunitArtifact(JunitArtifact junitArtifact) {
6362
this.junitArtifact = junitArtifact;
6463
}
6564

6665
@DataBoundSetter
67-
public void setCoberturaArtifact(Artifact coberturaArtifact) {
66+
public void setCoberturaArtifact(CoberturaArtifact coberturaArtifact) {
6867
this.coberturaArtifact = coberturaArtifact;
6968
}
7069

7170
@DataBoundSetter
72-
public void setStmResultsArtifact(Artifact stmResultsArtifact) {
71+
public void setStmResultsArtifact(StmResultsArtifact stmResultsArtifact) {
7372
this.stmResultsArtifact = stmResultsArtifact;
7473
}
7574

7675
@DataBoundSetter
77-
public void setModelCoverageArtifact(Artifact modelCoverageArtifact) {
76+
public void setModelCoverageArtifact(ModelCovArtifact modelCoverageArtifact) {
7877
this.modelCoverageArtifact = modelCoverageArtifact;
7978
}
8079

8180
@DataBoundSetter
82-
public void setPdfReportArtifact(Artifact pdfReportArtifact) {
81+
public void setPdfReportArtifact(PdfArtifact pdfReportArtifact) {
8382
this.pdfReportArtifact = pdfReportArtifact;
8483
}
8584

@@ -230,23 +229,12 @@ private String getInputArguments() {
230229
getModelCoverageArtifact()));
231230

232231
for (Artifact artifact : artifactList) {
233-
//addInputArgs(artifact, inputArgs);
234232
artifact.addFilePathArgTo(inputArgs);
235233
}
236234

237-
if (inputArgs.isEmpty()) {
238-
return "";
239-
}
240-
241235
return String.join(",", inputArgs);
242236
}
243237

244-
/*public void addInputArgs(Artifact artifactType, List<String> inputArgs) {
245-
if (artifactType != null) {
246-
artifactType.addFilePathArgTo(inputArgs);
247-
}
248-
}*/
249-
250238

251239
/*
252240
* Classes for each optional block in jelly file.This is restriction from Stapler architecture
@@ -264,7 +252,6 @@ public static class PdfArtifact extends Artifact {
264252
@DataBoundConstructor
265253
public PdfArtifact() {
266254

267-
268255
}
269256

270257
@DataBoundSetter
@@ -286,12 +273,6 @@ public void addFilePathArgTo(List<String> inputArgs) {
286273
public String getFilePath() {
287274
return getPdfReportFilePath();
288275
}
289-
290-
291-
public boolean getDefault() {
292-
293-
return true;
294-
}
295276
}
296277

297278
public static class TapArtifact extends Artifact {
@@ -300,7 +281,6 @@ public static class TapArtifact extends Artifact {
300281
@DataBoundConstructor
301282
public TapArtifact() {
302283

303-
304284
}
305285

306286
@DataBoundSetter
@@ -322,11 +302,6 @@ public void addFilePathArgTo(List<String> inputArgs) {
322302
public String getFilePath() {
323303
return getTapReportFilePath();
324304
}
325-
326-
327-
public boolean getDefault() {
328-
return true;
329-
}
330305
}
331306

332307
public static class JunitArtifact extends Artifact {
@@ -335,7 +310,6 @@ public static class JunitArtifact extends Artifact {
335310
@DataBoundConstructor
336311
public JunitArtifact() {
337312

338-
339313
}
340314

341315
@DataBoundSetter
@@ -357,11 +331,6 @@ public void addFilePathArgTo(List<String> inputArgs) {
357331
public String getFilePath() {
358332
return getJunitReportFilePath();
359333
}
360-
361-
362-
public boolean getDefault() {
363-
return true;
364-
}
365334
}
366335

367336
public static class CoberturaArtifact extends Artifact {
@@ -370,7 +339,6 @@ public static class CoberturaArtifact extends Artifact {
370339
@DataBoundConstructor
371340
public CoberturaArtifact() {
372341

373-
374342
}
375343

376344
@DataBoundSetter
@@ -392,11 +360,6 @@ public void addFilePathArgTo(List<String> inputArgs) {
392360
public String getFilePath() {
393361
return getCoberturaReportFilePath();
394362
}
395-
396-
397-
public boolean getDefault() {
398-
return true;
399-
}
400363
}
401364

402365
public static class StmResultsArtifact extends Artifact {
@@ -405,7 +368,6 @@ public static class StmResultsArtifact extends Artifact {
405368
@DataBoundConstructor
406369
public StmResultsArtifact() {
407370

408-
409371
}
410372

411373
@DataBoundSetter
@@ -427,11 +389,6 @@ public void addFilePathArgTo(List<String> inputArgs) {
427389
public String getFilePath() {
428390
return getStmResultsFilePath();
429391
}
430-
431-
432-
public boolean getDefault() {
433-
return true;
434-
}
435392
}
436393

437394
public static class ModelCovArtifact extends Artifact {
@@ -440,7 +397,6 @@ public static class ModelCovArtifact extends Artifact {
440397
@DataBoundConstructor
441398
public ModelCovArtifact() {
442399

443-
444400
}
445401

446402
@DataBoundSetter
@@ -463,26 +419,21 @@ public String getFilePath() {
463419

464420
return getModelCoverageFilePath();
465421
}
466-
467-
@Override
468-
public boolean getDefault() {
469-
return true;
470-
}
471422
}
472423

473424
public static class NullArtifact extends Artifact {
474-
425+
475426
@DataBoundConstructor
476-
public NullArtifact() {
477-
427+
public NullArtifact() {
428+
478429
}
479430

480431
@Override
481432
public void addFilePathArgTo(List<String> inputArgs) {
482-
433+
483434
}
484-
485-
435+
436+
@Override
486437
public boolean getDefault() {
487438
return false;
488439
}
@@ -491,29 +442,16 @@ public boolean getDefault() {
491442
public String getFilePath() {
492443
return null;
493444
}
494-
495445
}
496-
446+
497447

498-
public static class Artifact {
499-
500-
@DataBoundConstructor
501-
public Artifact() {
502-
503-
}
504-
505-
506-
507-
public void addFilePathArgTo(List<String> inputArgs) {
508-
509-
}
510-
511-
public String getFilePath() {
512-
return null;
513-
}
514-
448+
public static abstract class Artifact {
449+
public abstract void addFilePathArgTo(List<String> inputArgs);
450+
451+
public abstract String getFilePath();
452+
515453
public boolean getDefault() {
516-
return false;
454+
return true;
517455
}
518-
}
456+
}
519457
}

0 commit comments

Comments
 (0)