diff options
20 files changed, 245 insertions, 304 deletions
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 5aaa8a38a..6ebb79f43 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 @@ -57,7 +57,7 @@ public class ContextAlbumImplTest { public static void prepareForTest() { final ContextParameters contextParameters = new ContextParameters(); contextParameters.getLockManagerParameters() - .setPluginClass("org.onap.policy.apex.context.impl.locking.jvmlocal.JvmLocalLockManager"); + .setPluginClass("org.onap.policy.apex.context.impl.locking.jvmlocal.JvmLocalLockManager"); contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME); contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME); @@ -101,25 +101,25 @@ public class ContextAlbumImplTest { .hasMessage("Album map may not be null"); assertThatThrownBy(() -> new ContextAlbumImpl(new AxContextAlbum(), new JvmLocalDistributor(), - new LinkedHashMap<String, Object>())) - .hasMessage("Model for org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas " - + "not found in model service"); + new LinkedHashMap<String, Object>())) + .hasMessage("Model for org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas " + + "not found in model service"); } @Test public void testAlbumInterface() throws ContextException { AxContextSchemas schemas = new AxContextSchemas(); AxContextSchema simpleStringSchema = new AxContextSchema(new AxArtifactKey("SimpleStringSchema", "0.0.1"), - "JAVA", "java.lang.String"); + "JAVA", "java.lang.String"); schemas.getSchemasMap().put(simpleStringSchema.getKey(), simpleStringSchema); ModelService.registerModel(AxContextSchemas.class, schemas); AxContextAlbum axContextAlbum = new AxContextAlbum(new AxArtifactKey("TestContextAlbum", "0.0.1"), "Policy", - true, AxArtifactKey.getNullKey()); + true, AxArtifactKey.getNullKey()); - assertThatThrownBy(() -> new ContextAlbumImpl(axContextAlbum, new JvmLocalDistributor(), - new LinkedHashMap<String, Object>())) - .hasMessageContaining("could not initiate schema management for context album AxContextAlbum"); + assertThatThrownBy( + () -> new ContextAlbumImpl(axContextAlbum, new JvmLocalDistributor(), new LinkedHashMap<String, Object>())) + .hasMessageContaining("could not initiate schema management for context album AxContextAlbum"); axContextAlbum.setItemSchema(simpleStringSchema.getKey()); Distributor distributor = new JvmLocalDistributor(); @@ -146,16 +146,15 @@ public class ContextAlbumImplTest { .hasMessage("album \"TestContextAlbum:0.0.1\" null keys are illegal on keys for put()"); assertThatThrownBy(() -> album.put("KeyNull", null)) - .hasMessage("album \"TestContextAlbum:0.0.1\" null values are illegal on key \"KeyNull\"" - + " for put()"); + .hasMessage("album \"TestContextAlbum:0.0.1\" null values are illegal on key \"KeyNull\"" + " for put()"); AxContextAlbum axContextAlbumRo = new AxContextAlbum(new AxArtifactKey("TestContextAlbum", "0.0.1"), "Policy", - false, simpleStringSchema.getKey()); + false, simpleStringSchema.getKey()); ContextAlbum albumRo = new ContextAlbumImpl(axContextAlbumRo, distributor, new LinkedHashMap<String, Object>()); assertThatThrownBy(() -> albumRo.put("KeyReadOnly", "A value for a Read Only Album")) .hasMessage("album \"TestContextAlbum:0.0.1\" put() not allowed on read only albums " - + "for key=\"KeyReadOnly\", value=\"A value for a Read Only Album"); + + "for key=\"KeyReadOnly\", value=\"A value for a Read Only Album"); Map<String, Object> putAllData = new LinkedHashMap<>(); putAllData.put("AllKey0", "vaue of AllKey0"); @@ -165,9 +164,8 @@ public class ContextAlbumImplTest { assertThatThrownBy(() -> albumRo.putAll(putAllData)) .hasMessage("album \"TestContextAlbum:0.0.1\" putAll() not allowed on read only albums"); - assertThatThrownBy(() -> albumRo.remove("AllKey0")) - .hasMessage("album \"TestContextAlbum:0.0.1\" remove() not allowed " - + "on read only albums for key=\"AllKey0\""); + assertThatThrownBy(() -> albumRo.remove("AllKey0")).hasMessage( + "album \"TestContextAlbum:0.0.1\" remove() not allowed " + "on read only albums for key=\"AllKey0\""); assertThatThrownBy(() -> album.remove(null)) .hasMessage("null values are illegal on method parameter \"keyID\""); @@ -175,7 +173,8 @@ public class ContextAlbumImplTest { assertThatThrownBy(albumRo::clear) .hasMessage("album \"TestContextAlbum:0.0.1\" clear() not allowed on read only albums"); - // The following locking tests pass because the locking protects access to Key0 across all + // The following locking tests pass because the locking protects access to Key0 + // across all // copies of the distributed album whether the key exists or not album.lockForReading("Key0"); assertEquals(null, album.get("Key0")); @@ -205,8 +204,7 @@ public class ContextAlbumImplTest { AxArtifactKey somePolicyKey = new AxArtifactKey("MyPolicy", "0.0.1"); AxReferenceKey somePolicyState = new AxReferenceKey(somePolicyKey, "SomeState"); - AxConcept[] userArtifactStack = - { somePolicyKey, somePolicyState }; + AxConcept[] userArtifactStack = { somePolicyKey, somePolicyState }; album.setUserArtifactStack(userArtifactStack); assertEquals("MyPolicy:0.0.1", album.getUserArtifactStack()[0].getId()); assertEquals("MyPolicy:0.0.1:NULL:SomeState", album.getUserArtifactStack()[1].getId()); @@ -215,10 +213,10 @@ public class ContextAlbumImplTest { assertEquals(true, album.values().contains("value of Key0")); assertEquals(1, album.entrySet().size()); - // The flush() operation fails because the distributor is not initialized with the album which + // The flush() operation fails because the distributor is not initialized with + // the album which // is fine for unit test - assertThatThrownBy(album::flush) - .hasMessage("map flush failed, supplied map is null"); + assertThatThrownBy(album::flush).hasMessage("map flush failed, supplied map is null"); assertEquals(1, album.size()); assertEquals(false, album.isEmpty()); @@ -229,8 +227,7 @@ public class ContextAlbumImplTest { putAllData.put("AllKey3", null); assertThatThrownBy(() -> album.putAll(putAllData)) - .hasMessage("album \"TestContextAlbum:0.0.1\" null values are illegal on key " - + "\"AllKey3\" for put()"); + .hasMessage("album \"TestContextAlbum:0.0.1\" null values are illegal on key " + "\"AllKey3\" for put()"); assertEquals("New value of Key0", album.remove("Key0")); album.clear(); @@ -239,20 +236,19 @@ public class ContextAlbumImplTest { ModelService.clear(); } - @SuppressWarnings("unlikely-arg-type") @Test public void testCompareToEqualsHash() throws ContextException { AxContextSchemas schemas = new AxContextSchemas(); AxContextSchema simpleIntSchema = new AxContextSchema(new AxArtifactKey("SimpleIntSchema", "0.0.1"), "JAVA", - "java.lang.Integer"); + "java.lang.Integer"); schemas.getSchemasMap().put(simpleIntSchema.getKey(), simpleIntSchema); AxContextSchema simpleStringSchema = new AxContextSchema(new AxArtifactKey("SimpleStringSchema", "0.0.1"), - "JAVA", "java.lang.String"); + "JAVA", "java.lang.String"); schemas.getSchemasMap().put(simpleStringSchema.getKey(), simpleStringSchema); ModelService.registerModel(AxContextSchemas.class, schemas); AxContextAlbum axContextAlbum = new AxContextAlbum(new AxArtifactKey("TestContextAlbum", "0.0.1"), "Policy", - true, AxArtifactKey.getNullKey()); + true, AxArtifactKey.getNullKey()); axContextAlbum.setItemSchema(simpleIntSchema.getKey()); Distributor distributor = new JvmLocalDistributor(); @@ -268,7 +264,7 @@ public class ContextAlbumImplTest { assertNotEquals(album, new DummyContextAlbumImpl()); ContextAlbumImpl otherAlbum = new ContextAlbumImpl(axContextAlbum, distributor, - new LinkedHashMap<String, Object>()); + new LinkedHashMap<String, Object>()); assertEquals(album, otherAlbum); otherAlbum.put("Key", 123); @@ -276,20 +272,19 @@ public class ContextAlbumImplTest { assertThatThrownBy(() -> { ContextAlbumImpl otherAlbumBad = new ContextAlbumImpl(axContextAlbum, distributor, - new LinkedHashMap<String, Object>()); + new LinkedHashMap<String, Object>()); otherAlbumBad.put("Key", "BadValue"); }).hasMessage("Failed to set context value for key \"Key\" in album \"TestContextAlbum:0.0.1\": " - + "TestContextAlbum:0.0.1: object \"BadValue\" of class \"java.lang.String\" " - + "not compatible with class \"java.lang.Integer\""); + + "TestContextAlbum:0.0.1: object \"BadValue\" of class \"java.lang.String\" " + + "not compatible with class \"java.lang.Integer\""); AxContextAlbum otherAxContextAlbum = new AxContextAlbum(new AxArtifactKey("OtherTestContextAlbum", "0.0.1"), - "Policy", true, AxArtifactKey.getNullKey()); + "Policy", true, AxArtifactKey.getNullKey()); otherAxContextAlbum.setItemSchema(simpleStringSchema.getKey()); otherAlbum = new ContextAlbumImpl(otherAxContextAlbum, distributor, new LinkedHashMap<String, Object>()); assertNotEquals(album, otherAlbum); - assertThatThrownBy(album::flush) - .hasMessage("map flush failed, supplied map is null"); + assertThatThrownBy(album::flush).hasMessage("map flush failed, supplied map is null"); AxContextAlbums albums = new AxContextAlbums(); ModelService.registerModel(AxContextAlbums.class, albums); albums.getAlbumsMap().put(axContextAlbum.getKey(), axContextAlbum); diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnFieldTest.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnFieldTest.java index 168ab1d78..dbe2fa3c8 100644 --- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnFieldTest.java +++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnFieldTest.java @@ -25,7 +25,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import org.junit.After; import org.junit.Before; @@ -71,7 +70,7 @@ public class EnFieldTest { assertThatThrownBy(() -> new EnField(axField, null)) .hasMessage("schema helper cannot be created for parameter with key \"Parent:0.0.1:MyParent:My" - + "Field\" with schema \"AxArtifactKey:(name=FieldSchema,version=0.0.1)\""); + + "Field\" with schema \"AxArtifactKey:(name=FieldSchema,version=0.0.1)\""); AxContextSchema schema = new AxContextSchema(fieldSchemaKey, "Java", "java.lang.Integer"); ModelService.getModel(AxContextSchemas.class).getSchemasMap().put(fieldSchemaKey, schema); EnField field = new EnField(axField, 123); @@ -81,11 +80,11 @@ public class EnFieldTest { assertEquals(fieldKey, field.getKey()); assertEquals("MyField", field.getName()); assertEquals("org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelper", - field.getSchemaHelper().getClass().getName()); + field.getSchemaHelper().getClass().getName()); assertEquals(123, field.getAssignableValue()); assertEquals("EnField [axField=AxField:(key=AxReferenceKey:(parentKeyName=Parent,parentKeyVersion=0.0.1," - + "parentLocalName=MyParent,localName=MyField),fieldSchemaKey=AxArtifactKey:" - + "(name=FieldSchema,version=0.0.1),optional=false), value=123]", field.toString()); + + "parentLocalName=MyParent,localName=MyField),fieldSchemaKey=AxArtifactKey:" + + "(name=FieldSchema,version=0.0.1),optional=false), value=123]", field.toString()); assertTrue(field.isAssignableValue()); field = new EnField(axField, "Hello"); diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/DummyAction.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/DummyAction.java index bc8d5e5c1..3d15a8c01 100644 --- a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/DummyAction.java +++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/DummyAction.java @@ -1,34 +1,33 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ package org.onap.policy.apex.core.protocols; -import org.onap.policy.apex.core.protocols.Action; - /** * Dummy action for testing. */ public class DummyAction implements Action { private static final long serialVersionUID = 9178856761163651594L; - - private String actionString = "An Action String"; + + private String actionString = "An Action String"; public DummyAction(final String actionString) { this.actionString = actionString; @@ -59,15 +58,15 @@ public class DummyAction implements Action { if (this == obj) { return true; } - + if (obj == null) { return false; } - + if (getClass() != obj.getClass()) { return false; } - + DummyAction other = (DummyAction) obj; if (actionString == null) { if (other.actionString != null) { diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/DummyMessage.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/DummyMessage.java index aeeb43dda..5e32c00e4 100644 --- a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/DummyMessage.java +++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/DummyMessage.java @@ -1,26 +1,26 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ package org.onap.policy.apex.core.protocols; -import org.onap.policy.apex.core.protocols.Message; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; /** @@ -33,7 +33,7 @@ public class DummyMessage extends Message { public DummyMessage(final Action action, final AxArtifactKey targetKey) { super(action, targetKey); } - + public DummyMessage(final Action action, final AxArtifactKey targetKey, final String messageData) { super(action, targetKey, messageData); } diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/SupportMessageTester.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/SupportMessageTester.java index db13069f1..c4de748ee 100644 --- a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/SupportMessageTester.java +++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/SupportMessageTester.java @@ -34,7 +34,6 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; */ public class SupportMessageTester { - @SuppressWarnings("unlikely-arg-type") @Test public void testMessage() { assertNotNull(new DummyMessage(new DummyAction(null), new AxArtifactKey())); @@ -43,7 +42,7 @@ public class SupportMessageTester { DummyMessage dummyMessage = new DummyMessage(new DummyAction(null), new AxArtifactKey("Target:0.0.1")); assertEquals(new DummyAction(null), dummyMessage.getAction()); assertEquals("Message [action=org.onap.policy.apex.core.protocols.DummyAction@1f, " - + "targetKey=AxArtifactKey:(name=Target,version=0.0.1), data=null]", dummyMessage.toString()); + + "targetKey=AxArtifactKey:(name=Target,version=0.0.1), data=null]", dummyMessage.toString()); dummyMessage.setMessageData("Message Data"); assertEquals("Message Data", dummyMessage.getMessageData()); diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/ResponseTest.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/ResponseTest.java index 35fe5bb9f..a78c670b5 100644 --- a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/ResponseTest.java +++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/ResponseTest.java @@ -47,7 +47,6 @@ public class ResponseTest { * * @throws UnknownHostException the unknown host exception */ - @SuppressWarnings("unlikely-arg-type") @Test public void testResponse() throws UnknownHostException { final AxArtifactKey responseKey = new AxArtifactKey("ResponseTest", "0.0.1"); diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/UpdateModelTest.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/UpdateModelTest.java index 13d37a8f6..953c6fa8a 100644 --- a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/UpdateModelTest.java +++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/UpdateModelTest.java @@ -49,7 +49,6 @@ public class UpdateModelTest { * * @throws UnknownHostException the unknown host exception */ - @SuppressWarnings("unlikely-arg-type") @Test public void testRegisterEntity() throws UnknownHostException { assertNotNull(new UpdateModel(new AxArtifactKey())); diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTester.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTester.java index 2680a6e71..786df5258 100644 --- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTester.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTester.java @@ -24,7 +24,6 @@ package org.onap.policy.apex.model.basicmodel.handling; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; import java.io.File; import java.io.FileInputStream; @@ -44,47 +43,47 @@ public class SupportConceptGetterTester { assertNotNull(basicModel); AxKeyInfo intKI01 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey01", "0.0.1"), UUID.randomUUID(), - "IntegerKIKey01 description"); + "IntegerKIKey01 description"); AxKeyInfo intKI11 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey11", "0.0.1"), UUID.randomUUID(), - "IntegerKIKey11 description"); + "IntegerKIKey11 description"); AxKeyInfo intKI21 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey21", "0.0.1"), UUID.randomUUID(), - "IntegerKIKey21 description"); + "IntegerKIKey21 description"); AxKeyInfo intKI22 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey22", "0.0.2"), UUID.randomUUID(), - "IntegerKIKey22 description"); + "IntegerKIKey22 description"); AxKeyInfo intKI23 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey23", "0.0.3"), UUID.randomUUID(), - "IntegerKIKey23 description"); + "IntegerKIKey23 description"); AxKeyInfo intKI24 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey24", "0.0.4"), UUID.randomUUID(), - "IntegerKIKey24 description"); + "IntegerKIKey24 description"); AxKeyInfo intKI25 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey25", "0.0.5"), UUID.randomUUID(), - "IntegerKIKey25 description"); + "IntegerKIKey25 description"); AxKeyInfo intKI26 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey26", "0.0.6"), UUID.randomUUID(), - "IntegerKIKey26 description"); + "IntegerKIKey26 description"); AxKeyInfo intKI31 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey31", "0.0.1"), UUID.randomUUID(), - "IntegerKIKey31 description"); + "IntegerKIKey31 description"); AxKeyInfo intKI41 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey41", "0.0.1"), UUID.randomUUID(), - "IntegerKIKey41 description"); + "IntegerKIKey41 description"); AxKeyInfo intKI51 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey51", "0.0.1"), UUID.randomUUID(), - "IntegerKIKey51 description"); + "IntegerKIKey51 description"); AxKeyInfo intKI52 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey52", "0.0.2"), UUID.randomUUID(), - "IntegerKIKey52 description"); + "IntegerKIKey52 description"); AxKeyInfo intKI53 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey53", "0.0.3"), UUID.randomUUID(), - "IntegerKIKey53 description"); + "IntegerKIKey53 description"); AxKeyInfo intKI54 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey54", "0.0.4"), UUID.randomUUID(), - "IntegerKIKey54 description"); + "IntegerKIKey54 description"); AxKeyInfo intKI61 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey61", "0.0.1"), UUID.randomUUID(), - "IntegerKIKey61 description"); + "IntegerKIKey61 description"); AxKeyInfo intKI62 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey62", "0.0.2"), UUID.randomUUID(), - "IntegerKIKey62 description"); + "IntegerKIKey62 description"); AxKeyInfo intKI63 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey63", "0.0.3"), UUID.randomUUID(), - "IntegerKIKey63 description"); + "IntegerKIKey63 description"); AxKeyInfo intKI64 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey64", "0.0.4"), UUID.randomUUID(), - "IntegerKIKey64 description"); + "IntegerKIKey64 description"); AxKeyInfo intKI71 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey71", "0.0.1"), UUID.randomUUID(), - "IntegerKIKey71 description"); + "IntegerKIKey71 description"); AxKeyInfo intKI81 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey81", "0.0.1"), UUID.randomUUID(), - "IntegerKIKey81 description"); + "IntegerKIKey81 description"); AxKeyInfo intKI91 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey91", "0.0.1"), UUID.randomUUID(), - "IntegerKIKey91 description"); + "IntegerKIKey91 description"); basicModel.getKeyInformation().getKeyInfoMap().put(intKI31.getKey(), intKI31); basicModel.getKeyInformation().getKeyInfoMap().put(intKI24.getKey(), intKI24); basicModel.getKeyInformation().getKeyInfoMap().put(intKI11.getKey(), intKI11); @@ -108,33 +107,33 @@ public class SupportConceptGetterTester { basicModel.getKeyInformation().getKeyInfoMap().put(intKI63.getKey(), intKI63); AxKeyInfo floatKI01 = new AxKeyInfo(new AxArtifactKey("FloatKIKey01", "0.0.1"), UUID.randomUUID(), - "IntegerKIKey01 description"); + "IntegerKIKey01 description"); AxKeyInfo floatKI11 = new AxKeyInfo(new AxArtifactKey("FloatKIKey11", "0.0.1"), UUID.randomUUID(), - "IntegerKIKey11 description"); + "IntegerKIKey11 description"); AxKeyInfo floatKI21 = new AxKeyInfo(new AxArtifactKey("FloatKIKey21", "0.0.1"), UUID.randomUUID(), - "IntegerKIKey21 description"); + "IntegerKIKey21 description"); AxKeyInfo floatKI31 = new AxKeyInfo(new AxArtifactKey("FloatKIKey31", "0.0.1"), UUID.randomUUID(), - "IntegerKIKey31 description"); + "IntegerKIKey31 description"); AxKeyInfo floatKI41 = new AxKeyInfo(new AxArtifactKey("FloatKIKey41", "0.0.1"), UUID.randomUUID(), - "IntegerKIKey41 description"); + "IntegerKIKey41 description"); AxKeyInfo floatKI51 = new AxKeyInfo(new AxArtifactKey("FloatKIKey51", "0.0.1"), UUID.randomUUID(), - "IntegerKIKey51 description"); + "IntegerKIKey51 description"); AxKeyInfo floatKI61 = new AxKeyInfo(new AxArtifactKey("FloatKIKey61", "0.0.1"), UUID.randomUUID(), - "IntegerKIKey61 description"); + "IntegerKIKey61 description"); AxKeyInfo floatKI71 = new AxKeyInfo(new AxArtifactKey("FloatKIKey71", "0.0.1"), UUID.randomUUID(), - "IntegerKIKey71 description"); + "IntegerKIKey71 description"); AxKeyInfo floatKI81 = new AxKeyInfo(new AxArtifactKey("FloatKIKey81", "0.0.1"), UUID.randomUUID(), - "IntegerKIKey81 description"); + "IntegerKIKey81 description"); AxKeyInfo floatKI82 = new AxKeyInfo(new AxArtifactKey("FloatKIKey82", "0.0.2"), UUID.randomUUID(), - "IntegerKIKey82 description"); + "IntegerKIKey82 description"); AxKeyInfo floatKI83 = new AxKeyInfo(new AxArtifactKey("FloatKIKey83", "0.0.3"), UUID.randomUUID(), - "IntegerKIKey83 description"); + "IntegerKIKey83 description"); AxKeyInfo floatKI91 = new AxKeyInfo(new AxArtifactKey("FloatKIKey91", "0.0.1"), UUID.randomUUID(), - "IntegerKIKey91 description"); + "IntegerKIKey91 description"); AxKeyInfo floatKI92 = new AxKeyInfo(new AxArtifactKey("FloatKIKey92", "0.0.2"), UUID.randomUUID(), - "IntegerKIKey92 description"); + "IntegerKIKey92 description"); AxKeyInfo floatKI93 = new AxKeyInfo(new AxArtifactKey("FloatKIKey93", "0.0.3"), UUID.randomUUID(), - "IntegerKIKey93 description"); + "IntegerKIKey93 description"); basicModel.getKeyInformation().getKeyInfoMap().put(floatKI11.getKey(), floatKI11); basicModel.getKeyInformation().getKeyInfoMap().put(floatKI83.getKey(), floatKI83); basicModel.getKeyInformation().getKeyInfoMap().put(floatKI51.getKey(), floatKI51); diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java index 02195e4db..4071803a0 100644 --- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java +++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java @@ -144,11 +144,9 @@ public class ApexModelApiTest { @Test public void testApexModelUrl() throws IOException { final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false); - //ApexApiResult result = null; - assertThatThrownBy(() -> apexModel.readFromUrl(null)) - .isInstanceOf(IllegalArgumentException.class); - assertThatThrownBy(() -> apexModel.writeToUrl(null, true)) - .isInstanceOf(IllegalArgumentException.class); + + assertThatThrownBy(() -> apexModel.readFromUrl(null)).isInstanceOf(IllegalArgumentException.class); + assertThatThrownBy(() -> apexModel.writeToUrl(null, true)).isInstanceOf(IllegalArgumentException.class); ApexApiResult result = null; result = apexModel.readFromUrl("zooby/looby"); assertEquals(ApexApiResult.Result.FAILED, result.getResult()); @@ -162,8 +160,6 @@ public class ApexModelApiTest { result = apexModel.writeToUrl("zooby://zooby/looby", false); assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - final ApexModel apexModelJSon = new ApexModelFactory().createApexModel(null, false); - final File tempJsonModelFile = File.createTempFile("ApexModelTest", ".json"); result = apexModel.saveToFile(tempJsonModelFile.getCanonicalPath(), false); diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/DummyLogicReader.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/DummyLogicReader.java index 42f2fc754..007288343 100644 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/DummyLogicReader.java +++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/DummyLogicReader.java @@ -1,27 +1,26 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ package org.onap.policy.apex.model.policymodel.concepts; -import org.onap.policy.apex.model.policymodel.concepts.AxLogicReader; - public class DummyLogicReader implements AxLogicReader { /** diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java index e506513a8..fafde8b98 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java @@ -26,7 +26,6 @@ import static org.awaitility.Awaitility.await; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import java.io.ByteArrayOutputStream; import java.io.PrintStream; @@ -78,8 +77,8 @@ public class ApexRestClientConusmerTest { EventHandlerParameters consumerParameters = new EventHandlerParameters(); SupportApexEventReceiver incomingEventReceiver = new SupportApexEventReceiver(); assertThatThrownBy(() -> arcc.init("RestClientConsumer", consumerParameters, incomingEventReceiver)) - .hasMessageContaining("specified consumer properties are not applicable to REST client" - + " consumer (RestClientConsumer)"); + .hasMessageContaining( + "specified consumer properties are not applicable to REST client" + " consumer (RestClientConsumer)"); RestClientCarrierTechnologyParameters rcctp = new RestClientCarrierTechnologyParameters(); consumerParameters.setCarrierTechnologyParameters(rcctp); @@ -87,7 +86,7 @@ public class ApexRestClientConusmerTest { assertThatThrownBy(() -> { arcc.init("RestClientConsumer", consumerParameters, incomingEventReceiver); }).hasMessageContaining("specified HTTP method of \"DELETE\" is invalid, only HTTP method \"GET\" is " - + "supported for event reception on REST client consumer (RestClientConsumer)"); + + "supported for event reception on REST client consumer (RestClientConsumer)"); assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.DELETE, rcctp.getHttpMethod()); rcctp.setHttpMethod(null); diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java index 2da6a5c73..2a10e70ca 100644 --- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java +++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java @@ -22,10 +22,7 @@ package org.onap.policy.apex.plugins.executor.javascript; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import java.util.HashMap; -import java.util.Map; import java.util.Properties; import org.junit.After; import org.junit.Before; @@ -94,7 +91,7 @@ public class JavascriptStateFinalizerExecutorTest { assertThatThrownBy(() -> { jsfe.prepare(); }).hasMessage("logic failed to compile for NULL:0.0.0:NULL:NULL " - + "with message: invalid return (NULL:0.0.0:NULL:NULL#1)"); + + "with message: invalid return (NULL:0.0.0:NULL:NULL#1)"); stateFinalizerLogic.setLogic("java.lang.String"); jsfe.prepare(); @@ -102,10 +99,10 @@ public class JavascriptStateFinalizerExecutorTest { AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1")); EnEvent event = new EnEvent(axEvent); stateFinalizerLogic.setLogic("if(executor.executionId==-1)" + "{\r\n" - + "var returnValueType = java.lang.Boolean;" + "var returnValue = new returnValueType(false); }\n" - + "else{\n" + "executor.setSelectedStateOutputName(\"SelectedOutputIsMe\");\n" - + "var returnValueType = java.lang.Boolean;\n" + "\n" - + "var returnValue = new returnValueType(true);} true;"); + + "var returnValueType = java.lang.Boolean;" + "var returnValue = new returnValueType(false); }\n" + + "else{\n" + "executor.setSelectedStateOutputName(\"SelectedOutputIsMe\");\n" + + "var returnValueType = java.lang.Boolean;\n" + "\n" + + "var returnValue = new returnValueType(true);} true;"); assertThatThrownBy(() -> { jsfe.prepare(); diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java index a6e410cd0..78ac85366 100644 --- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java +++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java @@ -22,7 +22,6 @@ package org.onap.policy.apex.plugins.executor.javascript; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import java.util.Properties; @@ -83,9 +82,6 @@ public class JavascriptTaskSelectExecutorTest { jtse.prepare(); }).hasMessage("no logic specified for NULL:0.0.0:NULL:NULL"); - AxEvent axEvent1 = new AxEvent(new AxArtifactKey("Event", "0.0.1")); - EnEvent event1 = new EnEvent(axEvent1); - state.getTaskSelectionLogic().setLogic("java.lang.String"); jtse.prepare(); @@ -99,7 +95,7 @@ public class JavascriptTaskSelectExecutorTest { assertThatThrownBy(() -> { jtse.execute(-1, new Properties(), event); }).hasMessage( - "execute: logic for NULL:0.0.0:NULL:NULL returned a non-boolean value [JavaClass java.lang.String]"); + "execute: logic for NULL:0.0.0:NULL:NULL returned a non-boolean value [JavaClass java.lang.String]"); state.getTaskSelectionLogic().setLogic("var x=1;\n" + "false; "); diff --git a/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutorTest.java b/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutorTest.java index 2cd19c6f6..4dd400bbc 100644 --- a/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutorTest.java +++ b/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutorTest.java @@ -47,17 +47,12 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; import org.onap.policy.apex.model.policymodel.concepts.AxState; import org.onap.policy.apex.model.policymodel.concepts.AxStateFinalizerLogic; import org.onap.policy.common.parameters.ParameterService; -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; /** * Test the MvelStateFinalizerExecutor class. * */ public class MvelStateFinalizerExecutorTest { - - private static final XLogger LOGGER = XLoggerFactory.getXLogger(MvelStateFinalizerExecutorTest.class); - /** * Initiate Parameters. */ @@ -85,8 +80,7 @@ public class MvelStateFinalizerExecutorTest { MvelStateFinalizerExecutor msfe = new MvelStateFinalizerExecutor(); assertNotNull(msfe); - assertThatThrownBy(msfe::prepare) - .isInstanceOf(java.lang.NullPointerException.class); + assertThatThrownBy(msfe::prepare).isInstanceOf(java.lang.NullPointerException.class); ApexInternalContext internalContext = null; internalContext = new ApexInternalContext(new AxPolicyModel()); @@ -100,8 +94,7 @@ public class MvelStateFinalizerExecutorTest { msfe.setContext(parentStateExcutor, stateFinalizerLogic, internalContext); stateFinalizerLogic.setLogic("x > 1 2 ()"); - assertThatThrownBy(msfe::prepare) - .hasMessage("failed to compile MVEL code for state NULL:0.0.0:NULL:NULL"); + assertThatThrownBy(msfe::prepare).hasMessage("failed to compile MVEL code for state NULL:0.0.0:NULL:NULL"); stateFinalizerLogic.setLogic("java.lang.String"); msfe.prepare(); @@ -117,9 +110,9 @@ public class MvelStateFinalizerExecutorTest { assertThatThrownBy(() -> msfe.execute(-1, new Properties(), event)) .hasMessage("execute-post: state finalizer logic execution failure on state \"NULL:0.0.0:" + "NULL:NULL\" on finalizer logic NULL:0.0.0:NULL:NULL"); - stateFinalizerLogic.setLogic( - "if (executionId == -1) {return false;}setSelectedStateOutputName(\"SelectedOutputIsMe\");" - + "return true;"); + stateFinalizerLogic + .setLogic("if (executionId == -1) {return false;}setSelectedStateOutputName(\"SelectedOutputIsMe\");" + + "return true;"); state.getStateOutputs().put("SelectedOutputIsMe", null); msfe.prepare(); diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ApexParametersTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ApexParametersTest.java index 330de42dd..1c816768f 100644 --- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ApexParametersTest.java +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ApexParametersTest.java @@ -27,7 +27,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import org.junit.Test; import org.onap.policy.apex.service.engine.main.ApexCommandLineArguments; @@ -42,7 +41,7 @@ public class ApexParametersTest { @Test public void testJavaPropertiesOk() throws ParameterException { - final String[] args = {"-c", "src/test/resources/parameters/javaPropertiesOK.json"}; + final String[] args = { "-c", "src/test/resources/parameters/javaPropertiesOK.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); ApexParameters parameters = new ApexParameterHandler().getParameters(arguments); @@ -56,7 +55,7 @@ public class ApexParametersTest { @Test public void testJavaPropertiesEmpty() throws ParameterException { - final String[] args = {"-c", "src/test/resources/parameters/javaPropertiesEmpty.json"}; + final String[] args = { "-c", "src/test/resources/parameters/javaPropertiesEmpty.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); ApexParameters parameters = new ApexParameterHandler().getParameters(arguments); @@ -66,7 +65,7 @@ public class ApexParametersTest { @Test public void testJavaPropertiesBad() throws ParameterException { - final String[] args = {"-c", "src/test/resources/parameters/javaPropertiesBad.json"}; + final String[] args = { "-c", "src/test/resources/parameters/javaPropertiesBad.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)) diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java index 018fda668..e8485d109 100644 --- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java @@ -23,7 +23,6 @@ package org.onap.policy.apex.service.engine.parameters; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; import org.junit.Test; import org.onap.policy.apex.service.engine.main.ApexCommandLineArguments; @@ -41,30 +40,29 @@ public class ContextParameterTests { @Test public void testNoParamsTest() { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextNoParams.json"}; + final String[] args = { "-c", "src/test/resources/parameters/serviceContextNoParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)) .hasMessage("error reading parameters from \"src/test/resources/parameters/serviceContextNoParams.json\"\n" - + "(ParameterRuntimeException):could not find field \"parameterClassName\" in " - + "\"contextParameters\" entry"); + + "(ParameterRuntimeException):could not find field \"parameterClassName\" in " + + "\"contextParameters\" entry"); } @Test public void testBadParamsTest() { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextBadParams.json"}; + final String[] args = { "-c", "src/test/resources/parameters/serviceContextBadParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)) .hasMessage("error reading parameters from \"src/test/resources/parameters/serviceContextBadParams.json\"" - + "\n(ParameterRuntimeException):failed to deserialize the parameters for " - + "\"contextParameters\" to parameter class " - + "\"hello\"\njava.lang.ClassNotFoundException: hello"); + + "\n(ParameterRuntimeException):failed to deserialize the parameters for " + + "\"contextParameters\" to parameter class " + "\"hello\"\njava.lang.ClassNotFoundException: hello"); } @Test public void testBadPluginParamNameTest() { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextBadPluginNameParams.json"}; + final String[] args = { "-c", "src/test/resources/parameters/serviceContextBadPluginNameParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)) @@ -76,21 +74,19 @@ public class ContextParameterTests { @Test public void testBadClassParamTest() { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextBadClassParams.json"}; + final String[] args = { "-c", "src/test/resources/parameters/serviceContextBadClassParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); - assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)) - .hasMessage("error reading parameters from " - + "\"src/test/resources/parameters/serviceContextBadClassParams.json\"" - + "\n(ParameterRuntimeException):failed to deserialize " - + "the parameters for \"contextParameters\"" + assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)).hasMessage( + "error reading parameters from " + "\"src/test/resources/parameters/serviceContextBadClassParams.json\"" + + "\n(ParameterRuntimeException):failed to deserialize " + "the parameters for \"contextParameters\"" + " to parameter class \"java.lang.Integer\"\ncom.google.gson.JsonSyntaxException: " + "java.lang.IllegalStateException: Expected NUMBER but was BEGIN_OBJECT at path $"); } @Test public void testBadPluginClassTest() { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextBadPluginClassParams.json"}; + final String[] args = { "-c", "src/test/resources/parameters/serviceContextBadPluginClassParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)) @@ -106,88 +102,87 @@ public class ContextParameterTests { @Test public void testOkFlushParamTest() throws ParameterException { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextOKFlushParams.json"}; + final String[] args = { "-c", "src/test/resources/parameters/serviceContextOKFlushParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments); - assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", parameters - .getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getName()); + assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getName()); assertEquals(123456, parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() - .getPersistorParameters().getFlushPeriod()); + .getPersistorParameters().getFlushPeriod()); } @Test public void testOkDefaultParamTest() throws ParameterException { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextOKDefaultParams.json"}; + final String[] args = { "-c", "src/test/resources/parameters/serviceContextOKDefaultParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments); - assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", parameters - .getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getName()); + assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getName()); assertEquals(300000, parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() - .getPersistorParameters().getFlushPeriod()); + .getPersistorParameters().getFlushPeriod()); } @Test public void testOkDistParamTest() throws ParameterException { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextOKDistParams.json"}; + final String[] args = { "-c", "src/test/resources/parameters/serviceContextOKDistParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments); - assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", parameters - .getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getName()); + assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getName()); assertEquals("org.onap.policy.apex.context.parameters.DistributorParameters", - parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() - .getDistributorParameters().getClass().getName()); + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getDistributorParameters().getClass().getName()); } @Test public void testOkFullDefaultParamTest() throws ParameterException { - final String[] args = {"-c", "src/test/resources/parameters/goodParams.json"}; + final String[] args = { "-c", "src/test/resources/parameters/goodParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments); - assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", parameters - .getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getName()); + assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getName()); assertEquals("org.onap.policy.apex.context.parameters.DistributorParameters", - parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() - .getDistributorParameters().getClass().getName()); + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getDistributorParameters().getClass().getName()); assertEquals("org.onap.policy.apex.context.parameters.LockManagerParameters", - parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() - .getLockManagerParameters().getClass().getName()); + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getLockManagerParameters().getClass().getName()); assertEquals("org.onap.policy.apex.context.parameters.PersistorParameters", - parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() - .getPersistorParameters().getClass().getName()); + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getPersistorParameters().getClass().getName()); assertEquals(300000, parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() - .getPersistorParameters().getFlushPeriod()); + .getPersistorParameters().getFlushPeriod()); } @Test public void testOkFullParamTest() throws ParameterException { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextOKFullParams.json"}; + final String[] args = { "-c", "src/test/resources/parameters/serviceContextOKFullParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments); - assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", parameters - .getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getName()); + assertEquals("org.onap.policy.apex.context.parameters.ContextParameters", + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters().getClass().getName()); assertEquals("org.onap.policy.apex.context.parameters.LockManagerParameters", - parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() - .getLockManagerParameters().getClass().getName()); + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getLockManagerParameters().getClass().getName()); assertEquals("org.onap.policy.apex.context.parameters.PersistorParameters", - parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() - .getPersistorParameters().getClass().getName()); + parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getPersistorParameters().getClass().getName()); assertEquals(123456, parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() - .getPersistorParameters().getFlushPeriod()); + .getPersistorParameters().getFlushPeriod()); - final SuperDooperDistributorParameters infinispanParameters = - (SuperDooperDistributorParameters) parameters.getEngineServiceParameters().getEngineParameters() - .getContextParameters().getDistributorParameters(); + final SuperDooperDistributorParameters infinispanParameters = (SuperDooperDistributorParameters) parameters + .getEngineServiceParameters().getEngineParameters().getContextParameters().getDistributorParameters(); assertEquals("org.onap.policy.apex.service.engine.parameters.dummyclasses.SuperDooperDistributorParameters", - infinispanParameters.getClass().getName()); + infinispanParameters.getClass().getName()); assertEquals("my/lovely/configFile.xml", infinispanParameters.getConfigFile()); assertEquals("holy/stone.xml", infinispanParameters.getJgroupsFile()); assertEquals(false, infinispanParameters.isPreferIPv4Stack()); @@ -197,7 +192,7 @@ public class ContextParameterTests { @Test public void testBadClassDistParamTest() { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextBadClassDistParams.json"}; + final String[] args = { "-c", "src/test/resources/parameters/serviceContextBadClassDistParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)) @@ -212,7 +207,7 @@ public class ContextParameterTests { @Test public void testBadClassLockParamTest() { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextBadClassLockParams.json"}; + final String[] args = { "-c", "src/test/resources/parameters/serviceContextBadClassLockParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)) @@ -227,7 +222,7 @@ public class ContextParameterTests { @Test public void testBadClassPersistParamTest() { - final String[] args = {"-c", "src/test/resources/parameters/serviceContextBadClassPersistParams.json"}; + final String[] args = { "-c", "src/test/resources/parameters/serviceContextBadClassPersistParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)) diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java index a80aa09c8..8c7c9df82 100644 --- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java @@ -24,7 +24,6 @@ package org.onap.policy.apex.service.engine.parameters; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import org.junit.Test; import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.FileCarrierTechnologyParameters; @@ -41,7 +40,7 @@ import org.onap.policy.common.parameters.ParameterException; public class ProducerConsumerTests { @Test public void testGoodParametersTest() throws ParameterException { - final String[] args = {"-c", "src/test/resources/parameters/goodParams.json"}; + final String[] args = { "-c", "src/test/resources/parameters/goodParams.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments); @@ -51,35 +50,34 @@ public class ProducerConsumerTests { assertEquals(45, parameters.getEngineServiceParameters().getId()); assertEquals(19, parameters.getEngineServiceParameters().getInstanceCount()); assertEquals(65522, parameters.getEngineServiceParameters().getDeploymentPort()); - assertEquals("FILE", parameters.getEventOutputParameters().get("FirstProducer") - .getCarrierTechnologyParameters().getLabel()); + assertEquals("FILE", + parameters.getEventOutputParameters().get("FirstProducer").getCarrierTechnologyParameters().getLabel()); assertEquals("JSON", - parameters.getEventOutputParameters().get("FirstProducer").getEventProtocolParameters().getLabel()); - assertEquals("FILE", parameters.getEventOutputParameters().get("MyOtherProducer") - .getCarrierTechnologyParameters().getLabel()); - assertEquals("JSON", parameters.getEventOutputParameters().get("MyOtherProducer") - .getEventProtocolParameters().getLabel()); - assertEquals("FILE", parameters.getEventInputParameters().get("TheFileConsumer1") - .getCarrierTechnologyParameters().getLabel()); - assertEquals("JSON", parameters.getEventInputParameters().get("TheFileConsumer1") - .getEventProtocolParameters().getLabel()); + parameters.getEventOutputParameters().get("FirstProducer").getEventProtocolParameters().getLabel()); + assertEquals("FILE", + parameters.getEventOutputParameters().get("MyOtherProducer").getCarrierTechnologyParameters().getLabel()); + assertEquals("JSON", + parameters.getEventOutputParameters().get("MyOtherProducer").getEventProtocolParameters().getLabel()); + assertEquals("FILE", + parameters.getEventInputParameters().get("TheFileConsumer1").getCarrierTechnologyParameters().getLabel()); + assertEquals("JSON", + parameters.getEventInputParameters().get("TheFileConsumer1").getEventProtocolParameters().getLabel()); assertEquals("SUPER_DOOPER", parameters.getEventInputParameters().get("MySuperDooperConsumer1") - .getCarrierTechnologyParameters().getLabel()); - assertEquals("SUPER_TOK_DEL", parameters.getEventInputParameters().get("MySuperDooperConsumer1") - .getEventProtocolParameters().getLabel()); + .getCarrierTechnologyParameters().getLabel()); + assertEquals("SUPER_TOK_DEL", + parameters.getEventInputParameters().get("MySuperDooperConsumer1").getEventProtocolParameters().getLabel()); } @Test public void testNoCarrierTechnology() { - final String[] args = {"-c", "src/test/resources/parameters/prodConsNoCT.json"}; + final String[] args = { "-c", "src/test/resources/parameters/prodConsNoCT.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)) .hasMessage("validation error(s) on parameters from \"src/test/resources/parameters/prodConsNoCT.json\"\n" + "parameter group \"APEX_PARAMETERS\" type " + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, " - + "parameter group has status INVALID\n" - + " parameter group map \"eventInputParameters\" INVALID, " + + "parameter group has status INVALID\n" + " parameter group map \"eventInputParameters\" INVALID, " + "parameter group map has status INVALID\n" + " parameter group \"aConsumer\" type " + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID," + " parameter group has status INVALID\n" + " parameter group \"UNDEFINED\" INVALID, " @@ -88,15 +86,14 @@ public class ProducerConsumerTests { @Test public void testNoEventProcol() { - final String[] args = {"-c", "src/test/resources/parameters/prodConsNoEP.json"}; + final String[] args = { "-c", "src/test/resources/parameters/prodConsNoEP.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)) .hasMessage("validation error(s) on parameters from \"src/test/resources/parameters/prodConsNoEP.json\"\n" + "parameter group \"APEX_PARAMETERS\" type " + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, " - + "parameter group has status INVALID\n" - + " parameter group map \"eventOutputParameters\" INVALID, " + + "parameter group has status INVALID\n" + " parameter group map \"eventOutputParameters\" INVALID, " + "parameter group map has status INVALID\n" + " parameter group \"aProducer\" type " + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID" + ", parameter group has status INVALID\n" + " parameter group \"UNDEFINED\" INVALID, " @@ -114,7 +111,7 @@ public class ProducerConsumerTests { @Test public void testNoCarrierTechnologyParClass() { - final String[] args = {"-c", "src/test/resources/parameters/prodConsNoCTParClass.json"}; + final String[] args = { "-c", "src/test/resources/parameters/prodConsNoCTParClass.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)) @@ -125,27 +122,24 @@ public class ProducerConsumerTests { @Test public void testMismatchCarrierTechnologyParClass() { - final String[] args = {"-c", "src/test/resources/parameters/prodConsMismatchCTParClass.json"}; + final String[] args = { "-c", "src/test/resources/parameters/prodConsMismatchCTParClass.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); - assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)) - .hasMessage("error reading parameters from " - + "\"src/test/resources/parameters/prodConsMismatchCTParClass.json\"\n" + assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)).hasMessage( + "error reading parameters from " + "\"src/test/resources/parameters/prodConsMismatchCTParClass.json\"\n" + "(ParameterRuntimeException):carrier technology \"SUPER_LOOPER\" " + "does not match plugin \"SUPER_DOOPER\" in \"" + "org.onap.policy.apex.service.engine." + "parameters.dummyclasses.SuperDooperCarrierTechnologyParameters" - + "\", specify correct carrier technology parameter plugin " - + "in parameter \"parameterClassName\""); + + "\", specify correct carrier technology parameter plugin " + "in parameter \"parameterClassName\""); } @Test public void testWrongTypeCarrierTechnologyParClass() { - final String[] args = {"-c", "src/test/resources/parameters/prodConsWrongTypeCTParClass.json"}; + final String[] args = { "-c", "src/test/resources/parameters/prodConsWrongTypeCTParClass.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); - assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)) - .hasMessage("error reading parameters from " - + "\"src/test/resources/parameters/prodConsWrongTypeCTParClass.json\"\n" + assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)).hasMessage( + "error reading parameters from " + "\"src/test/resources/parameters/prodConsWrongTypeCTParClass.json\"\n" + "(ParameterRuntimeException):could not create default parameters for carrier technology " + "\"SUPER_DOOPER\"\n" + "class org.onap.policy.apex.service.engine.parameters.dummyclasses." + "SuperTokenDelimitedEventProtocolParameters cannot be cast to class " @@ -157,12 +151,12 @@ public class ProducerConsumerTests { @Test public void testOkFileNameCarrierTechnology() throws ParameterException { - final String[] args = {"-c", "src/test/resources/parameters/prodConsOKFileName.json"}; + final String[] args = { "-c", "src/test/resources/parameters/prodConsOKFileName.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments); final FileCarrierTechnologyParameters fileParams = (FileCarrierTechnologyParameters) parameters - .getEventOutputParameters().get("aProducer").getCarrierTechnologyParameters(); + .getEventOutputParameters().get("aProducer").getCarrierTechnologyParameters(); assertTrue(fileParams.getFileName().endsWith("target/aaa.json")); assertEquals(false, fileParams.isStandardError()); assertEquals(false, fileParams.isStandardIo()); @@ -172,16 +166,14 @@ public class ProducerConsumerTests { @Test public void testBadFileNameCarrierTechnology() { - final String[] args = {"-c", "src/test/resources/parameters/prodConsBadFileName.json"}; + final String[] args = { "-c", "src/test/resources/parameters/prodConsBadFileName.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); - assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)) - .hasMessage("validation error(s) on parameters from " - + "\"src/test/resources/parameters/prodConsBadFileName.json\"\n" + assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)).hasMessage( + "validation error(s) on parameters from " + "\"src/test/resources/parameters/prodConsBadFileName.json\"\n" + "parameter group \"APEX_PARAMETERS\" type " + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, " - + "parameter group has status INVALID\n" - + " parameter group map \"eventOutputParameters\" INVALID, " + + "parameter group has status INVALID\n" + " parameter group map \"eventOutputParameters\" INVALID, " + "parameter group map has status INVALID\n" + " parameter group \"aProducer\" type " + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" " + "INVALID, parameter group has status INVALID\n" + " parameter group \"FILE\" type " @@ -194,7 +186,7 @@ public class ProducerConsumerTests { @Test public void testBadEventProtocolParClass() { - final String[] args = {"-c", "src/test/resources/parameters/prodConsBadEPParClass.json"}; + final String[] args = { "-c", "src/test/resources/parameters/prodConsBadEPParClass.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)) @@ -207,7 +199,7 @@ public class ProducerConsumerTests { @Test public void testNoEventProtocolParClass() { - final String[] args = {"-c", "src/test/resources/parameters/prodConsNoEPParClass.json"}; + final String[] args = { "-c", "src/test/resources/parameters/prodConsNoEPParClass.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)) @@ -218,12 +210,11 @@ public class ProducerConsumerTests { @Test public void testMismatchEventProtocolParClass() { - final String[] args = {"-c", "src/test/resources/parameters/prodConsMismatchEPParClass.json"}; + final String[] args = { "-c", "src/test/resources/parameters/prodConsMismatchEPParClass.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); - assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)) - .hasMessage("error reading parameters from " - + "\"src/test/resources/parameters/prodConsMismatchEPParClass.json\"\n" + assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)).hasMessage( + "error reading parameters from " + "\"src/test/resources/parameters/prodConsMismatchEPParClass.json\"\n" + "(ParameterRuntimeException):event protocol \"SUPER_TOK_BEL\" " + "does not match plugin \"SUPER_TOK_DEL\" in " + "\"org.onap.policy.apex.service.engine.parameters.dummyclasses." @@ -233,12 +224,11 @@ public class ProducerConsumerTests { @Test public void testWrongTypeEventProtocolParClass() { - final String[] args = {"-c", "src/test/resources/parameters/prodConsWrongTypeEPParClass.json"}; + final String[] args = { "-c", "src/test/resources/parameters/prodConsWrongTypeEPParClass.json" }; final ApexCommandLineArguments arguments = new ApexCommandLineArguments(args); - assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)) - .hasMessage("error reading parameters from " - + "\"src/test/resources/parameters/prodConsWrongTypeEPParClass.json\"\n" + assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)).hasMessage( + "error reading parameters from " + "\"src/test/resources/parameters/prodConsWrongTypeEPParClass.json\"\n" + "(ParameterRuntimeException):could not create default parameters for event protocol " + "\"SUPER_TOK_DEL\"\n" + "class org.onap.policy.apex.service.engine." + "parameters.dummyclasses.SuperDooperCarrierTechnologyParameters " diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextInstantiation.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextInstantiation.java index 9e9e4626e..5561dbece 100644 --- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextInstantiation.java +++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextInstantiation.java @@ -26,10 +26,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import static org.onap.policy.apex.testsuites.integration.context.factory.TestContextAlbumFactory.createPolicyContextModel; import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.BYTE_VAL; -import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.EXCEPTION_MESSAGE; import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.EXTERNAL_CONTEXT; import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.EXTERNAL_CONTEXT_ALBUM; import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.FLOAT_VAL; @@ -87,7 +85,8 @@ import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; /** - * The Class TestContextInstantiation is used to test Apex context insitiation is correct. + * The Class TestContextInstantiation is used to test Apex context insitiation + * is correct. * * @author Sergey Sachkov (sergey.sachkov@ericsson.com) */ @@ -102,9 +101,7 @@ public class ContextInstantiation { private static final String TEST_POLICY_CONTEXT_ITEM003 = "TestPolicyContextItem003"; private static final String TEST_POLICY_CONTEXT_ITEM002 = "TestPolicyContextItem002"; private static final String TEST_POLICY_CONTEXT_ITEM001 = "TestPolicyContextItem001"; - private static final String NORMAL_TEST_EXCEPTION = "normal test exception"; - private static final String NULL_VALUES_ILLEGAL_TAG = - "album \"ExternalContextAlbum:0.0.1\" null values are illegal on key "; + private static final String NULL_ILLEGAL = "album \"ExternalContextAlbum:0.0.1\" null values are illegal on key "; private static final TreeSet<String> TEST_TREE_SET = new TreeSet<>(); private static final Map<String, String> TEST_HASH_MAP = new HashMap<>(); @@ -134,8 +131,8 @@ public class ContextInstantiation { final Distributor contextDistributor = getDistributor(); - final ContextAlbum policyContextAlbum = - contextDistributor.createContextAlbum(new AxArtifactKey(POLICY_CONTEXT_ALBUM, VERSION)); + final ContextAlbum policyContextAlbum = contextDistributor + .createContextAlbum(new AxArtifactKey(POLICY_CONTEXT_ALBUM, VERSION)); assertNotNull(policyContextAlbum); policyContextAlbum.setUserArtifactStack(Constants.getAxArtifactKeyArray()); @@ -152,8 +149,8 @@ public class ContextInstantiation { policyContextAlbum.putAll(valueMap0); - final TestPolicyContextItem contextItem = - (TestPolicyContextItem) policyContextAlbum.get(TEST_POLICY_CONTEXT_ITEM); + final TestPolicyContextItem contextItem = (TestPolicyContextItem) policyContextAlbum + .get(TEST_POLICY_CONTEXT_ITEM); assertEquals(STRING_VAL, contextItem.getTestPolicyContextItem000().getStringValue()); assertEquals(LONG_VAL, contextItem.getTestPolicyContextItem001().getLongValue()); @@ -171,8 +168,8 @@ public class ContextInstantiation { globalContextAlbum.putAll(valueMap1); - final TestGlobalContextItem globalContextItem = - (TestGlobalContextItem) globalContextAlbum.get(GLOBAL_CONTEXT_KEY); + final TestGlobalContextItem globalContextItem = (TestGlobalContextItem) globalContextAlbum + .get(GLOBAL_CONTEXT_KEY); assertFalse(globalContextItem.getTestGlobalContextItem000().isFlag()); @@ -188,10 +185,10 @@ public class ContextInstantiation { assertEquals((Long) testDate.getTime(), globalContextItem.getTestGlobalContextItem007().getLongValue()); assertEquals(testDate, globalContextItem.getTestGlobalContextItem008().getDateValue()); assertEquals(tci9.getDateValue().getTime(), - globalContextItem.getTestGlobalContextItem009().getDateValue().getTime()); + globalContextItem.getTestGlobalContextItem009().getDateValue().getTime()); assertEquals(tciA.getDateValue().getTime(), - globalContextItem.getTestGlobalContextItem00A().getDateValue().getTime()); + globalContextItem.getTestGlobalContextItem00A().getDateValue().getTime()); assertEquals(TEST_TREE_SET, globalContextItem.getTestGlobalContextItem00B().getSetValue()); assertEquals(TEST_HASH_MAP, globalContextItem.getTestGlobalContextItem00C().getMapValue()); @@ -217,8 +214,8 @@ public class ContextInstantiation { externalContextAlbum.putAll(valueMap2); externalContextAlbum.getAlbumDefinition().setWritable(false); - TestExternalContextItem externalContextItem = - (TestExternalContextItem) externalContextAlbum.get(EXTERNAL_CONTEXT); + TestExternalContextItem externalContextItem = (TestExternalContextItem) externalContextAlbum + .get(EXTERNAL_CONTEXT); assertFalse(externalContextItem.getTestExternalContextItem000().isFlag()); assertEquals(BYTE_VAL, externalContextItem.getTestExternalContextItem001().getByteValue()); @@ -232,10 +229,10 @@ public class ContextInstantiation { assertEquals((Long) testDate.getTime(), externalContextItem.getTestExternalContextItem007().getLongValue()); assertEquals(testDate, externalContextItem.getTestExternalContextItem008().getDateValue()); assertEquals(tci9A.getDateValue().getTime(), - externalContextItem.getTestExternalContextItem009().getDateValue().getTime()); + externalContextItem.getTestExternalContextItem009().getDateValue().getTime()); assertEquals(tciAa.getDateValue().getTime(), - externalContextItem.getTestExternalContextItem00A().getDateValue().getTime()); + externalContextItem.getTestExternalContextItem00A().getDateValue().getTime()); assertEquals(TEST_TREE_SET, externalContextItem.getTestExternalContextItem00B().getSetValue()); assertEquals(TEST_HASH_MAP, externalContextItem.getTestExternalContextItem00C().getMapValue()); @@ -261,7 +258,7 @@ public class ContextInstantiation { assertThatThrownBy(() -> externalContextAlbum.put(null, null)) .hasMessageContaining("album \"ExternalContextAlbum:0.0.1\" null keys are illegal on keys for put()"); assertThatThrownBy(() -> externalContextAlbum.put("TestExternalContextItem00A", null)) - .hasMessageContaining(NULL_VALUES_ILLEGAL_TAG + "\"TestExternalContextItem00A\" for put()"); + .hasMessageContaining(NULL_ILLEGAL + "\"TestExternalContextItem00A\" for put()"); assertEquals(tciAa, externalContextItem.getTestExternalContextItem00A()); // Should return the hash set @@ -284,16 +281,16 @@ public class ContextInstantiation { externalContextItem = (TestExternalContextItem) externalContextAlbum.get(EXTERNAL_CONTEXT); assertEquals(INT_VAL_3, externalContextItem.getTestExternalContextItem002().getIntValue()); assertThatThrownBy(() -> externalContextAlbum.put("TestExternalContextItem00A", null)) - .hasMessageContaining(NULL_VALUES_ILLEGAL_TAG + "\"TestExternalContextItem00A\" for put()"); + .hasMessageContaining(NULL_ILLEGAL + "\"TestExternalContextItem00A\" for put()"); assertTrue(externalContextAlbum.get(EXTERNAL_CONTEXT).equals(externalContext)); assertThatThrownBy(() -> externalContextAlbum.put("TestExternalContextItemFFF", null)) - .hasMessageContaining(NULL_VALUES_ILLEGAL_TAG + "\"TestExternalContextItemFFF\" for put()"); + .hasMessageContaining(NULL_ILLEGAL + "\"TestExternalContextItemFFF\" for put()"); assertEquals(1, externalContextAlbum.size()); assertThatThrownBy(() -> externalContextAlbum.put("TestExternalContextItemFFF", null)) - .hasMessageContaining(NULL_VALUES_ILLEGAL_TAG + "\"TestExternalContextItemFFF\" for put()"); + .hasMessageContaining(NULL_ILLEGAL + "\"TestExternalContextItemFFF\" for put()"); assertEquals(1, externalContextAlbum.size()); // Should ignore remove @@ -306,7 +303,7 @@ public class ContextInstantiation { } private void assertContextAlbumContains(final TestExternalContextItem externalContext, - final ContextAlbum externalContextAlbum) { + final ContextAlbum externalContextAlbum) { assertThatThrownBy(() -> externalContextAlbum.containsKey(null)) .hasMessageContaining("null values are illegal on method parameter \"key\""); assertTrue(externalContextAlbum.containsKey(EXTERNAL_CONTEXT)); @@ -319,15 +316,15 @@ public class ContextInstantiation { } private ContextAlbum getContextAlbum(final Distributor contextDistributor) throws ContextException { - final ContextAlbum globalContextAlbum = - contextDistributor.createContextAlbum(new AxArtifactKey(GLOBAL_CONTEXT_ALBUM, VERSION)); + final ContextAlbum globalContextAlbum = contextDistributor + .createContextAlbum(new AxArtifactKey(GLOBAL_CONTEXT_ALBUM, VERSION)); assertNotNull(globalContextAlbum); globalContextAlbum.setUserArtifactStack(Constants.getAxArtifactKeyArray()); return globalContextAlbum; } private TestGlobalContextItem getTestGlobalContextItem(final Distributor contextDistributor, final Date testDate, - final TestContextDateTzItem tci9, final TestContextDateLocaleItem tciA) throws ContextException { + final TestContextDateTzItem tci9, final TestContextDateLocaleItem tciA) throws ContextException { final AxContextModel globalContextModel = TestContextAlbumFactory.createGlobalContextModel(); final TestGlobalContextItem globalContext = getTestGlobalContextItem(testDate, tci9, tciA); contextDistributor.registerModel(globalContextModel); @@ -335,7 +332,7 @@ public class ContextInstantiation { } private TestGlobalContextItem getTestGlobalContextItem(final Date testDate, final TestContextDateTzItem tci9, - final TestContextDateLocaleItem tciA) { + final TestContextDateLocaleItem tciA) { final TestGlobalContextItem globalContext = new TestGlobalContextItem(); final TestContextBooleanItem testGlobalContextItem000 = new TestContextBooleanItem(false); @@ -399,13 +396,13 @@ public class ContextInstantiation { } private void assertPutMethods(final ContextAlbum policyContextAlbum, final TestContextStringItem contextStringItem, - final Map<String, Object> valueMapA) { + final Map<String, Object> valueMapA) { assertThatThrownBy(() -> policyContextAlbum.put(TEST_POLICY_CONTEXT_ITEM000, contextStringItem)) .hasMessageContaining(getMessage(TEST_POLICY_CONTEXT_ITEM000, "TestContextItem006", - TestContextStringItem.class.getName(), "stringValue=" + STRING_VAL)); + TestContextStringItem.class.getName(), "stringValue=" + STRING_VAL)); assertThatThrownBy(() -> policyContextAlbum.putAll(valueMapA)) .hasMessageContaining(getMessage(TEST_POLICY_CONTEXT_ITEM001, "TestContextItem003", - TestContextLongItem.class.getName(), "longValue=" + INT_VAL_3)); + TestContextLongItem.class.getName(), "longValue=" + INT_VAL_3)); } private AxContextModel getAxContextModel() { @@ -437,7 +434,7 @@ public class ContextInstantiation { } private TestExternalContextItem getTestExternalContextItem(final Date testDate, final TestContextDateTzItem tci9A, - final TestContextDateLocaleItem tciAa) { + final TestContextDateLocaleItem tciAa) { final TestExternalContextItem externalContext = new TestExternalContextItem(); final TestContextBooleanItem testExternalContextItem000 = new TestContextBooleanItem(false); @@ -473,10 +470,10 @@ public class ContextInstantiation { } private String getMessage(final String key, final String objName, final String clazzName, final String valString, - final String compatibleClazzName) { + final String compatibleClazzName) { return "Failed to set context value for key \"" + key + "\" in album \"PolicyContextAlbum:0.0.1\": " - + "PolicyContextAlbum:0.0.1: object \"" + objName + " [" + valString + "]\" " + "of class \"" - + clazzName + "\"" + " not compatible with class \"" + compatibleClazzName + "\""; + + "PolicyContextAlbum:0.0.1: object \"" + objName + " [" + valString + "]\" " + "of class \"" + clazzName + + "\"" + " not compatible with class \"" + compatibleClazzName + "\""; } private void assertFloat(final float actual, final float expected) { diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextUpdate.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextUpdate.java index 53c8d1fb8..ae662f293 100644 --- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextUpdate.java +++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextUpdate.java @@ -57,9 +57,6 @@ import org.slf4j.ext.XLoggerFactory; * @author Sergey Sachkov (sergey.sachkov@ericsson.com) */ public class ContextUpdate { - // Recurring string constants. - private static final String NORMAL_TEST_EXCEPTION = "normal test exception"; - private static final String ZERO = "zero"; private static final String NUMBER_ZERO = "0"; // Logger for this class diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/SequentialContextInstantiation.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/SequentialContextInstantiation.java index 287dd6147..50ca52a6b 100644 --- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/SequentialContextInstantiation.java +++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/SequentialContextInstantiation.java @@ -67,7 +67,8 @@ import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; /** - * The Class SequentialContextInstantiation checks sequential initiation of context. + * The Class SequentialContextInstantiation checks sequential initiation of + * context. * * @author Sergey Sachkov (sergey.sachkov@ericsson.com) */ @@ -87,7 +88,6 @@ public class SequentialContextInstantiation { private static final String ITEM00_2 = "Item00_2"; // Recurring string constants. - private static final String NORMAL_TEST_EXCEPTION = "normal test exception"; private static final String DV1 = "dv1"; private static final String DV0 = "dv0"; @@ -116,8 +116,7 @@ public class SequentialContextInstantiation { assertThatThrownBy(() -> dateAlbum.put("tci9", tci9)) .hasMessageContaining("class \"" + TestContextDateTzItem.class.getName() - + "\" not compatible with class \"" + TestContextDateLocaleItem.class.getName() - + "\""); + + "\" not compatible with class \"" + TestContextDateLocaleItem.class.getName() + "\""); final TestContextDateLocaleItem tciA01 = new TestContextDateLocaleItem(tciA00); final TestContextDateLocaleItem tciA02 = new TestContextDateLocaleItem(tciA00); @@ -139,9 +138,8 @@ public class SequentialContextInstantiation { // Get another reference to the album final ContextAlbum dateAlbum1 = getContextAlbum(DATE_CONTEXT_ALBUM, contextDistributor); - assertThatThrownBy(() -> dateAlbum1.putAll(valueMap1)) - .hasMessageContaining("not compatible with class \"" - + TestContextDateLocaleItem.class.getName() + "\""); + assertThatThrownBy(() -> dateAlbum1.putAll(valueMap1)).hasMessageContaining( + "not compatible with class \"" + TestContextDateLocaleItem.class.getName() + "\""); assertEquals(5, dateAlbum1.size()); valueMap1.clear(); @@ -220,7 +218,7 @@ public class SequentialContextInstantiation { } private void assertAlbumGetAndPutMethods(final ContextAlbum dateAlbum, final TestContextDateLocaleItem tciA03, - final TestContextDateLocaleItem tciA00) { + final TestContextDateLocaleItem tciA00) { assertThatThrownBy(() -> dateAlbum.get(null)) .hasMessageContaining("album \"DateContextAlbum:0.0.1\" null keys are illegal on keys for get()"); @@ -230,9 +228,8 @@ public class SequentialContextInstantiation { .hasMessageContaining("album \"DateContextAlbum:0.0.1\" null keys are illegal on keys for put()"); // Put null ContextItem should work (return null) - assertThatThrownBy(() -> dateAlbum.put(ITEM_NULL, null)) - .hasMessageContaining("album \"DateContextAlbum:0.0.1\" null values are illegal on " - + "key \"ItemNull\" for put()"); + assertThatThrownBy(() -> dateAlbum.put(ITEM_NULL, null)).hasMessageContaining( + "album \"DateContextAlbum:0.0.1\" null values are illegal on " + "key \"ItemNull\" for put()"); // Should return null assertNull(dateAlbum.get(ITEM_NULL)); @@ -245,26 +242,23 @@ public class SequentialContextInstantiation { retItem = (TestContextDateLocaleItem) dateAlbum.put(ITEM03, tciA03); assertEquals(tciA03Clone, retItem); - assertThatThrownBy(() -> dateAlbum.put(ITEM_NULL, null)) - .hasMessageContaining("album \"DateContextAlbum:0.0.1\" null values are illegal on " - + "key \"ItemNull\" for put()"); + assertThatThrownBy(() -> dateAlbum.put(ITEM_NULL, null)).hasMessageContaining( + "album \"DateContextAlbum:0.0.1\" null values are illegal on " + "key \"ItemNull\" for put()"); dateAlbum.put(TEST_AA, tciA00); assertEquals(tciA00, dateAlbum.get(TEST_AA)); // Should print warning - assertThatThrownBy(() -> dateAlbum.put(TEST_AA, null)) - .hasMessageContaining("album \"DateContextAlbum:0.0.1\" null values are illegal on key \"TestAA\" " - + "for put()"); + assertThatThrownBy(() -> dateAlbum.put(TEST_AA, null)).hasMessageContaining( + "album \"DateContextAlbum:0.0.1\" null values are illegal on key \"TestAA\" " + "for put()"); assertEquals(8, dateAlbum.size()); - assertThatThrownBy(() -> dateAlbum.put(TEST_AB, null)) - .hasMessageContaining("album \"DateContextAlbum:0.0.1\" null values are illegal on key \"TestAB\" " - + "for put()"); + assertThatThrownBy(() -> dateAlbum.put(TEST_AB, null)).hasMessageContaining( + "album \"DateContextAlbum:0.0.1\" null values are illegal on key \"TestAB\" " + "for put()"); assertEquals(8, dateAlbum.size()); } private Map<String, Object> getMap(final Date testDate, final TestContextDateLocaleItem tciA00, - final TestContextDateTzItem tci9) { + final TestContextDateTzItem tci9) { final TestContextBooleanItem testBadItem000 = new TestContextBooleanItem(); final TestContextByteItem testBadItem001 = new TestContextByteItem(); final TestContextIntItem testBadItem002 = new TestContextIntItem(); @@ -319,7 +313,7 @@ public class SequentialContextInstantiation { } private ContextAlbum getContextAlbum(final String albumName, final Distributor contextDistributor) - throws ContextException { + throws ContextException { final ContextAlbum dateAlbum = contextDistributor.createContextAlbum(new AxArtifactKey(albumName, VERSION)); assertNotNull(dateAlbum); dateAlbum.setUserArtifactStack(Constants.getAxArtifactKeyArray()); |