Skip to content

Commit

Permalink
Merge pull request #70 from robstoll/master
Browse files Browse the repository at this point in the history
Regressiontest for #69
  • Loading branch information
robstoll authored Aug 23, 2018
2 parents db4246c + f9603a7 commit 9628cb1
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void test02()
//arrange
Session session = new Session();
//act
runFullRecursiveAnalysis(session, "testSets/set02");
PomAnalysis pomAnalysis = runFullRecursiveAnalysis( session, "testSets/set02" );
//assert
assertProjects(session, 5);
assertDependencies(session, PROJECT_A, new GavIsSelfManaged( PROJECT_B, true ));
Expand All @@ -66,7 +66,7 @@ public void test02()
);
assertDependencies(session, PROJECT_D, 0);
assertDependencies(session, PROJECT_E, 0);
assertNoNullGavs(session);
assertNoNullGavsNoErroneousPoms(session, pomAnalysis);
}

@Test
Expand All @@ -75,7 +75,7 @@ public void test03()
//arrange
Session session = new Session();
//act
runFullRecursiveAnalysis(session, "testSets/set03");
PomAnalysis pomAnalysis =runFullRecursiveAnalysis(session, "testSets/set03");
//assert
assertProjects(session, 4);
assertDependencies(session, PROJECT_A,
Expand All @@ -86,7 +86,7 @@ public void test03()
assertDependenciesManagement(session, PROJECT_B, new GavIsSelfManaged( PROJECT_D, true ));
assertDependencies(session, PROJECT_C, new GavIsSelfManaged( PROJECT_D, true ));
assertDependencies(session, PROJECT_D, 0);
assertNoNullGavs(session);
assertNoNullGavsNoErroneousPoms(session, pomAnalysis);
}

@Test
Expand All @@ -95,7 +95,7 @@ public void test04()
//arrange
Session session = new Session();
//act
runFullRecursiveAnalysis(session, "testSets/set04");
PomAnalysis pomAnalysis =runFullRecursiveAnalysis(session, "testSets/set04");
//assert
assertProjects(session, 4);
assertDependencies(session, PROJECT_A,
Expand All @@ -106,7 +106,7 @@ public void test04()
assertDependenciesManagement(session, PROJECT_B, new GavIsSelfManaged( PROJECT_D, true ));
assertDependencies(session, PROJECT_C, new GavIsSelfManaged( "fr.lteconsulting:toto:1.4-SNAPSHOT", true ));
assertDependencies(session, PROJECT_D, 0);
assertNoNullGavs(session);
assertNoNullGavsNoErroneousPoms(session, pomAnalysis);
}

