summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java10
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java8
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java8
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java10
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java8
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java50
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java46
7 files changed, 111 insertions, 29 deletions
diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java
index 629e2556c..85a6ab803 100644
--- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java
+++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -264,7 +264,7 @@ public class AxContextAlbum extends AxConcept {
"scope is not defined"));
}
- String stringCheckResult = Assertions.getStringParameterValidationMessage(SCOPE_STRING, scope, SCOPE_REGEXP);
+ var stringCheckResult = Assertions.getStringParameterValidationMessage(SCOPE_STRING, scope, SCOPE_REGEXP);
if (stringCheckResult != null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
"scope invalid-" + stringCheckResult));
@@ -294,7 +294,7 @@ public class AxContextAlbum extends AxConcept {
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(this.getClass().getSimpleName());
builder.append(":(");
builder.append("key=");
@@ -333,8 +333,8 @@ public class AxContextAlbum extends AxConcept {
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + key.hashCode();
result = prime * result + scope.hashCode();
result = prime * result + (isWritable ? HASH_PRIME_0 : HASH_PRIME_1);
diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java
index 99e5300dc..616599653 100644
--- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java
+++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -213,7 +213,7 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(this.getClass().getSimpleName());
builder.append(":(");
builder.append(this.getClass().getSimpleName());
@@ -300,8 +300,8 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + key.hashCode();
result = prime * result + albums.hashCode();
return result;
diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java
index 9fbcc81cb..c5919c030 100644
--- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java
+++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -224,7 +224,7 @@ public class AxContextModel extends AxModel {
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(this.getClass().getSimpleName());
builder.append(":(");
builder.append(super.toString());
@@ -259,8 +259,8 @@ public class AxContextModel extends AxModel {
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + super.hashCode();
result = prime * result + schemas.hashCode();
result = prime * result + albums.hashCode();
diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java
index 00baebeab..bca369157 100644
--- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java
+++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -226,7 +226,7 @@ public class AxContextSchema extends AxConcept {
"schema flavour is not defined"));
}
- String flavourValidationResult = Assertions.getStringParameterValidationMessage(SCHEMA_FLAVOUR, schemaFlavour,
+ var flavourValidationResult = Assertions.getStringParameterValidationMessage(SCHEMA_FLAVOUR, schemaFlavour,
SCHEMA_FLAVOUR_REGEXP);
if (flavourValidationResult != null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
@@ -256,7 +256,7 @@ public class AxContextSchema extends AxConcept {
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(this.getClass().getSimpleName());
builder.append(":(");
builder.append("key=");
@@ -292,8 +292,8 @@ public class AxContextSchema extends AxConcept {
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + key.hashCode();
result = prime * result + schemaFlavour.hashCode();
result = prime * result + schemaDefinition.hashCode();
diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java
index 8c4110b62..705691c22 100644
--- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java
+++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -253,7 +253,7 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxCon
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(this.getClass().getSimpleName());
builder.append(":(");
builder.append("key=");
@@ -292,8 +292,8 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxCon
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + key.hashCode();
result = prime * result + schemas.hashCode();
return result;
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java
index 154739b90..8293feb5b 100644
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java
+++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,11 +40,14 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
public class ContextAlbumsTest {
@Test
- public void testContextAlbums() {
+ public void testNewAxContectAlbum() {
assertNotNull(new AxContextAlbum());
assertNotNull(new AxContextAlbum(new AxArtifactKey()));
assertNotNull(new AxContextAlbum(new AxArtifactKey(), "AlbumScope", false, new AxArtifactKey()));
+ }
+ @Test
+ public void testContextAlbums() {
final AxArtifactKey albumKey = new AxArtifactKey("AlbumName", "0.0.1");
final AxArtifactKey albumSchemaKey = new AxArtifactKey("AlbumSchemaName", "0.0.1");
@@ -72,7 +75,23 @@ public class ContextAlbumsTest {
album.setItemSchema(newSchemaKey);
assertEquals("NewAlbumSchemaName:0.0.1", album.getItemSchema().getId());
album.setItemSchema(albumSchemaKey);
+ }
+
+ private AxContextAlbum setTestAlbum() {
+ final AxArtifactKey newKey = new AxArtifactKey("NewAlbumName", "0.0.1");
+ final AxArtifactKey newSchemaKey = new AxArtifactKey("NewAlbumSchemaName", "0.0.1");
+
+ final AxContextAlbum album = new AxContextAlbum(newKey, "AlbumScope", false, newSchemaKey);
+ album.setScope("NewAlbumScope");
+ album.setWritable(true);
+
+ return album;
+ }
+
+ @Test
+ public void testAxvalidationAlbum() {
+ final AxContextAlbum album = setTestAlbum();
AxValidationResult result = new AxValidationResult();
result = album.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
@@ -82,6 +101,7 @@ public class ContextAlbumsTest {
result = album.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
+ final AxArtifactKey newKey = new AxArtifactKey("NewAlbumName", "0.0.1");
album.setKey(newKey);
result = new AxValidationResult();
result = album.validate(result);
@@ -102,12 +122,20 @@ public class ContextAlbumsTest {
result = album.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
+ final AxArtifactKey albumSchemaKey = new AxArtifactKey("AlbumSchemaName", "0.0.1");
album.setItemSchema(albumSchemaKey);
result = new AxValidationResult();
result = album.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
- album.clean();
+ }
+
+ @Test
+ public void testEqualsAlbum() {
+ final AxContextAlbum album = setTestAlbum();
+ final AxArtifactKey newKey = new AxArtifactKey("NewAlbumName", "0.0.1");
+ final AxArtifactKey albumSchemaKey = new AxArtifactKey("AlbumSchemaName", "0.0.1");
+ album.setItemSchema(albumSchemaKey);
final AxContextAlbum clonedAlbum = new AxContextAlbum(album);
assertEquals("AxContextAlbum:(key=AxArtifactKey:(name=NewAlbumName,version=0.0.1),"
@@ -138,9 +166,14 @@ public class ContextAlbumsTest {
assertNotEquals(0,
album.compareTo(new AxContextAlbum(newKey, "NewAlbumScope", true, AxArtifactKey.getNullKey())));
assertEquals(0, album.compareTo(new AxContextAlbum(newKey, "NewAlbumScope", true, albumSchemaKey)));
+ }
+ @Test
+ public void testMultipleAlbums() {
final AxContextAlbums albums = new AxContextAlbums();
- result = new AxValidationResult();
+ final AxContextAlbum album = setTestAlbum();
+ final AxArtifactKey newKey = new AxArtifactKey("NewAlbumName", "0.0.1");
+ AxValidationResult result = new AxValidationResult();
result = albums.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
@@ -175,6 +208,15 @@ public class ContextAlbumsTest {
result = albums.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
+ }
+
+ @Test
+ public void testClonedAlbums() {
+ final AxContextAlbums albums = new AxContextAlbums();
+ final AxContextAlbum album = setTestAlbum();
+ final AxArtifactKey newKey = new AxArtifactKey("NewAlbumName", "0.0.1");
+ albums.setKey(new AxArtifactKey("AlbumsKey", "0.0.1"));
+ albums.getAlbumsMap().put(newKey, album);
albums.clean();
final AxContextAlbums clonedAlbums = new AxContextAlbums(albums);
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java
index 6de0a5214..fbca04d7e 100644
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java
+++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,10 +38,14 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
public class ContextSchemasTest {
@Test
- public void testContextSchemas() {
+ public void testNewAxContextSchema() {
assertNotNull(new AxContextSchema());
assertNotNull(new AxContextSchema(new AxArtifactKey(), "SchemaFlavour", "SchemaDefinition"));
+ }
+
+ @Test
+ public void testContextSchemas() {
final AxContextSchema schema = new AxContextSchema(new AxArtifactKey("SchemaName", "0.0.1"), "SchemaFlavour",
"SchemaDefinition");
assertNotNull(schema);
@@ -59,7 +63,22 @@ public class ContextSchemasTest {
schema.setSchema("NewSchemaDefinition");
assertEquals("NewSchemaDefinition", schema.getSchema());
+ }
+
+ private AxContextSchema setTestSchema() {
+ final AxContextSchema schema = new AxContextSchema(new AxArtifactKey("SchemaName", "0.0.1"), "SchemaFlavour",
+ "SchemaDefinition");
+ final AxArtifactKey newKey = new AxArtifactKey("NewSchemaName", "0.0.1");
+ schema.setKey(newKey);
+ schema.setSchemaFlavour("NewSchemaFlavour");
+ schema.setSchema("NewSchemaDefinition");
+ return schema;
+ }
+
+ @Test
+ public void testAxvalidationSchema() {
+ AxContextSchema schema = setTestSchema();
AxValidationResult result = new AxValidationResult();
result = schema.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
@@ -69,6 +88,7 @@ public class ContextSchemasTest {
result = schema.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
+ final AxArtifactKey newKey = new AxArtifactKey("NewSchemaName", "0.0.1");
schema.setKey(newKey);
result = new AxValidationResult();
result = schema.validate(result);
@@ -93,7 +113,11 @@ public class ContextSchemasTest {
result = new AxValidationResult();
result = schema.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
+ }
+ @Test
+ public void testEqualsSchema() {
+ AxContextSchema schema = setTestSchema();
schema.clean();
final AxContextSchema clonedSchema = new AxContextSchema(schema);
@@ -109,6 +133,8 @@ public class ContextSchemasTest {
assertNotNull(schema);
assertNotEquals(schema, (Object) "Hello");
assertNotEquals(schema, new AxContextSchema(new AxArtifactKey(), "Flavour", "Def"));
+
+ final AxArtifactKey newKey = new AxArtifactKey("NewSchemaName", "0.0.1");
assertNotEquals(schema, new AxContextSchema(newKey, "Flavour", "Def"));
assertNotEquals(schema, new AxContextSchema(newKey, "NewSchemaFlavour", "Def"));
assertEquals(schema, new AxContextSchema(newKey, "NewSchemaFlavour", "NewSchemaDefinition"));
@@ -121,9 +147,12 @@ public class ContextSchemasTest {
assertNotEquals(0, schema.compareTo(new AxContextSchema(newKey, "Flavour", "Def")));
assertNotEquals(0, schema.compareTo(new AxContextSchema(newKey, "NewSchemaFlavour", "Def")));
assertEquals(0, schema.compareTo(new AxContextSchema(newKey, "NewSchemaFlavour", "NewSchemaDefinition")));
+ }
+ @Test
+ public void testMultipleSchemas() {
final AxContextSchemas schemas = new AxContextSchemas();
- result = new AxValidationResult();
+ AxValidationResult result = new AxValidationResult();
result = schemas.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
@@ -133,6 +162,8 @@ public class ContextSchemasTest {
result = schemas.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
+ AxContextSchema schema = setTestSchema();
+ final AxArtifactKey newKey = new AxArtifactKey("NewSchemaName", "0.0.1");
schemas.getSchemasMap().put(newKey, schema);
result = new AxValidationResult();
result = schemas.validate(result);
@@ -158,6 +189,15 @@ public class ContextSchemasTest {
result = schemas.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
+ }
+
+ @Test
+ public void testClonedSchemas() {
+ final AxContextSchemas schemas = new AxContextSchemas();
+ AxContextSchema schema = setTestSchema();
+ final AxArtifactKey newKey = new AxArtifactKey("NewSchemaName", "0.0.1");
+ schemas.setKey(new AxArtifactKey("SchemasKey", "0.0.1"));
+ schemas.getSchemasMap().put(newKey, schema);
schemas.clean();
final AxContextSchemas clonedSchemas = new AxContextSchemas(schemas);