KEYCLOAK-9713 Warning in the log during export/import on current master

This commit is contained in:
mposolda 2019-03-01 10:26:37 +01:00 committed by Marek Posolda
parent 65326ce16a
commit 5b663dbc69
2 changed files with 32 additions and 2 deletions

View file

@ -29,6 +29,7 @@ public class ModelVersion {
int minor;
int micro;
String qualifier;
boolean snapshot;
public ModelVersion(int major, int minor, int micro) {
this.major = major;
@ -37,6 +38,11 @@ public class ModelVersion {
}
public ModelVersion(String version) {
if (version.endsWith("-SNAPSHOT") || version.endsWith("-snapshot")) {
snapshot = true;
version = version.substring(0, version.length() - 9);
}
String[] split = version.split("\\.");
try {
if (split.length > 0) {
@ -72,6 +78,10 @@ public class ModelVersion {
return qualifier;
}
public boolean isSnapshot() {
return snapshot;
}
public boolean lessThan(ModelVersion version) {
if (major < version.major) {
return true;
@ -95,7 +105,16 @@ public class ModelVersion {
if (qualifier == null) return false;
if (version.qualifier == null) return true;
int comp = qualifier.compareTo(version.qualifier);
if (comp < 0) return true;
if (comp < 0) {
return true;
} else if (comp > 0){
return false;
}
if (snapshot && !version.snapshot) {
return true;
}
return false;
}

View file

@ -29,10 +29,11 @@ public class MigrationVersionTest {
@Test
public void testVersion() {
ModelVersion version_100Beta1 = new ModelVersion("1.0.0.Beta1");
ModelVersion version_100Beta1 = new ModelVersion("1.0.0.Beta1-SNAPSHOT");
Assert.assertEquals(version_100Beta1.getMajor(), 1);
Assert.assertEquals(version_100Beta1.getMinor(), 0);
Assert.assertEquals(version_100Beta1.getMicro(), 0);
Assert.assertTrue(version_100Beta1.isSnapshot());
ModelVersion version_100CR1 = new ModelVersion("1.0.0.CR1");
ModelVersion version_100 = new ModelVersion("1.0.0");
ModelVersion version_110Beta1 = new ModelVersion("1.1.0.Beta1");
@ -49,8 +50,16 @@ public class MigrationVersionTest {
Assert.assertEquals(version_211CR1.getMinor(), 1);
Assert.assertEquals(version_211CR1.getMicro(), 1);
Assert.assertEquals(version_211CR1.getQualifier(), "CR1");
Assert.assertFalse(version_211CR1.isSnapshot());
ModelVersion version_211 = new ModelVersion("2.1.1");
ModelVersion version50Snapshot = new ModelVersion("5.0.0-SNAPSHOT");
Assert.assertEquals(version50Snapshot.getMajor(), 5);
Assert.assertEquals(version50Snapshot.getMinor(), 0);
Assert.assertEquals(version50Snapshot.getMicro(), 0);
Assert.assertNull(version50Snapshot.getQualifier());
Assert.assertTrue(version50Snapshot.isSnapshot());
Assert.assertFalse(version_100Beta1.lessThan(version_100Beta1));
Assert.assertTrue(version_100Beta1.lessThan(version_100CR1));
Assert.assertTrue(version_100Beta1.lessThan(version_100));
@ -66,5 +75,7 @@ public class MigrationVersionTest {
Assert.assertFalse(version_211.lessThan(version_110CR1));
Assert.assertTrue(version_211CR1.lessThan(version50Snapshot));
}
}