#144 - Add Calver type.

This commit is contained in:
Mark Paluch
2020-04-30 11:01:35 +02:00
parent 49adb1da2d
commit 7c65952eec
4 changed files with 454 additions and 3 deletions

View File

@@ -0,0 +1,78 @@
/*
* Copyright 2020 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.
*/
package org.springframework.data.release.model;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
/**
* Unit tests for {@link Calver}.
*
* @author Mark Paluch
*/
public class CalverVersionUnitTests {
@Test
public void shouldParseRelease() {
Calver version = Calver.parse("2020.0.1");
assertThat(version.getYear()).isEqualTo(2020);
assertThat(version.getMinor()).isEqualTo(0);
assertThat(version.getMicro()).isEqualTo(1);
}
@Test
public void shouldParseM1Release() {
Calver version = Calver.parse("2020.0.1-M1");
assertThat(version.getYear()).isEqualTo(2020);
assertThat(version.getMinor()).isEqualTo(0);
assertThat(version.getMicro()).isEqualTo(1);
assertThat(version.getModifier()).isEqualTo(Iteration.M1);
}
@Test
public void shouldCompareReleasesCorrectly() {
Calver version = Calver.parse("2020.0.1-RC2");
assertThat(version).isGreaterThan(Calver.parse("2020.0.0-RC2"));
assertThat(version).isLessThan(Calver.parse("2020.0.2-RC2"));
assertThat(version).isLessThan(Calver.parse("2020.1.0-RC2"));
assertThat(version).isLessThan(Calver.parse("2021.0.0-RC2"));
assertThat(version).isGreaterThan(Calver.parse("2020.0.1-RC1"));
assertThat(version).isLessThan(Calver.parse("2020.0.1"));
assertThat(Calver.parse("2020.0.1")).isEqualTo(Calver.parse("2020.0.1"));
assertThat(Calver.parse("2020.0.1")).isLessThan(Calver.parse("2020.0.1-SR1"));
assertThat(Calver.parse("2020.0.1")).isGreaterThan(Calver.parse("2020.0.1-M1"));
}
@Test
public void shouldParseSnapshot() {
Calver version = Calver.parse("2020.0.1-SNAPSHOT");
assertThat(version.getYear()).isEqualTo(2020);
assertThat(version.getMinor()).isEqualTo(0);
assertThat(version.getMicro()).isEqualTo(1);
assertThat(version.getModifier()).isEqualTo(new Iteration("SNAPSHOT", null));
}
}

View File

@@ -15,10 +15,59 @@
*/
package org.springframework.data.release.model;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
/**
*
* @author Oliver Gierke
* Unit tests for {@link Iteration}.
*
* @author Mark Paluch
*/
public class IterationUnitTests {
@Test
public void shouldCompareMilestoneIterationsCorrectly() {
assertThat(Iteration.M1).isEqualByComparingTo(Iteration.M1);
assertThat(Iteration.M1).isLessThan(Iteration.RC1);
assertThat(Iteration.M1).isLessThan(Iteration.GA);
assertThat(Iteration.M1).isLessThan(Iteration.SR1);
assertThat(Iteration.M2).isLessThan(Iteration.M3);
assertThat(Iteration.M2).isGreaterThan(Iteration.M1);
}
@Test
public void shouldCompareReleaseCandidateIterationsCorrectly() {
assertThat(Iteration.RC1).isGreaterThan(Iteration.M1);
assertThat(Iteration.RC1).isEqualByComparingTo(Iteration.RC1);
assertThat(Iteration.RC1).isLessThan(Iteration.GA);
assertThat(Iteration.RC1).isLessThan(Iteration.SR1);
assertThat(Iteration.RC2).isLessThan(Iteration.RC3);
assertThat(Iteration.RC2).isGreaterThan(Iteration.RC1);
}
@Test
public void shouldCompareGAIterationsCorrectly() {
assertThat(Iteration.GA).isGreaterThan(Iteration.M1);
assertThat(Iteration.GA).isGreaterThan(Iteration.RC1);
assertThat(Iteration.GA).isEqualByComparingTo(Iteration.GA);
assertThat(Iteration.GA).isLessThan(Iteration.SR1);
}
@Test
public void shouldCompareServiceReleaseIterationsCorrectly() {
assertThat(Iteration.SR1).isGreaterThan(Iteration.M1);
assertThat(Iteration.SR1).isGreaterThan(Iteration.RC1);
assertThat(Iteration.SR1).isGreaterThan(Iteration.GA);
assertThat(Iteration.SR1).isEqualByComparingTo(Iteration.SR1);
assertThat(Iteration.SR2).isLessThan(Iteration.SR3);
assertThat(Iteration.SR2).isGreaterThan(Iteration.SR1);
}
}