Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
updated the setSkip function to be more extensible
Browse files Browse the repository at this point in the history
Signed-off-by: Fiona Ampofo <[email protected]>
  • Loading branch information
Akyiaa committed Feb 21, 2024
1 parent ae88999 commit cbf3f47
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,37 +33,42 @@ public class DeployTestCatalog extends AbstractMojo {
@Parameter(defaultValue = "${project}", readonly = true)
private MavenProject project;


@Parameter(defaultValue = "${galasa.skip.deploytestcatatlog}", readonly = true, required = false)
private boolean skipDeploy;

@Parameter(defaultValue = "${galasa.test.stream}", readonly = true, required = false)
private String testStream;

@Parameter(defaultValue = "${galasa.bootstrap}", readonly = true, required = false)
private URL bootstrapUrl;

protected boolean skip;
private boolean skip;
private boolean skipDeploy;

@Parameter(defaultValue = "${galasa.skip.bundletestcatalog}", readonly = true, required = false)
protected boolean typoSkip;
private boolean typoSkip;

@Parameter(defaultValue = "${galasa.skip.bundletestcatalog}", readonly = true, required = false)
protected boolean correctSkip;
private boolean correctSkip;

protected void setSkip() {
@Parameter(defaultValue = "${galasa.skip.deploytestcatatlog}", readonly = true, required = false)
private boolean typoSkipDeploy;

@Parameter(defaultValue = "${galasa.skip.deploytestcatalog}", readonly = true, required = false)
private boolean correctSkipDeploy;


protected boolean setSkip(boolean correctSkip, boolean typoSkip) {
boolean skip = false;
//boolean default value is false
if (correctSkip || typoSkip) {
//if one of the skip variables is set, we know for sure to skip
skip = true;
} else {
skip = false;
}
}
return skip;
}

public void execute() throws MojoExecutionException, MojoFailureException {

setSkip();
skip = setSkip(correctSkip, typoSkip);
skipDeploy = setSkip(correctSkip, typoSkip);

if (skip || skipDeploy) {
getLog().info("Skipping Deploy Test Catalog");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,66 +13,32 @@

public class DeployTestCatalogTest {

private class MockDeployTestCatalog extends DeployTestCatalog{

public boolean getSkip(){
return super.skip;
}

public boolean getTypoSkip() {
return super.typoSkip;
}

public boolean getCorrectSkip() {
return super.correctSkip;
}

private void setUp(boolean typo, boolean correct){
setTypoSkip(this.typoSkip, typo);
setCorrectSkip(this.correctSkip, correct);
}

private void setTypoSkip(boolean typoSkip, boolean typo) {
super.typoSkip = typo;
}
private void setCorrectSkip(boolean correctSkip, boolean correct) {
super.correctSkip = correct;
}

}

@Test
public void setSkipTrueWhenTypoSkipIsTrue() {
//Given...
boolean typoSkip = true;
boolean correctSkip = false;
MockDeployTestCatalog deployTest = new MockDeployTestCatalog();
deployTest.setUp(typoSkip, correctSkip);
DeployTestCatalog deployTest = new DeployTestCatalog();

//When...
deployTest.setSkip();
boolean skipResult = deployTest.setSkip(correctSkip, typoSkip);

//Then...
assertThat(deployTest.getTypoSkip()).isTrue();
assertThat(deployTest.getCorrectSkip()).isFalse();
assertThat(deployTest.getSkip()).isTrue();
assertThat(skipResult).isTrue();
}

@Test
public void setSkipFalseWhenTypoSkipAndCorrectSkipIsFalse() {
//Given...
boolean typoSkip = false;
boolean correctSkip = false;
MockDeployTestCatalog deployTest = new MockDeployTestCatalog();
deployTest.setUp(typoSkip, correctSkip);
DeployTestCatalog deployTest = new DeployTestCatalog();

//When...
deployTest.setSkip();
boolean skipResult = deployTest.setSkip(correctSkip, typoSkip);

//Then...
assertThat(deployTest.getTypoSkip()).isFalse();
assertThat(deployTest.getCorrectSkip()).isFalse();
assertThat(deployTest.getSkip()).isFalse();
assertThat(skipResult).isFalse();
}


Expand All @@ -81,33 +47,27 @@ public void setSkipTrueWhenCorrectSkipIsTrue() {
//Given...
boolean typoSkip = false;
boolean correctSkip = true;
MockDeployTestCatalog deployTest = new MockDeployTestCatalog();
deployTest.setUp(typoSkip, correctSkip);
DeployTestCatalog deployTest = new DeployTestCatalog();

//When...
deployTest.setSkip();
boolean skipResult = deployTest.setSkip(correctSkip, typoSkip);

//Then...
assertThat(deployTest.getTypoSkip()).isFalse();
assertThat(deployTest.getCorrectSkip()).isTrue();
assertThat(deployTest.getSkip()).isTrue();
assertThat(skipResult).isTrue();
}

@Test
public void setSkipTrueWhenCorrectSkipAndTypoSkipIsTrue() {
//Given...
boolean typoSkip = true;
boolean correctSkip = true;
MockDeployTestCatalog deployTest = new MockDeployTestCatalog();
deployTest.setUp(typoSkip, correctSkip);
DeployTestCatalog deployTest = new DeployTestCatalog();

//When...
deployTest.setSkip();
boolean skipResult = deployTest.setSkip(correctSkip, typoSkip);

//Then...
assertThat(deployTest.getTypoSkip()).isTrue();
assertThat(deployTest.getCorrectSkip()).isTrue();
assertThat(deployTest.getSkip()).isTrue();
assertThat(skipResult).isTrue();
}

}

0 comments on commit cbf3f47

Please sign in to comment.