@Test
Expand All @@ -115,7 +115,7 @@ public void dependencyWithExclusion()
//arrange
Session session = new Session();
//act
runFullRecursiveAnalysis(session, "testSets/dependencyWithExclusion");
PomAnalysis pomAnalysis =runFullRecursiveAnalysis(session, "testSets/dependencyWithExclusion");
//assert
assertProjects(session, 4);
assertDependencies(session, PROJECT_A,
Expand All @@ -126,7 +126,7 @@ public void dependencyWithExclusion()
assertDependenciesManagement(session, PROJECT_B, new GavIsSelfManaged( PROJECT_D, true ));
assertDependencies(session, PROJECT_C, new GavIsSelfManaged( "fr.lteconsulting:toto:1.4-SNAPSHOT", true ));
assertDependencies(session, PROJECT_D, 1);
assertNoNullGavs(session);
assertNoNullGavsNoErroneousPoms(session, pomAnalysis);

assertDependencyHasExclusion(session, PROJECT_A, PROJECT_B, PROJECT_D);
assertThat(session.projects().forGav(Gav.parse(PROJECT_D)).getUnresolvedProperties()).containsExactly( "unknown" );
Expand All @@ -138,7 +138,7 @@ public void dependencyManagementWithExclusion()
//arrange
Session session = new Session();
//act
runFullRecursiveAnalysis(session, "testSets/dependencyManagementWithExclusion");
PomAnalysis pomAnalysis =runFullRecursiveAnalysis(session, "testSets/dependencyManagementWithExclusion");
//assert
assertProjects(session, 4);
assertDependencies(session, PROJECT_A,
Expand All @@ -149,7 +149,7 @@ public void dependencyManagementWithExclusion()
assertDependenciesManagement(session, PROJECT_B, new GavIsSelfManaged( PROJECT_D, true ));
assertDependencies(session, PROJECT_C, new GavIsSelfManaged( "fr.lteconsulting:toto:1.4-SNAPSHOT", true ));
assertDependencies(session, PROJECT_D, 0);
assertNoNullGavs(session);
assertNoNullGavsNoErroneousPoms(session, pomAnalysis);

assertDependencyManagementHasExclusion(session, PROJECT_A, PROJECT_B, PROJECT_D);
}
Expand Down Expand Up @@ -289,7 +289,7 @@ public void multiModule()
//arrange
Session session = new Session();
//act
runFullRecursiveAnalysis(session, "testSets/multiModule_inSubfolders");
PomAnalysis pomAnalysis = runFullRecursiveAnalysis(session, "testSets/multiModule_inSubfolders");
//assert
assertProjects(session, 6);
assertDependencies(session, PROJECT_A, 0);
Expand Down Expand Up @@ -320,7 +320,7 @@ public void multiModule()
assertParentDependency(session, PROJECT_D, PROJECT_A);
assertDependencies(session, PROJECT_E, new GavIsSelfManaged( PROJECT_F, true ));
assertDependencies(session, PROJECT_F, 0);
assertNoNullGavs(session);
assertNoNullGavsNoErroneousPoms(session, pomAnalysis);
}


Expand All @@ -330,14 +330,15 @@ public void getSubmodules_submodulesInSubFolders()
//arrange
Session session = new Session();
//act
runFullRecursiveAnalysis(session, "testSets/multiModule_inSubfolders");
PomAnalysis pomAnalysis = runFullRecursiveAnalysis(session, "testSets/multiModule_inSubfolders");
//assert
assertProjects(session, 6);
assertSubmodules(session, PROJECT_A,
PROJECT_B,
PROJECT_C,
PROJECT_D
);
assertNoNullGavsNoErroneousPoms(session, pomAnalysis);
}


Expand All @@ -347,14 +348,15 @@ public void getSubmodules_submodulesInSameFolder()
//arrange
Session session = new Session();
//act
runFullRecursiveAnalysis(session, "testSets/multiModule_inSameFolder");
PomAnalysis pomAnalysis = runFullRecursiveAnalysis(session, "testSets/multiModule_inSameFolder");
//assert
assertProjects(session, 6);
assertSubmodules(session, PROJECT_A,
PROJECT_B,
PROJECT_C,
PROJECT_D
);
assertNoNullGavsNoErroneousPoms(session, pomAnalysis);
}

@Test
Expand All @@ -363,11 +365,12 @@ public void getSubmodules_submoduleIsAlsoMultiModule()
//arrange
Session session = new Session();
//act
runFullRecursiveAnalysis(session, "testSets/multiModule_nested");
PomAnalysis pomAnalysis = runFullRecursiveAnalysis(session, "testSets/multiModule_nested");
//assert
assertProjects(session, 6);
assertSubmodules(session, PROJECT_A, PROJECT_B, PROJECT_C );
assertSubmodules(session, PROJECT_B, PROJECT_D );
assertNoNullGavsNoErroneousPoms(session, pomAnalysis);
}

@Test
Expand All @@ -376,7 +379,7 @@ public void pomDependency()
//arrange
Session session = new Session();
//act
runFullRecursiveAnalysis(session, "testSets/pomDependency");
PomAnalysis pomAnalysis = runFullRecursiveAnalysis(session, "testSets/pomDependency");
//assert
assertProjects(session, 6);
assertDependencies(session, PROJECT_A, 0);
Expand All @@ -389,7 +392,7 @@ public void pomDependency()
assertParentDependency(session, PROJECT_D, PROJECT_A);
assertDependencies(session, PROJECT_E, 1);
assertDependencies(session, PROJECT_F, 0);
assertNoNullGavs(session);
assertNoNullGavsNoErroneousPoms(session, pomAnalysis);
}

