aboutsummaryrefslogtreecommitdiffstats
path: root/context/context-management
diff options
context:
space:
mode:
authorDinh Danh Le <dinh.danh.le@ericsson.com>2018-08-27 15:57:41 +0100
committerDinh Danh Le <dinh.danh.le@ericsson.com>2018-08-27 16:17:04 +0100
commit052038c7a7e0b385462b3b653b7d06094d472df3 (patch)
tree4ba5dd833f7f459d93c80754ee21d64ddcc27f18 /context/context-management
parent6a2abc8402af63dd8941b4652278a6df404d781a (diff)
Fix checkstyle warning in tools & context packages
Change-Id: I5b72c7a35d56296cd5053659a9d4c1e8f3b058be Signed-off-by: Dinh Danh Le <dinh.danh.le@ericsson.com> Issue-ID: POLICY-1034
Diffstat (limited to 'context/context-management')
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/ContextAlbum.java3
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java19
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java3
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java3
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperTest.java79
5 files changed, 60 insertions, 47 deletions
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/ContextAlbum.java b/context/context-management/src/main/java/org/onap/policy/apex/context/ContextAlbum.java
index b3e85282d..d9775bfe2 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/ContextAlbum.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/ContextAlbum.java
@@ -34,8 +34,7 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
* <p>A context album uses plugins to handle its context schemas, its distribution, its locking, and
* its persistence.
*
- * <p>
- * The schema that defines the items in a context album is interpreted by a plugin that implements
+ * <p>The schema that defines the items in a context album is interpreted by a plugin that implements
* the {@link SchemaHelper} interface. The schema helper uses the schema definition to provide new
* instances for a context album. By default, context albums use Java schemas.
*
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java
index bed678581..bf363058b 100644
--- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java
@@ -48,6 +48,9 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
public class ContextAlbumImplTest {
+ /**
+ * Set ups everything for the test.
+ */
@BeforeClass
public static void prepareForTest() {
final ContextParameters contextParameters = new ContextParameters();
@@ -111,9 +114,6 @@ public class ContextAlbumImplTest {
AxContextAlbum axContextAlbum = new AxContextAlbum(new AxArtifactKey("TestContextAlbum", "0.0.1"), "Policy",
true, AxArtifactKey.getNullKey());
- AxContextAlbum axContextAlbumRO = new AxContextAlbum(new AxArtifactKey("TestContextAlbum", "0.0.1"), "Policy",
- false, simpleStringSchema.getKey());
-
try {
new ContextAlbumImpl(axContextAlbum, new JVMLocalDistributor(), new LinkedHashMap<String, Object>());
fail("this test should throw an exception");
@@ -126,7 +126,10 @@ public class ContextAlbumImplTest {
Distributor distributor = new JVMLocalDistributor();
distributor.init(axContextAlbum.getKey());
ContextAlbum album = new ContextAlbumImpl(axContextAlbum, distributor, new LinkedHashMap<String, Object>());
- ContextAlbum albumRO = new ContextAlbumImpl(axContextAlbumRO, distributor, new LinkedHashMap<String, Object>());
+
+ AxContextAlbum axContextAlbumRo = new AxContextAlbum(new AxArtifactKey("TestContextAlbum", "0.0.1"), "Policy",
+ false, simpleStringSchema.getKey());
+ ContextAlbum albumRo = new ContextAlbumImpl(axContextAlbumRo, distributor, new LinkedHashMap<String, Object>());
assertEquals("TestContextAlbum", album.getName());
assertEquals("TestContextAlbum:0.0.1", album.getKey().getID());
@@ -172,7 +175,7 @@ public class ContextAlbumImplTest {
}
try {
- albumRO.put("KeyReadOnly", "A value for a Read Only Album");
+ albumRo.put("KeyReadOnly", "A value for a Read Only Album");
fail("test should throw an exception");
} catch (ContextRuntimeException e) {
assertEquals("album \"TestContextAlbum:0.0.1\" put() not allowed on read only albums "
@@ -185,14 +188,14 @@ public class ContextAlbumImplTest {
putAllData.put("AllKey2", "vaue of AllKey2");
try {
- albumRO.putAll(putAllData);
+ albumRo.putAll(putAllData);
fail("test should throw an exception");
} catch (ContextRuntimeException e) {
assertEquals("album \"TestContextAlbum:0.0.1\" putAll() not allowed on read only albums", e.getMessage());
}
try {
- albumRO.remove("AllKey0");
+ albumRo.remove("AllKey0");
fail("test should throw an exception");
} catch (ContextRuntimeException e) {
assertEquals(
@@ -208,7 +211,7 @@ public class ContextAlbumImplTest {
}
try {
- albumRO.clear();
+ albumRo.clear();
fail("test should throw an exception");
} catch (ContextRuntimeException e) {
assertEquals("album \"TestContextAlbum:0.0.1\" clear() not allowed on read only albums", e.getMessage());
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java
index 21096e753..fed79e713 100644
--- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java
@@ -39,6 +39,9 @@ public class SchemaHelperFactoryTest {
private static AxContextSchemas schemas;
private static AxContextSchema badSchema;
+ /**
+ * Set ups schema for the test.
+ */
@BeforeClass
public static void setupSchema() {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java
index ea29bd87d..1ca3702e8 100644
--- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java
@@ -43,6 +43,9 @@ public class JavaSchemaHelperInstanceCreationTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
+ /**
+ * Set ups everything for the test.
+ */
@Before
public void initTest() {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperTest.java
index ade5eba87..8da6fdab9 100644
--- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperTest.java
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperTest.java
@@ -23,17 +23,19 @@ package org.onap.policy.apex.context.impl.schema.java;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonPrimitive;
+
import java.math.BigDecimal;
import org.junit.Test;
+
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParser;
-import com.google.gson.JsonPrimitive;
public class JavaSchemaHelperTest {
@@ -49,7 +51,7 @@ public class JavaSchemaHelperTest {
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: class/type java.lang.Rubbish for context schema"
- + " \"SchemaKey:0.0.1\" not found. Check the class path of the JVM", e.getMessage());
+ + " \"SchemaKey:0.0.1\" not found. Check the class path of the JVM", e.getMessage());
}
AxContextSchema builtInJavaTypeSchema = new AxContextSchema(schemaKey, "Java", "short");
@@ -59,18 +61,13 @@ public class JavaSchemaHelperTest {
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: class/type short for context schema "
- + "\"SchemaKey:0.0.1\" not found. Primitive types are not supported."
- + " Use the appropriate Java boxing type instead.", e.getMessage());
+ + "\"SchemaKey:0.0.1\" not found. Primitive types are not supported."
+ + " Use the appropriate Java boxing type instead.", e.getMessage());
}
}
@Test
public void testJavaSchemaHelperMethods() {
- AxArtifactKey schemaKey = new AxArtifactKey("SchemaKey", "0.0.1");
- AxArtifactKey userKey = new AxArtifactKey("UserKey", "0.0.1");
-
- AxContextSchema intSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Integer");
-
SchemaHelper intSchemaHelper = new JavaSchemaHelper();
assertEquals(AxArtifactKey.getNullKey(), intSchemaHelper.getUserKey());
@@ -83,7 +80,7 @@ public class JavaSchemaHelperTest {
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("NULL:0.0.0: could not create an instance, schema class for the schema is null",
- e.getMessage());
+ e.getMessage());
}
try {
@@ -91,7 +88,7 @@ public class JavaSchemaHelperTest {
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("NULL:0.0.0: could not create an instance, schema class for the schema is null",
- e.getMessage());
+ e.getMessage());
}
try {
@@ -99,9 +96,13 @@ public class JavaSchemaHelperTest {
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("NULL:0.0.0: could not create an instance, schema class for the schema is null",
- e.getMessage());
+ e.getMessage());
}
+ AxArtifactKey schemaKey = new AxArtifactKey("SchemaKey", "0.0.1");
+ AxArtifactKey userKey = new AxArtifactKey("UserKey", "0.0.1");
+ AxContextSchema intSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Integer");
+
intSchemaHelper.init(userKey, intSchema);
assertEquals(userKey, intSchemaHelper.getUserKey());
assertEquals(intSchema, intSchemaHelper.getSchema());
@@ -113,7 +114,7 @@ public class JavaSchemaHelperTest {
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: could not create an instance of class "
- + "\"java.lang.Integer\" using the default constructor \"Integer()\"", e.getMessage());
+ + "\"java.lang.Integer\" using the default constructor \"Integer()\"", e.getMessage());
}
try {
@@ -121,8 +122,8 @@ public class JavaSchemaHelperTest {
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: the object \"1.23\" of type "
- + "\"java.lang.Float\" is not an instance of JsonObject and is not "
- + "assignable to \"java.lang.Integer\"", e.getMessage());
+ + "\"java.lang.Float\" is not an instance of JsonObject and is not "
+ + "assignable to \"java.lang.Integer\"", e.getMessage());
}
try {
@@ -130,7 +131,7 @@ public class JavaSchemaHelperTest {
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: could not create an instance of class \"java.lang.Integer\" "
- + "using the string constructor \"Integer(String)\"", e.getMessage());
+ + "using the string constructor \"Integer(String)\"", e.getMessage());
}
JsonElement jsonIntElement = null;
@@ -158,29 +159,33 @@ public class JavaSchemaHelperTest {
AxContextSchema byteSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Byte");
AxContextSchema shortSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Short");
AxContextSchema intSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Integer");
- AxContextSchema longSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Long");
- AxContextSchema floatSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Float");
- AxContextSchema doubleSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Double");
- AxContextSchema stringSchema = new AxContextSchema(schemaKey, "Java", "java.lang.String");
- AxContextSchema myBaseClassSchema = new AxContextSchema(schemaKey, "Java",
- "org.onap.policy.apex.context.impl.schema.java.MyBaseClass");
SchemaHelper byteSchemaHelper = new JavaSchemaHelper();
SchemaHelper shortSchemaHelper = new JavaSchemaHelper();
SchemaHelper intSchemaHelper = new JavaSchemaHelper();
- SchemaHelper longSchemaHelper = new JavaSchemaHelper();
- SchemaHelper floatSchemaHelper = new JavaSchemaHelper();
- SchemaHelper doubleSchemaHelper = new JavaSchemaHelper();
- SchemaHelper stringSchemaHelper = new JavaSchemaHelper();
- SchemaHelper myBaseClassSchemaHelper = new JavaSchemaHelper();
byteSchemaHelper.init(userKey, byteSchema);
shortSchemaHelper.init(userKey, shortSchema);
intSchemaHelper.init(userKey, intSchema);
+
+ SchemaHelper longSchemaHelper = new JavaSchemaHelper();
+ SchemaHelper floatSchemaHelper = new JavaSchemaHelper();
+
+ AxContextSchema longSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Long");
+ AxContextSchema floatSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Float");
longSchemaHelper.init(userKey, longSchema);
floatSchemaHelper.init(userKey, floatSchema);
+
+ SchemaHelper doubleSchemaHelper = new JavaSchemaHelper();
+ SchemaHelper stringSchemaHelper = new JavaSchemaHelper();
+ AxContextSchema doubleSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Double");
+ AxContextSchema stringSchema = new AxContextSchema(schemaKey, "Java", "java.lang.String");
doubleSchemaHelper.init(userKey, doubleSchema);
stringSchemaHelper.init(userKey, stringSchema);
+
+ AxContextSchema myBaseClassSchema =
+ new AxContextSchema(schemaKey, "Java", "org.onap.policy.apex.context.impl.schema.java.MyBaseClass");
+ SchemaHelper myBaseClassSchemaHelper = new JavaSchemaHelper();
myBaseClassSchemaHelper.init(userKey, myBaseClassSchema);
assertEquals(null, byteSchemaHelper.unmarshal(null));
@@ -196,7 +201,7 @@ public class JavaSchemaHelperTest {
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Byte\"", e.getMessage());
+ + "compatible with class \"java.lang.Byte\"", e.getMessage());
}
assertEquals(null, shortSchemaHelper.unmarshal(null));
@@ -212,7 +217,7 @@ public class JavaSchemaHelperTest {
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Short\"", e.getMessage());
+ + "compatible with class \"java.lang.Short\"", e.getMessage());
}
assertEquals(null, intSchemaHelper.unmarshal(null));
@@ -228,7 +233,7 @@ public class JavaSchemaHelperTest {
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Integer\"", e.getMessage());
+ + "compatible with class \"java.lang.Integer\"", e.getMessage());
}
assertEquals(null, longSchemaHelper.unmarshal(null));
@@ -244,7 +249,7 @@ public class JavaSchemaHelperTest {
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Long\"", e.getMessage());
+ + "compatible with class \"java.lang.Long\"", e.getMessage());
}
assertEquals(null, floatSchemaHelper.unmarshal(null));
@@ -260,7 +265,7 @@ public class JavaSchemaHelperTest {
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Float\"", e.getMessage());
+ + "compatible with class \"java.lang.Float\"", e.getMessage());
}
assertEquals(null, doubleSchemaHelper.unmarshal(null));
@@ -277,7 +282,7 @@ public class JavaSchemaHelperTest {
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Double\"", e.getMessage());
+ + "compatible with class \"java.lang.Double\"", e.getMessage());
}
assertEquals("123", stringSchemaHelper.unmarshal(123));
@@ -302,9 +307,9 @@ public class JavaSchemaHelperTest {
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: object \"123.45\" of class \"java.lang.Double\" not "
- + "compatible with class \"java.lang.Integer\"", e.getMessage());
+ + "compatible with class \"java.lang.Integer\"", e.getMessage());
}
-
+
JsonPrimitive intJsonPrimitive = (JsonPrimitive) intSchemaHelper.marshal2Object(123);
assertEquals(123, intJsonPrimitive.getAsInt());
}