diff options
author | Dinh Danh Le <dinh.danh.le@ericsson.com> | 2018-08-27 15:57:41 +0100 |
---|---|---|
committer | Dinh Danh Le <dinh.danh.le@ericsson.com> | 2018-08-27 16:17:04 +0100 |
commit | 052038c7a7e0b385462b3b653b7d06094d472df3 (patch) | |
tree | 4ba5dd833f7f459d93c80754ee21d64ddcc27f18 | |
parent | 6a2abc8402af63dd8941b4652278a6df404d781a (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
17 files changed, 180 insertions, 128 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()); } diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java index b4e9ad37d..0fd013da7 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java @@ -91,12 +91,11 @@ import org.slf4j.ext.XLoggerFactory; * @author Sergey Sachkov (sergey.sachkov@ericsson.com) */ public class ContextInstantiation { - // Logger for this class private static final XLogger LOGGER = XLoggerFactory.getXLogger(ContextInstantiation.class); - private final static TreeSet<String> TEST_TREE_SET = new TreeSet<>(); - private final static Map<String, String> TEST_HASH_MAP = new HashMap<>(); + private static final TreeSet<String> TEST_TREE_SET = new TreeSet<>(); + private static final Map<String, String> TEST_HASH_MAP = new HashMap<>(); static { TEST_TREE_SET.add("one hundred"); @@ -373,6 +372,40 @@ public class ContextInstantiation { return globalContext; } + private TestGlobalContextItem getTestGlobalContextItem(final Date testDate, final TestContextDateTzItem tci9, + final TestContextDateLocaleItem tciA) { + final TestGlobalContextItem globalContext = new TestGlobalContextItem(); + + final TestContextBooleanItem testGlobalContextItem000 = new TestContextBooleanItem(false); + final TestContextByteItem testGlobalContextItem001 = new TestContextByteItem(BYTE_VAL); + final TestContextIntItem testGlobalContextItem002 = new TestContextIntItem(INT_VAL); + final TestContextLongItem testGlobalContextItem003 = new TestContextLongItem(LONG_VAL); + final TestContextFloatItem testGlobalContextItem004 = new TestContextFloatItem(new Float(FLOAT_VAL)); + final TestContextDoubleItem testGlobalContextItem005 = new TestContextDoubleItem(PI_VAL); + final TestContextStringItem testGlobalContextItem006 = new TestContextStringItem(STRING_GLOBAL_VAL); + final TestContextLongObjectItem testGlobalContextItem007 = new TestContextLongObjectItem(testDate.getTime()); + + final TestContextDateItem testGlobalContextItem008 = new TestContextDateItem(testDate); + final TestContextTreeSetItem testGlobalContextItem00B = new TestContextTreeSetItem(TEST_TREE_SET); + final TestContextTreeMapItem testGlobalContextItem00C = new TestContextTreeMapItem(TEST_HASH_MAP); + + + globalContext.setTestGlobalContextItem000(testGlobalContextItem000); + globalContext.setTestGlobalContextItem001(testGlobalContextItem001); + globalContext.setTestGlobalContextItem002(testGlobalContextItem002); + globalContext.setTestGlobalContextItem003(testGlobalContextItem003); + globalContext.setTestGlobalContextItem004(testGlobalContextItem004); + globalContext.setTestGlobalContextItem005(testGlobalContextItem005); + globalContext.setTestGlobalContextItem006(testGlobalContextItem006); + globalContext.setTestGlobalContextItem007(testGlobalContextItem007); + globalContext.setTestGlobalContextItem008(testGlobalContextItem008); + globalContext.setTestGlobalContextItem009(tci9); + globalContext.setTestGlobalContextItem00A(tciA); + globalContext.setTestGlobalContextItem00B(testGlobalContextItem00B); + globalContext.setTestGlobalContextItem00C(testGlobalContextItem00C); + return globalContext; + } + private TestPolicyContextItem getTestPolicyContextItem(final ContextAlbum policyContextAlbum, final Date testDate) { final TestContextStringItem contextStringItem = new TestContextStringItem(STRING_VAL); final TestContextLongItem contextLongItem = new TestContextLongItem(LONG_VAL); @@ -453,40 +486,6 @@ public class ContextInstantiation { return tci9; } - private TestGlobalContextItem getTestGlobalContextItem(final Date testDate, final TestContextDateTzItem tci9, - final TestContextDateLocaleItem tciA) { - final TestGlobalContextItem globalContext = new TestGlobalContextItem(); - - final TestContextBooleanItem testGlobalContextItem000 = new TestContextBooleanItem(false); - final TestContextByteItem testGlobalContextItem001 = new TestContextByteItem(BYTE_VAL); - final TestContextIntItem testGlobalContextItem002 = new TestContextIntItem(INT_VAL); - final TestContextLongItem testGlobalContextItem003 = new TestContextLongItem(LONG_VAL); - final TestContextFloatItem testGlobalContextItem004 = new TestContextFloatItem(new Float(FLOAT_VAL)); - final TestContextDoubleItem testGlobalContextItem005 = new TestContextDoubleItem(PI_VAL); - final TestContextStringItem testGlobalContextItem006 = new TestContextStringItem(STRING_GLOBAL_VAL); - final TestContextLongObjectItem testGlobalContextItem007 = new TestContextLongObjectItem(testDate.getTime()); - - final TestContextDateItem testGlobalContextItem008 = new TestContextDateItem(testDate); - final TestContextTreeSetItem testGlobalContextItem00B = new TestContextTreeSetItem(TEST_TREE_SET); - final TestContextTreeMapItem testGlobalContextItem00C = new TestContextTreeMapItem(TEST_HASH_MAP); - - - globalContext.setTestGlobalContextItem000(testGlobalContextItem000); - globalContext.setTestGlobalContextItem001(testGlobalContextItem001); - globalContext.setTestGlobalContextItem002(testGlobalContextItem002); - globalContext.setTestGlobalContextItem003(testGlobalContextItem003); - globalContext.setTestGlobalContextItem004(testGlobalContextItem004); - globalContext.setTestGlobalContextItem005(testGlobalContextItem005); - globalContext.setTestGlobalContextItem006(testGlobalContextItem006); - globalContext.setTestGlobalContextItem007(testGlobalContextItem007); - globalContext.setTestGlobalContextItem008(testGlobalContextItem008); - globalContext.setTestGlobalContextItem009(tci9); - globalContext.setTestGlobalContextItem00A(tciA); - globalContext.setTestGlobalContextItem00B(testGlobalContextItem00B); - globalContext.setTestGlobalContextItem00C(testGlobalContextItem00C); - return globalContext; - } - private TestExternalContextItem getTestExternalContextItem(final Date testDate, final TestContextDateTzItem tci9A, final TestContextDateLocaleItem tciAA) { final TestExternalContextItem externalContext = new TestExternalContextItem(); diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/LockType.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/LockType.java index c0ac36264..228ca7a40 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/LockType.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/LockType.java @@ -64,6 +64,11 @@ public enum LockType { return value; } + /** + * Get the lock type given an int value. + * @param value the value of lock type + * @return the lock type + */ public static LockType getLockType(final int value) { for (final LockType lockType : LockType.values()) { if (lockType.getValue() == value) { diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java index b373e9fa0..4f6dd9b1f 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java @@ -51,7 +51,7 @@ public class ConcurrentContext { // The context distributor and map used by each test private Distributor contextDistributor = null; - private ContextAlbum lTypeAlbum = null; + private ContextAlbum ltypeAlbum = null; private final ConfigrationProvider configrationProvider; @@ -59,6 +59,13 @@ public class ConcurrentContext { this.configrationProvider = configrationProvider; } + /** + * The method tests concurrent use of context. + * @return the verified context + * @throws ApexModelException the exception occurs in model handling + * @throws IOException the IO exception occurs in handling IO + * @throws ApexException the Apex exception occurs in handling Apex + */ public Map<String, TestContextLongItem> testConcurrentContext() throws ApexModelException, IOException, ApexException { @@ -135,11 +142,11 @@ public class ConcurrentContext { */ private void setupAndVerifyContext() throws ContextException { contextDistributor = configrationProvider.getDistributor(); - lTypeAlbum = configrationProvider.getContextAlbum(contextDistributor); + ltypeAlbum = configrationProvider.getContextAlbum(contextDistributor); final Map<String, Object> initValues = configrationProvider.getContextAlbumInitValues(); for (final Entry<String, Object> entry : initValues.entrySet()) { - lTypeAlbum.put(entry.getKey(), entry.getValue()); + ltypeAlbum.put(entry.getKey(), entry.getValue()); } } @@ -147,7 +154,7 @@ public class ConcurrentContext { final Map<String, TestContextLongItem> values = new HashMap<>(); try { - for (Entry<String, Object> entry : lTypeAlbum.entrySet()) { + for (Entry<String, Object> entry : ltypeAlbum.entrySet()) { values.put(entry.getKey(), (TestContextLongItem) entry.getValue()); } } catch (final Exception exception) { diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java index 020bc4169..3288f56dd 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java @@ -20,6 +20,8 @@ package org.onap.policy.apex.context.test.locking; +import com.google.gson.Gson; + import java.net.InetAddress; import java.net.NetworkInterface; import java.util.ArrayList; @@ -46,7 +48,6 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; -import com.google.gson.Gson; /** * The Class ConcurrentContextJVM tests concurrent use of context in a single JVM. @@ -72,6 +73,10 @@ public final class ConcurrentContextJVM { this.executorService = configrationProvider.getExecutorService(name, configrationProvider.getThreadCount()); } + /** + * This method executes the test of concurrent use of context in a single JVM. + * @throws ApexException the Apex exception occurs while running the test + */ public void execute() throws ApexException { LOGGER.debug("starting JVMs and threads . . ."); @@ -186,7 +191,7 @@ public final class ConcurrentContextJVM { /** - * This method setus up any static configuration required by the JVM. + * This method sets up any static configuration required by the JVM. * * @throws Exception on configuration errors */ diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java index 049754802..117a396dc 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java @@ -20,6 +20,8 @@ package org.onap.policy.apex.context.test.locking; +import com.google.gson.Gson; + import java.io.BufferedReader; import java.io.Closeable; import java.io.InputStream; @@ -34,7 +36,7 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; -import com.google.gson.Gson; + /** * The Class TestConcurrentContextThread tests concurrent use of context. diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProviderImpl.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProviderImpl.java index f04cf5b39..87b81643a 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProviderImpl.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProviderImpl.java @@ -47,6 +47,15 @@ public class ConfigrationProviderImpl implements ConfigrationProvider { private final int albumSize; private final LockType lockType; + /** + * The parameterized ConfigrationProviderImpl constructor. + * @param testType the test type + * @param jvmCount the JVM count + * @param threadCount the thread count + * @param loopSize the size of loop + * @param albumSize the size of album + * @param lockType the lock type + */ public ConfigrationProviderImpl(final String testType, final int jvmCount, final int threadCount, final int loopSize, final int albumSize, final int lockType) { this.testType = testType; diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ZooKeeperServerServiceProvider.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ZooKeeperServerServiceProvider.java index ffcbb351c..5a7813a7e 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ZooKeeperServerServiceProvider.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ZooKeeperServerServiceProvider.java @@ -26,6 +26,8 @@ import java.net.InetSocketAddress; import org.apache.zookeeper.server.NIOServerCnxnFactory; import org.apache.zookeeper.server.ZooKeeperServer; +import org.onap.policy.apex.model.basicmodel.concepts.ApexException; +import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; @@ -46,6 +48,11 @@ public class ZooKeeperServerServiceProvider { this.addr = new InetSocketAddress(addr, port); } + /** + * Start the Zookeeper server. + * @throws IOException the IO exception occurs while setting up Zookeeper server + * @throws InterruptedException the interrupted exception occurs while setting up Zookeeper server + */ public void startZookeeperServer() throws IOException, InterruptedException { LOGGER.info("Starting up ZooKeeperServer using address: {} and port: {}", addr.getAddress(), addr.getPort()); final ZooKeeperServer server = new ZooKeeperServer(zookeeperDirectory, zookeeperDirectory, 5000); @@ -54,6 +61,9 @@ public class ZooKeeperServerServiceProvider { zookeeperFactory.startup(server); } + /** + * Stop the Zookeeper server. + */ public void stopZookeeperServer() { LOGGER.info("Stopping ZooKeeperServer for address: {} and port: {}", addr.getAddress(), addr.getPort()); if (zookeeperFactory != null) { diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java index 5d41eee85..80f06ead7 100644 --- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java +++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java @@ -91,7 +91,7 @@ public class TestPersistentContextInstantiation { final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey); final AxArtifactKey[] usedArtifactStackArray = {new AxArtifactKey("testC-top", "0.0.1"), - new AxArtifactKey("testC-next", "0.0.1"), new AxArtifactKey("testC-bot", "0.0.1")}; + new AxArtifactKey("testC-next", "0.0.1"), new AxArtifactKey("testC-bot", "0.0.1")}; final DAOParameters daoParameters = new DAOParameters(); daoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao"); diff --git a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java index 5117a2ecf..d374a6c60 100644 --- a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java +++ b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java @@ -205,11 +205,11 @@ public class Model2Cli { * Gets the parameters for event. * * @param cg the code generator - * @param e the event + * @param event the event * @return the parameters for event */ - private List<ST> getParametersForEvent(final CGCliEditor cg, final AxEvent e) { - final Collection<AxField> fields = e.getFields(); + private List<ST> getParametersForEvent(final CGCliEditor cg, final AxEvent event) { + final Collection<AxField> fields = event.getFields(); final List<ST> ret = new ArrayList<>(fields.size()); for (final AxField f : fields) { final AxReferenceKey fkey = f.getKey(); @@ -226,13 +226,13 @@ public class Model2Cli { * Gets the context references for task. * * @param cg the code generator - * @param t the task + * @param task the task * @return the context references for task */ - private List<ST> getCtxtRefsForTask(final CGCliEditor cg, final AxTask t) { - final Collection<AxArtifactKey> ctxs = t.getContextAlbumReferences(); + private List<ST> getCtxtRefsForTask(final CGCliEditor cg, final AxTask task) { + final Collection<AxArtifactKey> ctxs = task.getContextAlbumReferences(); final List<ST> ret = new ArrayList<>(ctxs.size()); - final AxArtifactKey tkey = t.getKey(); + final AxArtifactKey tkey = task.getKey(); for (final AxArtifactKey ckey : ctxs) { final ST val = cg.createTaskDefinitionContextRef(kig.getName(tkey), kig.getVersion(tkey), kig.getName(ckey), @@ -247,11 +247,11 @@ public class Model2Cli { * Gets the parameters for task. * * @param cg the code generator - * @param t the task + * @param task the task * @return the parameters for task */ - private List<ST> getParametersForTask(final CGCliEditor cg, final AxTask t) { - final Collection<AxTaskParameter> pars = t.getTaskParameters().values(); + private List<ST> getParametersForTask(final CGCliEditor cg, final AxTask task) { + final Collection<AxTaskParameter> pars = task.getTaskParameters().values(); final List<ST> ret = new ArrayList<>(pars.size()); for (final AxTaskParameter p : pars) { final AxReferenceKey pkey = p.getKey(); @@ -268,12 +268,12 @@ public class Model2Cli { * Gets the logic for task. * * @param cg the code generator - * @param t the task + * @param task the task * @return the logic for task */ - private ST getLogicForTask(final CGCliEditor cg, final AxTask t) { - final AxArtifactKey tkey = t.getKey(); - final AxTaskLogic tl = t.getTaskLogic(); + private ST getLogicForTask(final CGCliEditor cg, final AxTask task) { + final AxArtifactKey tkey = task.getKey(); + final AxTaskLogic tl = task.getTaskLogic(); final ST val = cg.createTaskDefLogic(kig.getName(tkey), kig.getVersion(tkey), tl.getLogicFlavour(), tl.getLogic()); @@ -285,11 +285,11 @@ public class Model2Cli { * Gets the output fields for task. * * @param cg the code generator - * @param t the task + * @param task the task * @return the output fields for task */ - private List<ST> getOutfieldsForTask(final CGCliEditor cg, final AxTask t) { - final Collection<? extends AxField> fields = t.getOutputFields().values(); + private List<ST> getOutfieldsForTask(final CGCliEditor cg, final AxTask task) { + final Collection<? extends AxField> fields = task.getOutputFields().values(); final List<ST> ret = new ArrayList<>(fields.size()); for (final AxField f : fields) { final AxReferenceKey fkey = f.getKey(); @@ -306,11 +306,11 @@ public class Model2Cli { * Gets the input fields for task. * * @param cg the code generator - * @param t the task + * @param task the task * @return the input fields for task */ - private List<ST> getInfieldsForTask(final CGCliEditor cg, final AxTask t) { - final Collection<? extends AxField> fields = t.getInputFields().values(); + private List<ST> getInfieldsForTask(final CGCliEditor cg, final AxTask task) { + final Collection<? extends AxField> fields = task.getInputFields().values(); final List<ST> ret = new ArrayList<>(fields.size()); for (final AxField f : fields) { final AxReferenceKey fkey = f.getKey(); @@ -327,11 +327,11 @@ public class Model2Cli { * Gets the states for policy. * * @param cg the code generator - * @param p the policy + * @param pol the policy * @return the states for policy */ - private List<ST> getStatesForPolicy(final CGCliEditor cg, final AxPolicy p) { - final Collection<AxState> states = p.getStateMap().values(); + private List<ST> getStatesForPolicy(final CGCliEditor cg, final AxPolicy pol) { + final Collection<AxState> states = pol.getStateMap().values(); final List<ST> ret = new ArrayList<>(states.size()); for (final AxState st : states) { final AxReferenceKey skey = st.getKey(); diff --git a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2event/Model2JsonEventSchema.java b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2event/Model2JsonEventSchema.java index ec6d72c4b..b662f577c 100644 --- a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2event/Model2JsonEventSchema.java +++ b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2event/Model2JsonEventSchema.java @@ -136,9 +136,10 @@ public class Model2JsonEventSchema { /** * Runs the application. * + * + * @return status of the application execution, 0 for success, positive integer for exit + * condition (such as help or version), negative integer for errors * @throws ApexException if any problem occurred in the model - * @return status of the application execution, 0 for success, positive integer for exit condition (such as help or - * version), negative integer for errors */ public int runApp() throws ApexException { final STGroupFile stg = new STGroupFile("org/onap/policy/apex/tools/model/generator/event-json.stg"); diff --git a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/CliOptions.java b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/CliOptions.java index 277769be2..aea984fb1 100644 --- a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/CliOptions.java +++ b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/CliOptions.java @@ -88,7 +88,8 @@ public final class CliOptions { /** A type option defining what type is used for events with "-t" and "--type". */ public static final Option TYPE = Option.builder("t").hasArg().argName("TYPE").longOpt("type").desc( - "set the event type for generation, one of: stimuli (trigger events), response (action events), internal (events between states)") + "set the event type for generation, one of: stimuli (trigger events), response (action events)," + + " internal (events between states)") .build(); /** A server option with "-s" and "--server". */ diff --git a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java index d76caa333..28337fdeb 100644 --- a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java +++ b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java @@ -151,16 +151,6 @@ public final class Console { } /** - * Configures the console. Use the configuration flags in combination for the required configuration. For instance, - * to collect errors and warnings use <code>CONFIG_COLLECT_ERRORS | CONFIG_COLLECT_WARNINGS</code>. - * - * @param config the new configuration, overwrites the current configuration, 0 deactivates all settings - */ - public void configure(final int config) { - this.configuration = config; - } - - /** * Sets the type to the given types, effectively deactivating all other types. * * @param ts array of types to set @@ -173,6 +163,16 @@ public final class Console { } /** + * Configures the console. Use the configuration flags in combination for the required configuration. For instance, + * to collect errors and warnings use <code>CONFIG_COLLECT_ERRORS | CONFIG_COLLECT_WARNINGS</code>. + * + * @param config the new configuration, overwrites the current configuration, 0 deactivates all settings + */ + public void configure(final int config) { + this.configuration = config; + } + + /** * Prints an error message with message and objects if {@link #TYPE_ERROR} is set; and increases the error count. * Errors are collected (if configuration is set) and the error counter is increased regardless of the console error * type settings. |