Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ProjectModelResolverTest extends AbstractMavenProjectTestCase {
}

@Test
void testResolveParentThrowsUnresolvableModelExceptionWhenNotFound() throws Exception {
void testResolveParentThrowsUnresolvableModelExceptionWhenNotFound() {
final Parent parent = new Parent();
parent.setGroupId("org.apache");
parent.setArtifactId("apache");
Expand All @@ -70,7 +70,7 @@ void testResolveParentThrowsUnresolvableModelExceptionWhenNotFound() throws Exce
}

@Test
void testResolveParentThrowsUnresolvableModelExceptionWhenNoMatchingVersionFound() throws Exception {
void testResolveParentThrowsUnresolvableModelExceptionWhenNoMatchingVersionFound() {
final Parent parent = new Parent();
parent.setGroupId("org.apache");
parent.setArtifactId("apache");
Expand All @@ -84,7 +84,7 @@ void testResolveParentThrowsUnresolvableModelExceptionWhenNoMatchingVersionFound
}

@Test
void testResolveParentThrowsUnresolvableModelExceptionWhenUsingRangesWithoutUpperBound() throws Exception {
void testResolveParentThrowsUnresolvableModelExceptionWhenUsingRangesWithoutUpperBound() {
final Parent parent = new Parent();
parent.setGroupId("org.apache");
parent.setArtifactId("apache");
Expand All @@ -97,6 +97,22 @@ void testResolveParentThrowsUnresolvableModelExceptionWhenUsingRangesWithoutUppe
assertEquals("The requested parent version range '[1,)' does not specify an upper bound", e.getMessage());
}

@Test
void testResolveParentThrowsUnresolvableModelExceptionWhenUsingWrongRangeFormat() {
final Parent parent = new Parent();
parent.setGroupId("org.apache");
parent.setArtifactId("apache");
parent.setVersion("[1:2)");

UnresolvableModelException e = assertThrows(
UnresolvableModelException.class,
() -> newModelResolver().resolveModel(parent),
"Expected 'UnresolvableModelException' not thrown.");
assertEquals(
"Failed to resolve version range for org.apache:apache:pom:[1:2): Invalid version range [1:2), single version must be surrounded by []",
e.getMessage());
}

@Test
void testResolveParentSuccessfullyResolvesExistingParentWithoutRange() throws Exception {
final Parent parent = new Parent();
Expand All @@ -120,7 +136,7 @@ void testResolveParentSuccessfullyResolvesExistingParentUsingHighestVersion() th
}

@Test
void testResolveDependencyThrowsUnresolvableModelExceptionWhenNotFound() throws Exception {
void testResolveDependencyThrowsUnresolvableModelExceptionWhenNotFound() {
final Dependency dependency = new Dependency();
dependency.setGroupId("org.apache");
dependency.setArtifactId("apache");
Expand All @@ -135,7 +151,7 @@ void testResolveDependencyThrowsUnresolvableModelExceptionWhenNotFound() throws
}

@Test
void testResolveDependencyThrowsUnresolvableModelExceptionWhenNoMatchingVersionFound() throws Exception {
void testResolveDependencyThrowsUnresolvableModelExceptionWhenNoMatchingVersionFound() {
final Dependency dependency = new Dependency();
dependency.setGroupId("org.apache");
dependency.setArtifactId("apache");
Expand All @@ -149,7 +165,7 @@ void testResolveDependencyThrowsUnresolvableModelExceptionWhenNoMatchingVersionF
}

@Test
void testResolveDependencyThrowsUnresolvableModelExceptionWhenUsingRangesWithoutUpperBound() throws Exception {
void testResolveDependencyThrowsUnresolvableModelExceptionWhenUsingRangesWithoutUpperBound() {
final Dependency dependency = new Dependency();
dependency.setGroupId("org.apache");
dependency.setArtifactId("apache");
Expand All @@ -162,6 +178,22 @@ void testResolveDependencyThrowsUnresolvableModelExceptionWhenUsingRangesWithout
assertEquals("The requested dependency version range '[1,)' does not specify an upper bound", e.getMessage());
}

@Test
void testResolveDependencyThrowsUnresolvableModelExceptionWhenUsingWrongRangeFormat() {
final Dependency dependency = new Dependency();
dependency.setGroupId("org.apache");
dependency.setArtifactId("apache");
dependency.setVersion("[2:3)");

UnresolvableModelException e = assertThrows(
UnresolvableModelException.class,
() -> newModelResolver().resolveModel(dependency),
"Expected 'UnresolvableModelException' not thrown.");
assertEquals(
"Failed to resolve version range for org.apache:apache:pom:[2:3): Invalid version range [2:3), single version must be surrounded by []",
e.getMessage());
}

@Test
void testResolveDependencySuccessfullyResolvesExistingDependencyWithoutRange() throws Exception {
final Dependency dependency = new Dependency();
Expand Down
Loading