KEYCLOAK-12877 Fix ModelVersion for testing pipeline
This commit is contained in:
parent
66350f415c
commit
986213be23
2 changed files with 25 additions and 16 deletions
|
@ -25,11 +25,11 @@ import org.jboss.logging.Logger;
|
||||||
*/
|
*/
|
||||||
public class ModelVersion {
|
public class ModelVersion {
|
||||||
private static Logger logger = Logger.getLogger(ModelVersion.class);
|
private static Logger logger = Logger.getLogger(ModelVersion.class);
|
||||||
|
|
||||||
int major;
|
int major;
|
||||||
int minor;
|
int minor;
|
||||||
int micro;
|
int micro;
|
||||||
String qualifier;
|
String qualifier;
|
||||||
boolean snapshot;
|
|
||||||
|
|
||||||
public ModelVersion(int major, int minor, int micro) {
|
public ModelVersion(int major, int minor, int micro) {
|
||||||
this.major = major;
|
this.major = major;
|
||||||
|
@ -38,10 +38,7 @@ public class ModelVersion {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelVersion(String version) {
|
public ModelVersion(String version) {
|
||||||
if (version.toUpperCase().contains("-SNAPSHOT")) {
|
version = version.split("-")[0];
|
||||||
snapshot = true;
|
|
||||||
version = version.toUpperCase().split("-SNAPSHOT")[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] split = version.split("\\.");
|
String[] split = version.split("\\.");
|
||||||
try {
|
try {
|
||||||
|
@ -56,6 +53,10 @@ public class ModelVersion {
|
||||||
}
|
}
|
||||||
if (split.length > 3) {
|
if (split.length > 3) {
|
||||||
qualifier = split[3];
|
qualifier = split[3];
|
||||||
|
|
||||||
|
if (qualifier.startsWith("redhat")) {
|
||||||
|
qualifier = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
logger.warn("failed to parse version: " + version, e);
|
logger.warn("failed to parse version: " + version, e);
|
||||||
|
@ -78,10 +79,6 @@ public class ModelVersion {
|
||||||
return qualifier;
|
return qualifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSnapshot() {
|
|
||||||
return snapshot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean lessThan(ModelVersion version) {
|
public boolean lessThan(ModelVersion version) {
|
||||||
if (major < version.major) {
|
if (major < version.major) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -111,10 +108,6 @@ public class ModelVersion {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (snapshot && !version.snapshot) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class MigrationVersionTest {
|
||||||
Assert.assertEquals(1, version_100Beta1.getMajor());
|
Assert.assertEquals(1, version_100Beta1.getMajor());
|
||||||
Assert.assertEquals(0, version_100Beta1.getMinor());
|
Assert.assertEquals(0, version_100Beta1.getMinor());
|
||||||
Assert.assertEquals(0, version_100Beta1.getMicro());
|
Assert.assertEquals(0, version_100Beta1.getMicro());
|
||||||
Assert.assertTrue(version_100Beta1.isSnapshot());
|
|
||||||
ModelVersion version_100CR1 = new ModelVersion("1.0.0.CR1");
|
ModelVersion version_100CR1 = new ModelVersion("1.0.0.CR1");
|
||||||
ModelVersion version_100 = new ModelVersion("1.0.0");
|
ModelVersion version_100 = new ModelVersion("1.0.0");
|
||||||
ModelVersion version_110Beta1 = new ModelVersion("1.1.0.Beta1");
|
ModelVersion version_110Beta1 = new ModelVersion("1.1.0.Beta1");
|
||||||
|
@ -55,7 +55,7 @@ public class MigrationVersionTest {
|
||||||
Assert.assertEquals(1, version_211CR1.getMinor());
|
Assert.assertEquals(1, version_211CR1.getMinor());
|
||||||
Assert.assertEquals(1, version_211CR1.getMicro());
|
Assert.assertEquals(1, version_211CR1.getMicro());
|
||||||
Assert.assertEquals("CR1", version_211CR1.getQualifier());
|
Assert.assertEquals("CR1", version_211CR1.getQualifier());
|
||||||
Assert.assertFalse(version_211CR1.isSnapshot());
|
|
||||||
ModelVersion version_211 = new ModelVersion("2.1.1");
|
ModelVersion version_211 = new ModelVersion("2.1.1");
|
||||||
|
|
||||||
ModelVersion version50Snapshot = new ModelVersion("5.0.0-SNAPSHOT");
|
ModelVersion version50Snapshot = new ModelVersion("5.0.0-SNAPSHOT");
|
||||||
|
@ -63,7 +63,6 @@ public class MigrationVersionTest {
|
||||||
Assert.assertEquals(0, version50Snapshot.getMinor());
|
Assert.assertEquals(0, version50Snapshot.getMinor());
|
||||||
Assert.assertEquals(0, version50Snapshot.getMicro());
|
Assert.assertEquals(0, version50Snapshot.getMicro());
|
||||||
Assert.assertNull(version50Snapshot.getQualifier());
|
Assert.assertNull(version50Snapshot.getQualifier());
|
||||||
Assert.assertTrue(version50Snapshot.isSnapshot());
|
|
||||||
|
|
||||||
Assert.assertFalse(version_100Beta1.lessThan(version_100Beta1));
|
Assert.assertFalse(version_100Beta1.lessThan(version_100Beta1));
|
||||||
Assert.assertTrue(version_100Beta1.lessThan(version_100CR1));
|
Assert.assertTrue(version_100Beta1.lessThan(version_100CR1));
|
||||||
|
@ -82,6 +81,23 @@ public class MigrationVersionTest {
|
||||||
|
|
||||||
Assert.assertTrue(version_211CR1.lessThan(version50Snapshot));
|
Assert.assertTrue(version_211CR1.lessThan(version50Snapshot));
|
||||||
|
|
||||||
|
ModelVersion versionPipeline = new ModelVersion("8.0.2-REL-20200130-143126");
|
||||||
|
Assert.assertEquals(8, versionPipeline.getMajor());
|
||||||
|
Assert.assertEquals(0, versionPipeline.getMinor());
|
||||||
|
Assert.assertEquals(2, versionPipeline.getMicro());
|
||||||
|
Assert.assertNull(versionPipeline.getQualifier());
|
||||||
|
|
||||||
|
ModelVersion versionPipeline2 = new ModelVersion("9.1.2-SNAPSHOT-stage-20191125-003440");
|
||||||
|
Assert.assertEquals(9, versionPipeline2.getMajor());
|
||||||
|
Assert.assertEquals(1, versionPipeline2.getMinor());
|
||||||
|
Assert.assertEquals(2, versionPipeline2.getMicro());
|
||||||
|
Assert.assertNull(versionPipeline2.getQualifier());
|
||||||
|
|
||||||
|
ModelVersion versionProduct = new ModelVersion("7.0.0.redhat-00002");
|
||||||
|
Assert.assertEquals(7, versionProduct.getMajor());
|
||||||
|
Assert.assertEquals(0, versionProduct.getMinor());
|
||||||
|
Assert.assertEquals(0, versionProduct.getMicro());
|
||||||
|
Assert.assertNull(versionProduct.getQualifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in a new issue