Broke tests for child pom update

This commit is contained in:
Marcin Grzejszczak
2017-03-06 18:09:25 +01:00
parent 298fb2b004
commit 024f3b3f4b
6 changed files with 264 additions and 0 deletions

View File

@@ -115,6 +115,70 @@ public class PomUpdaterTests {
.containsEntry("spring-cloud-vault.version", "0.0.4.BUILD-SNAPSHOT");
}
@Test
public void should_not_update_child_pom_when_project_is_not_on_the_versions_list() throws Exception {
File springCloudReleasePom = pom("/projects/spring-cloud-release");
then(this.pomUpdater.shouldProjectBeUpdated(springCloudReleasePom, this.versions)).isFalse();
}
@Test
public void should_update_child_pom_when_project_is_not_on_the_versions_list() throws Exception {
File springCloudSleuthPom = pom("/projects/spring-cloud-sleuth");
then(this.pomUpdater.shouldProjectBeUpdated(springCloudSleuthPom, this.versions)).isTrue();
}
@Test
public void should_not_update_the_child_model_if_no_changes_were_made() throws Exception {
File nonMatchingPom = pom("/projects/project");
ModelWrapper model = this.pomUpdater.updatePom(nonMatchingPom, this.versions);
then(model.dirty).isFalse();
}
@Test
public void should_update_the_child_model_if_parent_is_matched_via_sc_build() throws Exception {
File matchingArtifactId = pom("/projects/project/children", "pom_matching_parent_v2.xml");
ModelWrapper model = this.pomUpdater.updatePom(matchingArtifactId, this.versions);
then(model.dirty).isTrue();
then(model.model.getParent().getVersion()).isEqualTo("0.0.3.BUILD-SNAPSHOT");
// the rest is the same
then(model.model.getProperties())
.containsEntry("spring-cloud-foo.version", "1.3.1.BUILD-SNAPSHOT")
.containsEntry("foo.version", "1.2.0.BUILD-SNAPSHOT");
}
@Test
public void should_update_the_child_model_if_parent_is_matched_via_sc_dependencies_parent() throws Exception {
File matchingArtifactId = pom("/projects/project/children", "pom_matching_parent.xml");
ModelWrapper model = this.pomUpdater.updatePom(matchingArtifactId, this.versions);
then(model.dirty).isTrue();
then(model.model.getParent().getVersion()).isEqualTo("0.0.3.BUILD-SNAPSHOT");
// the rest is the same
then(model.model.getProperties())
.containsEntry("spring-cloud-foo.version", "1.3.1.BUILD-SNAPSHOT")
.containsEntry("foo.version", "1.2.0.BUILD-SNAPSHOT");
}
@Test
public void should_update_the_child_model_if_properties_are_matched() throws Exception {
File matchingArtifactId = pom("/projects/project/children", "pom_matching_properties.xml");
ModelWrapper model = this.pomUpdater.updatePom(matchingArtifactId, this.versions);
then(model.dirty).isTrue();
then(model.model.getParent().getVersion()).isEqualTo("0.0.3.BUILD-SNAPSHOT");
then(model.model.getProperties())
.containsEntry("spring-cloud-sleuth.version", "0.0.3.BUILD-SNAPSHOT")
.containsEntry("spring-cloud-vault.version", "0.0.4.BUILD-SNAPSHOT");
}
Set<Project> projects() {
Set<Project> projects = new HashSet<>();
projects.add(new Project("spring-cloud-sleuth", "0.0.3.BUILD-SNAPSHOT"));

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2013-2017 the original author or authors.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>foo</artifactId>
<version>1.2.0.BUILD-SNAPSHOT</version>
<packaging>pom</packaging>
<name>foo</name>
<description>foo</description>
<parent>
<groupId>parentGroup</groupId>
<artifactId>parentArtifactId</artifactId>
<version>1.3.1.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<properties>
<spring-cloud-foo.version>1.3.1.BUILD-SNAPSHOT</spring-cloud-foo.version>
<foo.version>1.2.0.BUILD-SNAPSHOT</foo.version>
</properties>
</project>

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2013-2017 the original author or authors.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-cloud-sleuth-child</artifactId>
<version>1.2.0.BUILD-SNAPSHOT</version>
<packaging>pom</packaging>
<name>foo</name>
<description>foo</description>
<parent>
<groupId>parentGroup</groupId>
<artifactId>parentArtifactId</artifactId>
<version>1.3.1.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<properties>
<spring-cloud-foo.version>1.3.1.BUILD-SNAPSHOT</spring-cloud-foo.version>
<foo.version>1.2.0.BUILD-SNAPSHOT</foo.version>
</properties>
</project>

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2013-2017 the original author or authors.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-cloud-sleuth-child</artifactId>
<version>1.2.0.BUILD-SNAPSHOT</version>
<packaging>pom</packaging>
<name>foo</name>
<description>foo</description>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth</artifactId>
<version>1.3.1.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<properties>
<spring-cloud-foo.version>1.3.1.BUILD-SNAPSHOT</spring-cloud-foo.version>
<foo.version>1.2.0.BUILD-SNAPSHOT</foo.version>
</properties>
</project>

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2013-2017 the original author or authors.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-cloud-sleuth-child</artifactId>
<version>1.2.0.BUILD-SNAPSHOT</version>
<packaging>pom</packaging>
<name>foo</name>
<description>foo</description>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth</artifactId>
<version>1.3.1.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<properties>
<spring-cloud-foo.version>1.3.1.BUILD-SNAPSHOT</spring-cloud-foo.version>
<foo.version>1.2.0.BUILD-SNAPSHOT</foo.version>
</properties>
</project>

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2013-2017 the original author or authors.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-cloud-sleuth-child</artifactId>
<version>1.2.0.BUILD-SNAPSHOT</version>
<packaging>pom</packaging>
<name>foo</name>
<description>foo</description>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth</artifactId>
<version>1.3.1.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<properties>
<spring-cloud-sleuth.version>1.3.1.BUILD-SNAPSHOT</spring-cloud-sleuth.version>
<spring-cloud-vault.version>1.2.0.BUILD-SNAPSHOT</spring-cloud-vault.version>
</properties>
</project>