Skip to content

Commit

Permalink
Javadocs: Simplify asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
thescouser89 committed Sep 4, 2020
1 parent ae5fe05 commit 9d5f00c
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ public void isEnvDriverEnabled() throws CoreException, ConfigurationParseExcepti
OpenshiftEnvironmentDriverModuleConfig openShiftConfig = configuration
.getModuleConfig(new PncConfigProvider<>(OpenshiftEnvironmentDriverModuleConfig.class));

Assert.assertTrue("Environment driver disabled.", !openShiftConfig.isDisabled());
Assert.assertFalse("Environment driver disabled.", openShiftConfig.isDisabled());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ public void testRepositoryCreationSearchPredicates() {
String scmUrl = "repo";
repositoryConfigurations = searchForRepositoryConfigurations(scmUrl);
// expect
Assert.assertTrue("Repository configuration was not found.", !repositoryConfigurations.isEmpty());
Assert.assertFalse("Repository configuration was not found.", repositoryConfigurations.isEmpty());

// when
scmUrl = "repoX";
Expand All @@ -413,31 +413,31 @@ public void testRepositoryCreationSearchPredicates() {
scmUrl = "ssh://internal.repo.com/repo.git";
repositoryConfigurations = searchForRepositoryConfigurations(scmUrl);
// expect
Assert.assertTrue("Repository configuration was not found.", !repositoryConfigurations.isEmpty());
Assert.assertFalse("Repository configuration was not found.", repositoryConfigurations.isEmpty());

// when
scmUrl = "http://internal.repo.com/repo.git";
repositoryConfigurations = searchForRepositoryConfigurations(scmUrl);
// expect
Assert.assertTrue("Repository configuration was not found.", !repositoryConfigurations.isEmpty());
Assert.assertFalse("Repository configuration was not found.", repositoryConfigurations.isEmpty());

// when
repositoryConfigurations = repositoryConfigurationRepository
.queryWithPredicates(RepositoryConfigurationPredicates.withExactInternalScmRepoUrl(internalUrl));
// expect
Assert.assertTrue("Repository configuration was not found.", !repositoryConfigurations.isEmpty());
Assert.assertFalse("Repository configuration was not found.", repositoryConfigurations.isEmpty());

// when
repositoryConfigurations = repositoryConfigurationRepository.queryWithPredicates(
RepositoryConfigurationPredicates.withInternalScmRepoUrl("ssh://internal.repo.com/repo"));
// expect
Assert.assertTrue("Repository configuration was not found.", !repositoryConfigurations.isEmpty());
Assert.assertFalse("Repository configuration was not found.", repositoryConfigurations.isEmpty());

// when
repositoryConfigurations = repositoryConfigurationRepository.queryWithPredicates(
RepositoryConfigurationPredicates.withExternalScmRepoUrl("http://github.com/external/repo.git"));
// expect
Assert.assertTrue("Repository configuration was not found.", !repositoryConfigurations.isEmpty());
Assert.assertFalse("Repository configuration was not found.", repositoryConfigurations.isEmpty());

// when
repositoryConfigurations = repositoryConfigurationRepository.queryWithPredicates(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public void shouldExtractReposFromString() {

List<ArtifactRepository> repos = driver.extractExtraRepositoriesFromGenericParameters(genericParams);
assertEquals(2, repos.size());
assertTrue("http://central.maven.org/maven2/".equals(repos.get(0).getUrl()));
assertTrue("central-maven-org".equals(repos.get(0).getId()));
assertTrue("https://maven.repository.redhat.com/ga/".equals(repos.get(1).getUrl()));
assertTrue("maven-repository-redhat-com".equals(repos.get(1).getId()));
assertEquals("http://central.maven.org/maven2/", repos.get(0).getUrl());
assertEquals("central-maven-org", repos.get(0).getId());
assertEquals("https://maven.repository.redhat.com/ga/", repos.get(1).getUrl());
assertEquals("maven-repository-redhat-com", repos.get(1).getId());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
import java.util.Collections;

import org.jboss.pnc.enums.RepositoryType;

import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

Expand Down Expand Up @@ -105,7 +107,7 @@ public void testIndyPromotionValidation() {

RepositoryManagerResult repositoryManagerResult = repositorySession.extractBuildArtifacts(true);
// Just a dummy check, the point is really to be able to debug this
assertTrue(CompletionStatus.FAILED == repositoryManagerResult.getCompletionStatus());
assertSame(CompletionStatus.FAILED, repositoryManagerResult.getCompletionStatus());
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
7 changes: 4 additions & 3 deletions model/src/test/java/org/jboss/pnc/model/ArtifactTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

Expand Down Expand Up @@ -87,7 +88,7 @@ public void shouldAllowDeletionOfTemporaryArtifact() {
em.persist(artifact);
em.getTransaction().commit();
int artifactId = artifact.getId();
assertTrue(artifact.getId() != null);
assertNotNull(artifact.getId());
assertTrue(artifact.getId() != 0);

// when
Expand All @@ -96,7 +97,7 @@ public void shouldAllowDeletionOfTemporaryArtifact() {
em.getTransaction().commit();

// then
assertTrue(em.find(Artifact.class, artifactId) == null);
assertNull(em.find(Artifact.class, artifactId));
}

@Test
Expand All @@ -116,7 +117,7 @@ public void shouldAllowDeletionOfDeletedQualityArtifacts() {
em.getTransaction().commit();

// then
assertTrue(em.find(Artifact.class, artifactId) == null);
assertNull(em.find(Artifact.class, artifactId));
}

private void insertBasicTargetRepository() {
Expand Down
3 changes: 2 additions & 1 deletion model/src/test/java/org/jboss/pnc/model/BuildRecordTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

Expand Down Expand Up @@ -110,7 +111,7 @@ public void shouldAllowDeletionOfTemporaryBuild() {
em.getTransaction().commit();

// then
assertTrue(em.find(BuildRecord.class, brId) == null);
assertNull(em.find(BuildRecord.class, brId));
}

private BuildRecord.Builder prepareBuildRecordBuilder() {
Expand Down
22 changes: 11 additions & 11 deletions model/src/test/java/org/jboss/pnc/model/ModelValidationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,55 +51,55 @@ public void testVersionStringValidation() throws Exception {

// Test validation of product version
Set<ConstraintViolation<ProductVersion>> productVersionViolations = validator.validate(productVersion);
Assert.assertTrue(productVersionViolations.size() == 0);
Assert.assertEquals(0, productVersionViolations.size());

productVersion.setVersion("1.0.x");
productVersionViolations = validator.validate(productVersion);
Assert.assertTrue(productVersionViolations.size() == 1);
Assert.assertEquals(1, productVersionViolations.size());

productVersion.setVersion("foo");
productVersionViolations = validator.validate(productVersion);
Assert.assertTrue(productVersionViolations.size() == 1);
Assert.assertEquals(1, productVersionViolations.size());

// Test product milestone versions
ProductMilestone milestone = ProductMilestone.Builder.newBuilder()
.productVersion(productVersion)
.version("1.0.0.ER1")
.build();
Set<ConstraintViolation<ProductMilestone>> milestoneVersionViolations = validator.validate(milestone);
Assert.assertTrue(milestoneVersionViolations.size() == 0);
Assert.assertEquals(0, milestoneVersionViolations.size());

milestone.setVersion("1.0");
milestoneVersionViolations = validator.validate(milestone);
Assert.assertTrue(milestoneVersionViolations.size() == 1);
Assert.assertEquals(1, milestoneVersionViolations.size());

milestone.setVersion("1.0-DR1");
milestoneVersionViolations = validator.validate(milestone);
Assert.assertTrue(milestoneVersionViolations.size() == 1);
Assert.assertEquals(1, milestoneVersionViolations.size());

milestone.setVersion("1.0-x");
milestoneVersionViolations = validator.validate(milestone);
Assert.assertTrue(milestoneVersionViolations.size() == 1);
Assert.assertEquals(1, milestoneVersionViolations.size());

// Test product release versions
ProductRelease release = ProductRelease.Builder.newBuilder()
.productMilestone(milestone)
.version("1.0.0.GA")
.build();
Set<ConstraintViolation<ProductRelease>> releaseVersionViolations = validator.validate(release);
Assert.assertTrue(releaseVersionViolations.size() == 0);
Assert.assertEquals(0, releaseVersionViolations.size());

release.setVersion("1.0");
releaseVersionViolations = validator.validate(release);
Assert.assertTrue(releaseVersionViolations.size() == 1);
Assert.assertEquals(1, releaseVersionViolations.size());

release.setVersion("1.0-DR1");
releaseVersionViolations = validator.validate(release);
Assert.assertTrue(releaseVersionViolations.size() == 1);
Assert.assertEquals(1, releaseVersionViolations.size());

release.setVersion("1.0-x");
releaseVersionViolations = validator.validate(release);
Assert.assertTrue(releaseVersionViolations.size() == 1);
Assert.assertEquals(1, releaseVersionViolations.size());

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void loadIndyRepoDriverConfigTest() throws ConfigurationParseException {

assertNotNull(indyDriverConfig);
assertEquals(100, indyDriverConfig.getDefaultRequestTimeout().intValue());
assertEquals(true, indyDriverConfig.getBuildRepositoryAllowSnapshots().booleanValue());
assertTrue(indyDriverConfig.getBuildRepositoryAllowSnapshots().booleanValue());
assertEquals(0, indyDriverConfig.getIgnoredPathPatterns().getData().getMaven().getPatterns().size());
assertEquals(0, indyDriverConfig.getIgnoredPathPatterns().getData().getNpm().getPatterns().size());
assertEquals(0, indyDriverConfig.getIgnoredPathPatterns().getPromotion().getNpm().getPatterns().size());
Expand Down Expand Up @@ -76,7 +76,7 @@ public void checkDefaultValuesLoadedProperly() throws ConfigurationParseExceptio

assertNotNull(mavenConfig);
assertEquals(600, mavenConfig.getDefaultRequestTimeout().intValue());
assertEquals(false, mavenConfig.getBuildRepositoryAllowSnapshots().booleanValue());
assertFalse(mavenConfig.getBuildRepositoryAllowSnapshots().booleanValue());
}

}

0 comments on commit 9d5f00c

Please sign in to comment.