Skip to content

Commit

Permalink
- cleanup test formatting/style
Browse files Browse the repository at this point in the history
  • Loading branch information
JAmes Atwill committed Aug 14, 2014
1 parent c01aad0 commit 4b444c4
Show file tree
Hide file tree
Showing 8 changed files with 385 additions and 389 deletions.
Expand Up @@ -23,9 +23,8 @@
import com.thoughtworks.xstream.io.xml.StaxDriver;

/**
* Some basic plumbing for licensing mojos. I've borrowed
* {@code MavenProjectDependenciesConfigurator} from the license plugin since it
* rocks.
* Some basic plumbing for licensing mojos. I've borrowed {@code MavenProjectDependenciesConfigurator} from the
* license plugin since it rocks.
*
* @see CheckMojo
* @see CollectReportsMojo
Expand Down Expand Up @@ -294,8 +293,7 @@ protected Set<String> collectLicensesForMavenProject(MavenProject mavenProject)
licenses.add(licensingRequirements.getCorrectLicenseName(license.getName()));
}
}

}
}

if (licenses.isEmpty()) {
getLog().debug(
Expand Down
Expand Up @@ -12,38 +12,38 @@

public abstract class AbstractLicensingTest {

protected LicensingRequirements licensingRequirements;
protected MavenProject mavenProject;
protected TestLicensingMojo mojo;
protected LicensingRequirements licensingRequirements;
protected MavenProject mavenProject;
protected TestLicensingMojo mojo;

class TestLicensingMojo extends AbstractLicensingMojo {
class TestLicensingMojo extends AbstractLicensingMojo {

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
@Override
public void execute() throws MojoExecutionException, MojoFailureException {

}
}

public void setLicensingRequirements(LicensingRequirements requirements) {
public void setLicensingRequirements(LicensingRequirements requirements) {
licensingRequirements = requirements;
}
}
}
}

@Before
public void setUp() {
licensingRequirements = new LicensingRequirements();
@Before
public void setUp() {
licensingRequirements = new LicensingRequirements();

mavenProject = new MavenProject();
Model model = mavenProject.getModel();
model.setGroupId("groupdId");
model.setArtifactId("artifactId");
model.setVersion("1.0");
model.setPackaging("jar");
mavenProject = new MavenProject();
Model model = mavenProject.getModel();
model.setGroupId("groupdId");
model.setArtifactId("artifactId");
model.setVersion("1.0");
model.setPackaging("jar");

mavenProject.setLicenses(new ArrayList<License>());
mavenProject.setLicenses(new ArrayList<License>());

mojo = new TestLicensingMojo();
mojo.setLicensingRequirements(licensingRequirements);
mojo = new TestLicensingMojo();
mojo.setLicensingRequirements(licensingRequirements);

}
}

}
Expand Up @@ -9,26 +9,26 @@

public class ArtifactWithLicensesComparisonTest {

/**
* Comparisons for {@code ArtifactWithLicenses} are done solely on the
* artifactId. This way the artifact only shows up once in {@code Set}s.
*/
@Test
public void test() {
ArtifactWithLicenses awl1 = new ArtifactWithLicenses("artifactA");
ArtifactWithLicenses awl2 = new ArtifactWithLicenses("artifactB");

ArtifactWithLicenses awl3 = new ArtifactWithLicenses("artifactA");

assertFalse("ArtifactWithLicenses are compared only on artifactId.", awl1.equals(awl2));
/**
* Comparisons for {@code ArtifactWithLicenses} are done solely on the
* artifactId. This way the artifact only shows up once in {@code Set}s.
*/
@Test
public void test() {
ArtifactWithLicenses awl1 = new ArtifactWithLicenses("artifactA");
ArtifactWithLicenses awl2 = new ArtifactWithLicenses("artifactB");

ArtifactWithLicenses awl3 = new ArtifactWithLicenses("artifactA");

assertFalse("ArtifactWithLicenses are compared only on artifactId.", awl1.equals(awl2));
assertEquals("ArtifactWithLicenses are compared only on artifactId.", awl1, awl3);

awl1.addLicense("one two");
awl2.addLicense("one two");
awl1.addLicense("one two");
awl2.addLicense("one two");

assertFalse("ArtifactWithLicenses are compared only on artifactId.", awl1.equals(awl2));
assertFalse("ArtifactWithLicenses are compared only on artifactId.", awl1.equals(awl2));
Assert.assertEquals("ArtifactWithLicenses are compared only on artifactId.", awl1, awl3);

}
}

}
154 changes: 77 additions & 77 deletions src/test/java/org/linuxstuff/mojo/licensing/CheckForFailureTest.java
Expand Up @@ -7,117 +7,117 @@

