summaryrefslogtreecommitdiffstats
path: root/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java')
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java150
1 files changed, 79 insertions, 71 deletions
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java
index 6ac46b14e..ea09cc69d 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java
@@ -29,91 +29,99 @@ import static org.junit.Assert.fail;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKey.Compatibility;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.policy.apex.model.basicmodel.concepts.AxKey.Compatibility;
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
public class AxKeyTest {
@Test
public void testArtifactKey() {
- AxArtifactKey aKey0 = new AxArtifactKey();
- AxArtifactKey aKey1 = new AxArtifactKey("name", "0.0.1");
- AxArtifactKey aKey2 = new AxArtifactKey(aKey1);
- AxArtifactKey aKey3 = new AxArtifactKey(aKey1.getID());
- AxArtifactKey aKey4 = new AxArtifactKey(aKey1);
- AxArtifactKey aKey5 = new AxArtifactKey(aKey1);
- AxArtifactKey aKey6 = new AxArtifactKey(aKey1);
-
try {
new AxArtifactKey("some bad key id");
fail("This test should throw an exception");
+ } catch (IllegalArgumentException e) {
+ assertEquals("parameter \"id\": value \"some bad key id\", "
+ + "does not match regular expression \"[A-Za-z0-9\\-_\\.]+:[0-9].[0-9].[0-9]\"",
+ e.getMessage());
}
- catch (IllegalArgumentException e) {
- assertEquals("parameter \"id\": value \"some bad key id\", does not match regular expression \"[A-Za-z0-9\\-_\\.]+:[0-9].[0-9].[0-9]\"", e.getMessage());
- }
-
- assertEquals(AxArtifactKey.getNullKey(), aKey0);
- assertEquals(aKey1, aKey2);
- assertEquals(aKey1, aKey3);
-
- assertEquals(aKey2, aKey1.getKey());
- assertEquals(1, aKey1.getKeys().size());
-
- aKey0.setName("zero");
- aKey0.setVersion("0.0.2");
- aKey3.setVersion("0.0.2");
- aKey4.setVersion("0.1.2");
- aKey5.setVersion("1.2.2");
- aKey6.setVersion("3");
-
- assertEquals(Compatibility.DIFFERENT, aKey0.getCompatibility(new AxReferenceKey()));
- assertEquals(Compatibility.DIFFERENT, aKey0.getCompatibility(aKey1));
- assertEquals(Compatibility.IDENTICAL, aKey2.getCompatibility(aKey1));
- assertEquals(Compatibility.PATCH, aKey3.getCompatibility(aKey1));
- assertEquals(Compatibility.MINOR, aKey4.getCompatibility(aKey1));
- assertEquals(Compatibility.MAJOR, aKey5.getCompatibility(aKey1));
- assertEquals(Compatibility.MAJOR, aKey6.getCompatibility(aKey1));
-
- assertTrue(aKey1.isCompatible(aKey2));
- assertTrue(aKey1.isCompatible(aKey3));
- assertTrue(aKey1.isCompatible(aKey4));
- assertFalse(aKey1.isCompatible(aKey0));
- assertFalse(aKey1.isCompatible(aKey5));
- assertFalse(aKey1.isCompatible(new AxReferenceKey()));
-
- assertEquals(AxValidationResult.ValidationResult.VALID, aKey0.validate(new AxValidationResult()).getValidationResult());
- assertEquals(AxValidationResult.ValidationResult.VALID, aKey1.validate(new AxValidationResult()).getValidationResult());
- assertEquals(AxValidationResult.ValidationResult.VALID, aKey2.validate(new AxValidationResult()).getValidationResult());
- assertEquals(AxValidationResult.ValidationResult.VALID, aKey3.validate(new AxValidationResult()).getValidationResult());
- assertEquals(AxValidationResult.ValidationResult.VALID, aKey4.validate(new AxValidationResult()).getValidationResult());
- assertEquals(AxValidationResult.ValidationResult.VALID, aKey5.validate(new AxValidationResult()).getValidationResult());
- assertEquals(AxValidationResult.ValidationResult.VALID, aKey6.validate(new AxValidationResult()).getValidationResult());
-
- aKey0.clean();
- assertNotNull(aKey0.toString());
-
- AxArtifactKey aKey7 = new AxArtifactKey(aKey1);
- assertEquals(150332875, aKey7.hashCode());
- assertEquals(0, aKey7.compareTo(aKey1));
- assertEquals(-12, aKey7.compareTo(aKey0));
-
+
+ AxArtifactKey someKey0 = new AxArtifactKey();
+ assertEquals(AxArtifactKey.getNullKey(), someKey0);
+
+ AxArtifactKey someKey1 = new AxArtifactKey("name", "0.0.1");
+ AxArtifactKey someKey2 = new AxArtifactKey(someKey1);
+ AxArtifactKey someKey3 = new AxArtifactKey(someKey1.getId());
+ assertEquals(someKey1, someKey2);
+ assertEquals(someKey1, someKey3);
+
+ assertEquals(someKey2, someKey1.getKey());
+ assertEquals(1, someKey1.getKeys().size());
+
+ someKey0.setName("zero");
+ someKey0.setVersion("0.0.2");
+
+ someKey3.setVersion("0.0.2");
+
+ AxArtifactKey someKey4 = new AxArtifactKey(someKey1);
+ someKey4.setVersion("0.1.2");
+
+ AxArtifactKey someKey5 = new AxArtifactKey(someKey1);
+ someKey5.setVersion("1.2.2");
+
+ AxArtifactKey someKey6 = new AxArtifactKey(someKey1);
+ someKey6.setVersion("3");
+
+ assertEquals(Compatibility.DIFFERENT, someKey0.getCompatibility(new AxReferenceKey()));
+ assertEquals(Compatibility.DIFFERENT, someKey0.getCompatibility(someKey1));
+ assertEquals(Compatibility.IDENTICAL, someKey2.getCompatibility(someKey1));
+ assertEquals(Compatibility.PATCH, someKey3.getCompatibility(someKey1));
+ assertEquals(Compatibility.MINOR, someKey4.getCompatibility(someKey1));
+ assertEquals(Compatibility.MAJOR, someKey5.getCompatibility(someKey1));
+ assertEquals(Compatibility.MAJOR, someKey6.getCompatibility(someKey1));
+
+ assertTrue(someKey1.isCompatible(someKey2));
+ assertTrue(someKey1.isCompatible(someKey3));
+ assertTrue(someKey1.isCompatible(someKey4));
+ assertFalse(someKey1.isCompatible(someKey0));
+ assertFalse(someKey1.isCompatible(someKey5));
+ assertFalse(someKey1.isCompatible(new AxReferenceKey()));
+
+ assertEquals(AxValidationResult.ValidationResult.VALID,
+ someKey0.validate(new AxValidationResult()).getValidationResult());
+ assertEquals(AxValidationResult.ValidationResult.VALID,
+ someKey1.validate(new AxValidationResult()).getValidationResult());
+ assertEquals(AxValidationResult.ValidationResult.VALID,
+ someKey2.validate(new AxValidationResult()).getValidationResult());
+ assertEquals(AxValidationResult.ValidationResult.VALID,
+ someKey3.validate(new AxValidationResult()).getValidationResult());
+ assertEquals(AxValidationResult.ValidationResult.VALID,
+ someKey4.validate(new AxValidationResult()).getValidationResult());
+ assertEquals(AxValidationResult.ValidationResult.VALID,
+ someKey5.validate(new AxValidationResult()).getValidationResult());
+ assertEquals(AxValidationResult.ValidationResult.VALID,
+ someKey6.validate(new AxValidationResult()).getValidationResult());
+
+ someKey0.clean();
+ assertNotNull(someKey0.toString());
+
+ AxArtifactKey someKey7 = new AxArtifactKey(someKey1);
+ assertEquals(150332875, someKey7.hashCode());
+ assertEquals(0, someKey7.compareTo(someKey1));
+ assertEquals(-12, someKey7.compareTo(someKey0));
+
try {
- aKey0.compareTo(null);
- }
- catch (IllegalArgumentException e) {
+ someKey0.compareTo(null);
+ } catch (IllegalArgumentException e) {
assertEquals("comparison object may not be null", e.getMessage());
}
-
- assertEquals(0, aKey0.compareTo(aKey0));
- assertEquals(353602977, aKey0.compareTo(new AxReferenceKey()));
-
- assertFalse(aKey0.equals(null));
- assertTrue(aKey0.equals(aKey0));
- assertFalse(((AxKey)aKey0).equals(new AxReferenceKey()));
+
+ assertEquals(0, someKey0.compareTo(someKey0));
+ assertEquals(353602977, someKey0.compareTo(new AxReferenceKey()));
+
+ assertFalse(someKey0.equals(null));
+ assertTrue(someKey0.equals(someKey0));
+ assertFalse(((AxKey) someKey0).equals(new AxReferenceKey()));
}
}