@Test
Expand All @@ -398,14 +401,14 @@ public void bomDependency()
//arrange
Session session = new Session();
//act
runFullRecursiveAnalysis(session, "testSets/bomDependency");
PomAnalysis pomAnalysis = runFullRecursiveAnalysis(session, "testSets/bomDependency");
//assert
assertProjects(session, 3);
assertDependencies(session, PROJECT_A, 0);
assertDependencies(session, PROJECT_B, new GavIsSelfManaged(PROJECT_A, false));
assertDependenciesManagement(session, PROJECT_B, new GavIsSelfManaged(PROJECT_C, true));
assertDependenciesManagement(session, PROJECT_C, new GavIsSelfManaged(PROJECT_A, true));
assertNoNullGavs(session);
assertNoNullGavsNoErroneousPoms(session, pomAnalysis);
}

@Test
Expand All @@ -414,14 +417,14 @@ public void bomDependencyProjectVersion()
//arrange
Session session = new Session();
//act
runFullRecursiveAnalysis(session, "testSets/bomDependencyProjectVersion");
PomAnalysis pomAnalysis = runFullRecursiveAnalysis(session, "testSets/bomDependencyProjectVersion");
//assert
assertProjects(session, 3);
assertDependencies(session, PROJECT_A, 0);
assertDependencies(session, PROJECT_B_2, new GavIsSelfManaged(PROJECT_A_3, false));
assertDependenciesManagement(session, PROJECT_B_2, new GavIsSelfManaged(PROJECT_C_3, true));
assertDependenciesManagement(session, PROJECT_C_3, new GavIsSelfManaged(PROJECT_A_3, true));
assertNoNullGavs(session);
assertNoNullGavsNoErroneousPoms(session, pomAnalysis);
}

@Test
Expand All @@ -430,14 +433,14 @@ public void bomDependency_dependencyToItself()
//arrange
Session session = new Session();
//act
runFullRecursiveAnalysis(session, "testSets/bomDependencyWithSelfDependency");
PomAnalysis pomAnalysis = runFullRecursiveAnalysis(session, "testSets/bomDependencyWithSelfDependency");
//assert
assertProjects(session, 3);
assertDependencies(session, PROJECT_A, 0);
assertDependencies(session, PROJECT_B, new GavIsSelfManaged(PROJECT_A, false));
assertDependenciesManagement(session, PROJECT_B, new GavIsSelfManaged(PROJECT_C, true));
assertDependenciesManagement(session, PROJECT_C, new GavIsSelfManaged(PROJECT_A, true));
assertNoNullGavs(session);
assertNoNullGavsNoErroneousPoms(session, pomAnalysis);
}

@Test
Expand All @@ -446,15 +449,15 @@ public void bomDependencyInParent()
//arrange
Session session = new Session();
//act
runFullRecursiveAnalysis(session, "testSets/bomDependencyInParent");
PomAnalysis pomAnalysis = runFullRecursiveAnalysis(session, "testSets/bomDependencyInParent");
//assert
assertProjects(session, 4);
assertDependencies(session, PROJECT_A, 0);
assertDependencies(session, PROJECT_B, new GavIsSelfManaged(PROJECT_A, false));
assertDependenciesManagement(session, PROJECT_B, new GavIsSelfManaged(PROJECT_C, true));
assertDependenciesManagement(session, PROJECT_C, new GavIsSelfManaged(PROJECT_A, true));
assertDependenciesManagement(session, PROJECT_D, new GavIsSelfManaged(PROJECT_A, false));
assertNoNullGavs(session);
assertNoNullGavsNoErroneousPoms(session, pomAnalysis);
}