public class CheckForFailureTest {

/**
* Ignore all our problems.
*/
@Test
public void testIgnoreEverything() throws MojoFailureException {
/**
* Ignore all our problems.
*/
@Test
public void testIgnoreEverything() throws MojoFailureException {

LicensingReport report = new LicensingReport();
LicensingReport report = new LicensingReport();

CheckMojo mojo = new CheckMojo();
CheckMojo mojo = new CheckMojo();

mojo.failIfDisliked = false;
mojo.failIfMissing = false;
mojo.failIfDisliked = false;
mojo.failIfMissing = false;

report.addMissingLicense(new ArtifactWithLicenses("missing"));
report.addDislikedArtifact(new ArtifactWithLicenses("disliked"));
report.addMissingLicense(new ArtifactWithLicenses("missing"));
report.addDislikedArtifact(new ArtifactWithLicenses("disliked"));

mojo.checkForFailure(report);
}
mojo.checkForFailure(report);
}

/**
* Blow up because of the disliked artifact.
*/
@Test(expected = MojoFailureException.class)
public void testDislkedThrowsException() throws MojoFailureException {
LicensingReport report = new LicensingReport();
/**
* Blow up because of the disliked artifact.
*/
@Test(expected = MojoFailureException.class)
public void testDislkedThrowsException() throws MojoFailureException {
LicensingReport report = new LicensingReport();

CheckMojo mojo = new CheckMojo();
CheckMojo mojo = new CheckMojo();

mojo.failIfDisliked = true;
mojo.failIfMissing = false;
mojo.failIfDisliked = true;
mojo.failIfMissing = false;

report.addDislikedArtifact(new ArtifactWithLicenses("disliked"));
report.addDislikedArtifact(new ArtifactWithLicenses("disliked"));

mojo.checkForFailure(report);
mojo.checkForFailure(report);

}
}

/**
* Blow up because of the artifact with a missing license.
*/
@Test(expected = MojoFailureException.class)
public void testMissingThrowsException() throws MojoFailureException {
LicensingReport report = new LicensingReport();
/**
* Blow up because of the artifact with a missing license.
*/
@Test(expected = MojoFailureException.class)
public void testMissingThrowsException() throws MojoFailureException {
LicensingReport report = new LicensingReport();

CheckMojo mojo = new CheckMojo();
CheckMojo mojo = new CheckMojo();

mojo.failIfDisliked = false;
mojo.failIfMissing = true;
mojo.failIfDisliked = false;
mojo.failIfMissing = true;

report.addMissingLicense(new ArtifactWithLicenses("disliked"));
report.addMissingLicense(new ArtifactWithLicenses("disliked"));

mojo.checkForFailure(report);
mojo.checkForFailure(report);

}
}

/**
* Don't blow up about the disliked artifact (but enable blowing up for
* artifacts missing licenses).
*/
@Test
public void testIgnoreDisliked() throws MojoFailureException {
/**
* Don't blow up about the disliked artifact (but enable blowing up for
* artifacts missing licenses).
*/
@Test
public void testIgnoreDisliked() throws MojoFailureException {

LicensingReport report = new LicensingReport();
LicensingReport report = new LicensingReport();

CheckMojo mojo = new CheckMojo();
CheckMojo mojo = new CheckMojo();

mojo.failIfDisliked = false;
mojo.failIfMissing = true;
mojo.failIfDisliked = false;
mojo.failIfMissing = true;

report.addDislikedArtifact(new ArtifactWithLicenses("disliked"));
report.addDislikedArtifact(new ArtifactWithLicenses("disliked"));

mojo.checkForFailure(report);
}
mojo.checkForFailure(report);
}

/**
* Don't blow up about artifacts missing licenses (but enable blowing up for
* disliked licenses).
*/
@Test
public void testIgnoreMissing() throws MojoFailureException {
/**
* Don't blow up about artifacts missing licenses (but enable blowing up for
* disliked licenses).
*/
@Test
public void testIgnoreMissing() throws MojoFailureException {

LicensingReport report = new LicensingReport();
LicensingReport report = new LicensingReport();

CheckMojo mojo = new CheckMojo();
CheckMojo mojo = new CheckMojo();

mojo.failIfDisliked = true;
mojo.failIfMissing = false;
mojo.failIfDisliked = true;
mojo.failIfMissing = false;

report.addMissingLicense(new ArtifactWithLicenses("missing"));
report.addMissingLicense(new ArtifactWithLicenses("missing"));

mojo.checkForFailure(report);
}
mojo.checkForFailure(report);
}

/**
* Also blow up if *everything* is bad. Technically the user sees a
* different message, but I'm not about to scrape an exception message.
*/
@Test(expected = MojoFailureException.class)
public void testEverythingIsBad() throws MojoFailureException {
/**
* Also blow up if *everything* is bad. Technically the user sees a
* different message, but I'm not about to scrape an exception message.
*/
@Test(expected = MojoFailureException.class)
public void testEverythingIsBad() throws MojoFailureException {

LicensingReport report = new LicensingReport();
LicensingReport report = new LicensingReport();

CheckMojo mojo = new CheckMojo();
CheckMojo mojo = new CheckMojo();

mojo.failIfDisliked = true;
mojo.failIfMissing = true;
mojo.failIfDisliked = true;
mojo.failIfMissing = true;

report.addMissingLicense(new ArtifactWithLicenses("missing"));
report.addDislikedArtifact(new ArtifactWithLicenses("disliked"));
report.addMissingLicense(new ArtifactWithLicenses("missing"));
report.addDislikedArtifact(new ArtifactWithLicenses("disliked"));

mojo.checkForFailure(report);
}
mojo.checkForFailure(report);
}

}

0 comments on commit 4b444c4

Please sign in to comment.