@Test
Expand All @@ -463,7 +466,7 @@ public void versionInUnresolvedParent()
//arrange
Session session = new Session();
//act
PomAnalysis.runFullRecursiveAnalysis("testSets/versionInUnresolvedParent", session, new DefaultPomFileLoader( session, false ), null, true, System.out::println);
PomAnalysis pomAnalysis = PomAnalysis.runFullRecursiveAnalysis("testSets/versionInUnresolvedParent", session, new DefaultPomFileLoader( session, false ), null, true, System.out::println);
//assert
assertProjects(session, 3);
assertDependencies(session, PROJECT_A, 0);
Expand All @@ -477,7 +480,8 @@ public void versionInUnresolvedParent()
new GavIsSelfManaged("fr.lteconsulting:b:null", false),
new GavIsSelfManaged("fr.lteconsulting:b:null", false)
);
assertNullGavs(session, 1);
assertNullGavs( session, 1 );
assertNoErronousPomFiles( pomAnalysis);
}

@Test
Expand Down Expand Up @@ -546,6 +550,36 @@ public void pomWithoutVersion()
}


@Ignore("Regressiontest for #69")
@Test
public void pomWithPropertyAsVersion()
{
//arrange
Session session = new Session();
//act
PomAnalysis pomAnalysis = runFullRecursiveAnalysis(session, "testSets/pomWithPropertyAsVersion");
//assert
assertProjects(session, 1);
assertDependencies(session, PROJECT_A, 0);
assertParentDependency(session, PROJECT_B_2, PROJECT_A);
assertNoNullGavsNoErroneousPoms(session, pomAnalysis);
}

@Ignore("Regressiontest for #69")
@Test
public void pomWithTwoPropertiesAsVersion()
{
//arrange
Session session = new Session();
//act
PomAnalysis pomAnalysis = runFullRecursiveAnalysis(session, "testSets/pomWithTwoPropertiesAsVersion");
//assert
assertProjects(session, 1);
assertDependencies(session, PROJECT_A, 0);
assertParentDependency(session, PROJECT_B_2, PROJECT_A);
assertNoNullGavsNoErroneousPoms(session, pomAnalysis);
}

@Test
public void localTest1()
{
Expand Down Expand Up @@ -696,7 +730,17 @@ private void assertBuildDependencies(Session session, String gavString, int numb
private void assertParentDependency(Session session, String gavString, String parentGav)
{
Gav parent = session.graph().read().parent(Gav.parse(gavString));
assertEquals("parent dependency of " + gavString, parent, Gav.parse(parentGav));
assertEquals("parent dependency of " + gavString, Gav.parse(parentGav), parent);
}

private void assertNoNullGavsNoErroneousPoms( Session session, PomAnalysis pomAnalysis ){
assertNoNullGavs( session );
assertNoErronousPomFiles( pomAnalysis );
}

private void assertNoErronousPomFiles( PomAnalysis pomAnalysis )
{
assertThat(pomAnalysis.getErroneousPomFiles()).isEmpty();
}

private void assertNoNullGavs(Session session)
Expand Down
15 changes: 15 additions & 0 deletions pom-explorer-core/testSets/pomWithPropertyAsVersion/a.pom
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>

<project>
<modelVersion>4.0.0</modelVersion>

<groupId>fr.lteconsulting</groupId>
<artifactId>b</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<xxx.version>2.0-SNAPSHOT</xxx.version>
</properties>


</project>
14 changes: 14 additions & 0 deletions pom-explorer-core/testSets/pomWithPropertyAsVersion/b.pom
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<project>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>fr.lteconsulting</groupId>
<artifactId>a</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>b</artifactId>
<version>${xxx.version}</version>

</project>
17 changes: 17 additions & 0 deletions pom-explorer-core/testSets/pomWithTwoPropertiesAsVersion/a.pom
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>

<project>
<modelVersion>4.0.0</modelVersion>

<groupId>fr.lteconsulting</groupId>
<artifactId>b</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<major.version>2</major.version>
<minor.version>0</minor.version>
<version.suffix>-SNAPSHOT</version.suffix>
</properties>


</project>
14 changes: 14 additions & 0 deletions pom-explorer-core/testSets/pomWithTwoPropertiesAsVersion/b.pom
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<project>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>fr.lteconsulting</groupId>
<artifactId>a</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>b</artifactId>
<version>${major.version}.${minor.version}${version.suffix}</version>

</project>

0 comments on commit 9628cb1

Please sign in to comment.