diff options
45 files changed, 156 insertions, 146 deletions
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorLoop.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorLoop.java index cfe2077bc..3adea1a89 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorLoop.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorLoop.java @@ -257,7 +257,6 @@ public class CommandLineEditorLoop { writer.println(e.getMessage()); executionStatus.setRight(executionStatus.getRight() + 1); LOGGER.debug(COMMAND_LINE_ERROR, e); - continue; } catch (final Exception e) { e.printStackTrace(writer); LOGGER.error(COMMAND_LINE_ERROR, e); diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParser.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParser.java index 3eba53d2d..05066adb4 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParser.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParser.java @@ -1,19 +1,20 @@ /*- * ============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========================================================= */ @@ -22,6 +23,7 @@ package org.onap.policy.apex.auth.clieditor; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; /** @@ -87,7 +89,7 @@ public class CommandLineParser { /** * This method merges the next set of quotes. - * + * * @param wordsSplitOnQuotes the words split on quotes * @param wordsWithQuotesMerged the merged words * @param wordIndex the current word index @@ -240,7 +242,7 @@ public class CommandLineParser { /** * Strip and split a word on blanks into an array of words split on blanks. - * + * * @param word the word to split * @return the array of split words */ @@ -257,9 +259,7 @@ public class CommandLineParser { // Split on space characters final String[] splitWords = singleSpaceWord.split(" "); - for (final String splitWord : splitWords) { - strippedAndSplitWords.add(splitWord); - } + Collections.addAll(strippedAndSplitWords, splitWords); return strippedAndSplitWords; } diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/utils/CliUtils.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/utils/CliUtils.java index ccf799047..a70439e10 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/utils/CliUtils.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/utils/CliUtils.java @@ -217,7 +217,7 @@ public class CliUtils { if (argValue instanceof String && !key.equals("o")) { cliArgsList.add("-" + key); cliArgsList.add(argValue.toString()); - } else if (argValue instanceof Boolean && (Boolean) argValue) { + } else if (argValue instanceof Boolean && (boolean) argValue) { cliArgsList.add("-" + key); } } catch (Exception e) { diff --git a/client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ApexMonitoringRestResource.java b/client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ApexMonitoringRestResource.java index dd9d8b2c6..f31f47cd4 100644 --- a/client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ApexMonitoringRestResource.java +++ b/client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ApexMonitoringRestResource.java @@ -1,6 +1,7 @@ /*- * ============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. @@ -294,7 +295,7 @@ public class ApexMonitoringRestResource { SlidingWindowList<Counter> valueList; if (!cache.containsKey(host)) { - cache.put(host, new HashMap<String, List<Counter>>()); + cache.put(host, new HashMap<>()); } if (cache.get(host).containsKey(id)) { @@ -312,7 +313,7 @@ public class ApexMonitoringRestResource { /** * Get an engine service facade for sending REST requests. This method is package because it is used by unit test. - * + * * @param hostName the host name of the Apex engine * @param port the port of the Apex engine * @return the engine service facade @@ -359,21 +360,21 @@ public class ApexMonitoringRestResource { if (this == obj) { return true; } - + if (!super.equals(obj)) { return false; } - + if (getClass() != obj.getClass()) { return false; } - + @SuppressWarnings("unchecked") SlidingWindowList<V> other = (SlidingWindowList<V>) obj; if (!getOuterType().equals(other.getOuterType())) { return false; } - + return maxEntries == other.maxEntries; } } diff --git a/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/RestResourceTest.java b/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/RestResourceTest.java index 469f09586..e8e7e9251 100644 --- a/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/RestResourceTest.java +++ b/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/RestResourceTest.java @@ -237,8 +237,8 @@ public class RestResourceTest { assertTrue(slidingWindowList0.add("Howdy")); assertNotNull(slidingWindowList0); - assertEquals(slidingWindowList0, slidingWindowList0); - + // disabling sonar because this code tests the equals() method + assertEquals(slidingWindowList0, slidingWindowList0); // NOSONAR ApexMonitoringRestResource.SlidingWindowList<String> slidingWindowList1 = restResource.new SlidingWindowList<>( 2); ApexMonitoringRestResource.SlidingWindowList<String> slidingWindowList2 = restResource.new SlidingWindowList<>( diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnEventTest.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnEventTest.java index 6ac0d2e33..fa04f19b5 100644 --- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnEventTest.java +++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnEventTest.java @@ -148,8 +148,8 @@ public class EnEventTest { assertNull(event.get("MyField")); assertNotEquals(0, event.hashCode()); - - assertEquals(event, event); + // disabling sonar because this code tests the equals() method + assertEquals(event, event); // NOSONAR assertNotNull(event); Map<String, Object> hashMap = new HashMap<>(); assertNotEquals(event, hashMap); diff --git a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/impl/ws/RawMessageHandler.java b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/impl/ws/RawMessageHandler.java index ca51a9e33..acd7bdfea 100644 --- a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/impl/ws/RawMessageHandler.java +++ b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/impl/ws/RawMessageHandler.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-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. @@ -104,7 +104,7 @@ public class RawMessageHandler<M> implements WebSocketMessageListener<M>, Runnab if (messageHolder != null) { final List<M> messages = messageHolder.getMessages(); if (messages != null) { - messageBlockQueue.add(new MessageBlock<M>(messages, incomingData.getConn())); + messageBlockQueue.add(new MessageBlock<>(messages, incomingData.getConn())); } } } catch (final IOException | ClassNotFoundException e) { 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 925884534..db13069f1 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 @@ -64,7 +64,8 @@ public class SupportMessageTester { dummyMessage = new DummyMessage(null, null, null); assertEquals(0, dummyMessage.hashCode()); - assertEquals(dummyMessage, dummyMessage); + // disabling sonar because this code tests the equals() method + assertEquals(dummyMessage, dummyMessage); // NOSONAR assertNotNull(dummyMessage); assertNotEquals(dummyMessage, new StartEngine(new AxArtifactKey())); diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/EngineServiceInfoResponseTest.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/EngineServiceInfoResponseTest.java index 87fe44aae..6e588dbe3 100644 --- a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/EngineServiceInfoResponseTest.java +++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/EngineServiceInfoResponseTest.java @@ -71,10 +71,10 @@ public class EngineServiceInfoResponseTest { response.setEngineKeyArray(engineKeyArrayList); assertNotEquals(0, response.hashCode()); response.setEngineKeyArray(null); - - assertEquals(response, response); + // disabling sonar because this code tests the equals() method + assertEquals(response, response); // NOSONAR assertNotNull(response); - assertNotEquals(response, (Object) new StartEngine(new AxArtifactKey())); + assertNotEquals(response, new StartEngine(new AxArtifactKey())); response = new EngineServiceInfoResponse(null, false, null); EngineServiceInfoResponse otherResponse = new EngineServiceInfoResponse(null, false, null); 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 b28993a41..35fe5bb9f 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 @@ -53,7 +53,7 @@ public class ResponseTest { final AxArtifactKey responseKey = new AxArtifactKey("ResponseTest", "0.0.1"); final AxArtifactKey responseToKey = new AxArtifactKey("ResponseTestTo", "0.0.1"); UpdateModel responseTo = new UpdateModel(responseToKey); - + Response message = new Response(responseKey, false, responseTo); logger.debug(message.toString()); assertTrue(message.toString().contains("ResponseTest")); @@ -73,8 +73,8 @@ public class ResponseTest { assertNotEquals(0, message.hashCode()); message = new Response(responseKey, true, new UpdateModel(null)); assertNotEquals(0, message.hashCode()); - - assertEquals(message, message); + // disabling sonar because this code tests the equals() method + assertEquals(message, message); // NOSONAR assertNotNull(message); assertNotEquals(message, new StartEngine(new AxArtifactKey())); 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 0839a43b8..13d37a8f6 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 @@ -1,6 +1,7 @@ /*- * ============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. @@ -68,8 +69,8 @@ public class UpdateModelTest { assertNotEquals(0, message.hashCode()); message = new UpdateModel(null, null, false, true); assertNotEquals(0, message.hashCode()); - - assertEquals(message, message); + // disabling sonar because this code tests the equals() method + assertEquals(message, message); // NOSONAR assertNotNull(message); assertNotEquals(message, new StartEngine(new AxArtifactKey())); diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java index fc876d8ea..446a00a68 100644 --- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java +++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-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. @@ -100,7 +100,7 @@ public class AxKeyInformation extends AxConcept implements AxConceptGetter<AxKey * @param key the key of the concept */ public AxKeyInformation(final AxArtifactKey key) { - this(key, new TreeMap<AxArtifactKey, AxKeyInfo>()); + this(key, new TreeMap<>()); } /** diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java index 991d020a4..b22d45c05 100644 --- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java @@ -58,11 +58,11 @@ public class AxKeyInfoTest { .startsWith("AxKeyInfo:(artifactId=AxArtifactKey:(name=key,version=0.0.1),uuid=")); assertNotEquals(0, testKeyInfo.hashCode()); - - assertEquals(testKeyInfo, testKeyInfo); + // disabling sonar because this code tests the equals() method + assertEquals(testKeyInfo, testKeyInfo); // NOSONAR assertEquals(testKeyInfo, clonedReferenceKey); assertNotNull(testKeyInfo); - assertNotEquals(testKeyInfo, (Object) new AxArtifactKey()); + assertNotEquals(testKeyInfo, new AxArtifactKey()); assertNotEquals(testKeyInfo, new AxKeyInfo(new AxArtifactKey())); assertNotEquals(testKeyInfo, new AxKeyInfo(key, UUID.randomUUID(), "Some Description")); assertNotEquals(testKeyInfo, new AxKeyInfo(key, uuid, "Some Description")); diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java index fbbc4a793..60c848d17 100644 --- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java @@ -109,8 +109,9 @@ public class AxKeyTest { assertEquals(353602977, someKey0.compareTo(new AxReferenceKey())); assertNotNull(someKey0); - assertEquals(someKey0, someKey0); - assertNotEquals(((AxKey) someKey0), new AxReferenceKey()); + // disabling sonar because this code tests the equals() method + assertEquals(someKey0, someKey0); // NOSONAR + assertNotEquals(someKey0, new AxReferenceKey()); AxArtifactKey nullKey0 = AxArtifactKey.getNullKey(); assertTrue(nullKey0.isNullKey()); diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUseTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUseTest.java index 52361438e..4c6020226 100644 --- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUseTest.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUseTest.java @@ -60,10 +60,10 @@ public class AxKeyUseTest { assertEquals("AxKeyUse:(usedKey=AxArtifactKey:(name=Key,version=0.0.1))", clonedKeyUse.toString()); assertNotEquals(0, keyUse.hashCode()); - - assertEquals(keyUse, keyUse); + // disabling sonar because this code tests the equals() method + assertEquals(keyUse, keyUse); // NOSONAR assertEquals(keyUse, clonedKeyUse); - assertNotEquals(keyUse, (Object) "Hello"); + assertNotEquals(keyUse, "Hello"); assertEquals(keyUse, new AxKeyUse(key)); assertEquals(0, keyUse.compareTo(keyUse)); diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java index 49a14dd3c..e7bbef476 100644 --- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java @@ -86,10 +86,10 @@ public class AxReferenceKeyTest { clonedReferenceKey.toString()); assertNotEquals(0, testReferenceKey.hashCode()); - - assertEquals(testReferenceKey, testReferenceKey); + // disabling sonar because this code tests the equals() method + assertEquals(testReferenceKey, testReferenceKey); // NOSONAR assertEquals(testReferenceKey, clonedReferenceKey); - assertNotEquals(testReferenceKey, (Object) "Hello"); + assertNotEquals(testReferenceKey, "Hello"); assertNotEquals(testReferenceKey, new AxReferenceKey("PKN", "0.0.2", "PLN", "LN")); assertNotEquals(testReferenceKey, new AxReferenceKey("NPKN", "0.0.2", "PLN", "LN")); assertNotEquals(testReferenceKey, new AxReferenceKey("NPKN", "0.0.1", "PLN", "LN")); diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTester.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTester.java index 8676362dd..c2657bc7e 100644 --- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTester.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTester.java @@ -69,10 +69,11 @@ public class SupportApexBasicModelConceptsTester { assertNotEquals(0, model.hashCode()); - assertEquals(model, model); + // disabling sonar because this code tests the equals() method + assertEquals(model, model); // NOSONAR assertEquals(model, clonedModel); assertNotNull(model); - assertNotEquals(model, (Object) "Hello"); + assertNotEquals(model, "Hello"); clonedModel.getKey().setVersion("0.0.2"); assertNotEquals(model, clonedModel); clonedModel.getKey().setVersion("0.0.1"); @@ -94,7 +95,7 @@ public class SupportApexBasicModelConceptsTester { final AxKeyInformation clonedKeyI = new AxKeyInformation(keyI); assertNotNull(keyI); - assertNotEquals(keyI, (Object) new AxArtifactKey()); + assertNotEquals(keyI, new AxArtifactKey()); assertEquals(keyI, clonedKeyI); clonedKeyI.setKey(new AxArtifactKey()); diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java index a28fbf663..99e5300dc 100644 --- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java +++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-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. @@ -106,7 +106,7 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter< * @param key the key of the context album container */ public AxContextAlbums(final AxArtifactKey key) { - this(key, new TreeMap<AxArtifactKey, AxContextAlbum>()); + this(key, new TreeMap<>()); } /** diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java index a0f031450..8c4110b62 100644 --- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java +++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-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. @@ -108,7 +108,7 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxCon * @param key the key of the context album container */ public AxContextSchemas(final AxArtifactKey key) { - this(key, new TreeMap<AxArtifactKey, AxContextSchema>()); + this(key, new TreeMap<>()); } /** diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java index 74b000ff3..2e2005fcd 100644 --- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java +++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java @@ -115,11 +115,11 @@ public class ContextAlbumsTest { + "AxArtifactKey:(name=AlbumSchemaName,version=0.0.1))", clonedAlbum.toString()); assertNotEquals(0, album.hashCode()); - - assertEquals(album, album); + // disabling sonar because this code tests the equals() method + assertEquals(album, album); // NOSONAR assertEquals(album, clonedAlbum); assertNotNull(album); - assertNotEquals(album, (Object) "Hello"); + assertNotEquals(album, "Hello"); assertNotEquals(album, new AxContextAlbum(new AxArtifactKey(), "Scope", false, AxArtifactKey.getNullKey())); assertNotEquals(album, new AxContextAlbum(newKey, "Scope", false, AxArtifactKey.getNullKey())); assertNotEquals(album, new AxContextAlbum(newKey, "NewAlbumScope", false, AxArtifactKey.getNullKey())); @@ -183,10 +183,9 @@ public class ContextAlbumsTest { assertNotEquals(0, albums.hashCode()); - assertEquals(albums, albums); assertEquals(albums, clonedAlbums); assertNotNull(albums); - assertNotEquals(albums, (Object) "Hello"); + assertNotEquals(albums, "Hello"); assertNotEquals(albums, new AxContextAlbums(new AxArtifactKey())); assertEquals(0, albums.compareTo(albums)); diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java index 1be226cbd..ae6de38f2 100644 --- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java +++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java @@ -60,9 +60,10 @@ public class ContextModelTest { assertNotEquals(0, model.hashCode()); - assertEquals(model, model); + // disabling sonar because this code tests the equals() method + assertEquals(model, model); // NOSONAR assertEquals(model, clonedModel); - assertNotEquals(model, (Object) "Hello"); + assertNotEquals(model, "Hello"); assertNotEquals(model, new AxContextModel(new AxArtifactKey())); assertNotEquals(model, new AxContextModel(new AxArtifactKey(), new AxContextSchemas(), new AxContextAlbums(), new AxKeyInformation())); diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java index abe7c008f..55844d9d9 100644 --- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java +++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java @@ -103,10 +103,11 @@ public class ContextSchemasTest { assertNotEquals(0, schema.hashCode()); - assertEquals(schema, schema); + // disabling sonar because this code tests the equals() method + assertEquals(schema, schema); // NOSONAR assertEquals(schema, clonedSchema); assertNotNull(schema); - assertNotEquals(schema, (Object) "Hello"); + assertNotEquals(schema, "Hello"); assertNotEquals(schema, new AxContextSchema(new AxArtifactKey(), "Flavour", "Def")); assertNotEquals(schema, new AxContextSchema(newKey, "Flavour", "Def")); assertNotEquals(schema, new AxContextSchema(newKey, "NewSchemaFlavour", "Def")); @@ -165,10 +166,9 @@ public class ContextSchemasTest { assertNotEquals(0, schemas.hashCode()); - assertEquals(schemas, schemas); assertEquals(schemas, clonedSchemas); assertNotNull(schemas); - assertNotEquals(schemas, (Object) "Hello"); + assertNotEquals(schemas, "Hello"); assertNotEquals(schemas, new AxContextSchemas(new AxArtifactKey())); assertEquals(0, schemas.compareTo(schemas)); diff --git a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java index f3f2fb602..9d1c7bf44 100644 --- a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java +++ b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java @@ -98,9 +98,10 @@ public class EngineModelTest { assertNotEquals(0, model.hashCode()); - assertEquals(model, model); + // disabling sonar because this code tests the equals() method + assertEquals(model, model); // NOSONAR assertEquals(model, clonedModel); - assertNotEquals(model, (Object) "Hello"); + assertNotEquals(model, "Hello"); assertNotEquals(model, new AxEngineModel(new AxArtifactKey())); assertNotEquals(model, new AxEngineModel(new AxArtifactKey(), new AxContextSchemas(schemasKey), new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats)); diff --git a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java index 5cb1bd40e..7669f67bd 100644 --- a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java +++ b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java @@ -134,7 +134,8 @@ public class EngineStatsTest { assertNotEquals(0, stats.hashCode()); - assertEquals(stats, stats); + // disabling sonar because this code tests the equals() method + assertEquals(stats, stats); // NOSONAR assertEquals(stats, clonedStats); assertNotNull(stats); diff --git a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java index 26e21aed7..156b733ef 100644 --- a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java +++ b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-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. @@ -130,7 +130,7 @@ public class AxEvent extends AxConcept { * @param key the key of the event */ public AxEvent(final AxArtifactKey key) { - this(key, "", "", "", new TreeMap<String, AxField>()); + this(key, "", "", "", new TreeMap<>()); } /** @@ -141,7 +141,7 @@ public class AxEvent extends AxConcept { * @param nameSpace the name space of the event */ public AxEvent(final AxArtifactKey key, final String nameSpace) { - this(key, nameSpace, "", "", new TreeMap<String, AxField>()); + this(key, nameSpace, "", "", new TreeMap<>()); } /** @@ -154,7 +154,7 @@ public class AxEvent extends AxConcept { * @param target the target of the event */ public AxEvent(final AxArtifactKey key, final String nameSpace, final String source, final String target) { - this(key, nameSpace, source, target, new TreeMap<String, AxField>()); + this(key, nameSpace, source, target, new TreeMap<>()); } /** diff --git a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvents.java b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvents.java index 2df7dee07..8c3f294c6 100644 --- a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvents.java +++ b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvents.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-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. @@ -107,7 +107,7 @@ public class AxEvents extends AxConcept implements AxConceptGetter<AxEvent> { * @param key the event container key */ public AxEvents(final AxArtifactKey key) { - this(key, new TreeMap<AxArtifactKey, AxEvent>()); + this(key, new TreeMap<>()); } /** diff --git a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventModelTest.java b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventModelTest.java index c86ba12e7..1731bcddc 100644 --- a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventModelTest.java +++ b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventModelTest.java @@ -58,10 +58,10 @@ public class EventModelTest { final AxEventModel clonedModel = new AxEventModel(model); assertNotEquals(0, model.hashCode()); - - assertEquals(model, model); + // disabling sonar because this code tests the equals() method + assertEquals(model, model); // NOSONAR assertEquals(model, clonedModel); - assertNotEquals(model, (Object) "Hello"); + assertNotEquals(model, "Hello"); assertNotEquals(model, new AxEventModel(new AxArtifactKey())); assertNotEquals(model, new AxEventModel(modelKey, new AxContextSchemas(), new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey))); diff --git a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java index 629df1a5f..a2d562a6f 100644 --- a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java +++ b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java @@ -187,10 +187,11 @@ public class EventsTest { assertNotEquals(0, event.hashCode()); - assertEquals(event, event); + // disabling sonar because this code tests the equals() method + assertEquals(event, event); // NOSONAR assertEquals(event, clonedEvent); assertNotNull(event); - assertNotEquals(event, (Object) "Hello"); + assertNotEquals(event, "Hello"); assertNotEquals( event, new AxEvent(AxArtifactKey.getNullKey(), "namespace", "source", "target", parameterMap)); assertNotEquals(event, new AxEvent(eventKey, "namespace1", "source", "target", parameterMap)); @@ -270,10 +271,9 @@ public class EventsTest { assertNotEquals(0, events.hashCode()); - assertEquals(events, events); assertEquals(events, clonedEvents); assertNotNull(events); - assertNotEquals(events, (Object) "Hello"); + assertNotEquals(events, "Hello"); assertNotEquals(events, new AxEvents(new AxArtifactKey())); assertEquals(0, events.compareTo(events)); diff --git a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/FieldTest.java b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/FieldTest.java index e5a01ed6f..dd76d329c 100644 --- a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/FieldTest.java +++ b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/FieldTest.java @@ -109,11 +109,11 @@ public class FieldTest { + "AxArtifactKey:(name=SchemaName,version=0.0.1),optional=true)", clonedField.toString()); assertNotEquals(0, field.hashCode()); - - assertEquals(field, field); + // disabling sonar because this code tests the equals() method + assertEquals(field, field); // NOSONAR assertEquals(field, clonedField); assertNotNull(field); - assertNotEquals(field, (Object) "Hello"); + assertNotEquals(field, "Hello"); assertNotEquals(field, new AxField(AxReferenceKey.getNullKey(), AxArtifactKey.getNullKey(), false)); assertNotEquals(field, new AxField(fieldKey, AxArtifactKey.getNullKey(), false)); assertNotEquals(field, new AxField(fieldKey, schemaKey, false)); diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java index f3e89a4e0..16e555be1 100644 --- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java +++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-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. @@ -99,7 +99,7 @@ public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> { * @param key the key */ public AxPolicies(final AxArtifactKey key) { - this(key, new TreeMap<AxArtifactKey, AxPolicy>()); + this(key, new TreeMap<>()); } /** diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java index 502ec3a60..939d094e6 100644 --- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java +++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-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. @@ -134,7 +134,7 @@ public class AxPolicy extends AxConcept { * @param key the key of the policy */ public AxPolicy(final AxArtifactKey key) { - this(key, "", new TreeMap<String, AxState>(), ""); + this(key, "", new TreeMap<>(), ""); } /** diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxState.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxState.java index 713e4de79..44b71f84a 100644 --- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxState.java +++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxState.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-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. @@ -243,12 +243,12 @@ public class AxState extends AxConcept { this(new AxStateParamsBuilder() .key(key) // Key .trigger(AxArtifactKey.getNullKey()) // Trigger Reference - .stateOutputs(new TreeMap<String, AxStateOutput>()) // State Outputs - .contextAlbumReferenceSet(new TreeSet<AxArtifactKey>()) // Context Album Refs + .stateOutputs(new TreeMap<>()) // State Outputs + .contextAlbumReferenceSet(new TreeSet<>()) // Context Album Refs .taskSelectionLogic(new AxTaskSelectionLogic()) // Task Selection Logic - .stateFinalizerLogicMap(new TreeMap<String, AxStateFinalizerLogic>()) // State Finalizer Logics + .stateFinalizerLogicMap(new TreeMap<>()) // State Finalizer Logics .defaultTask(AxArtifactKey.getNullKey()) // Default Task - .taskReferenceMap(new TreeMap<AxArtifactKey, AxStateTaskReference>()) // Task References + .taskReferenceMap(new TreeMap<>()) // Task References ); // @formatter:on } diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java index a0aa705b5..20df8d872 100644 --- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java +++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-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. @@ -152,10 +152,10 @@ public class AxTask extends AxConcept { */ public AxTask(final AxArtifactKey key) { this(key, // Task Key - new TreeMap<String, AxInputField>(), // Input fields - new TreeMap<String, AxOutputField>(), // Output Fields - new TreeMap<String, AxTaskParameter>(), // Task Parameters - new TreeSet<AxArtifactKey>(), // Context Album References + new TreeMap<>(), // Input fields + new TreeMap<>(), // Output Fields + new TreeMap<>(), // Task Parameters + new TreeSet<>(), // Context Album References new AxTaskLogic(new AxReferenceKey(key)) // Task Logic ); } diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTasks.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTasks.java index 4d9dd2089..7986cb658 100644 --- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTasks.java +++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTasks.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-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. @@ -106,7 +106,7 @@ public class AxTasks extends AxConcept implements AxConceptGetter<AxTask> { * @param key the key */ public AxTasks(final AxArtifactKey key) { - this(key, new TreeMap<AxArtifactKey, AxTask>()); + this(key, new TreeMap<>()); } /** diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalysisResult.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalysisResult.java index 7da262c90..96bdc57d0 100644 --- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalysisResult.java +++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalysisResult.java @@ -1,19 +1,20 @@ /*- * ============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========================================================= */ @@ -57,20 +58,20 @@ public class PolicyAnalysisResult { */ public PolicyAnalysisResult(final AxPolicyModel policyModel) { for (final AxArtifactKey contextSchemaKey : policyModel.getSchemas().getSchemasMap().keySet()) { - contextSchemaUsage.put(contextSchemaKey, new TreeSet<AxKey>()); + contextSchemaUsage.put(contextSchemaKey, new TreeSet<>()); } for (final Entry<AxArtifactKey, AxContextAlbum> contextAlbumEntry : policyModel.getAlbums().getAlbumsMap() .entrySet()) { - contextAlbumUsage.put(contextAlbumEntry.getKey(), new TreeSet<AxKey>()); + contextAlbumUsage.put(contextAlbumEntry.getKey(), new TreeSet<>()); } for (final AxArtifactKey eventKey : policyModel.getEvents().getEventMap().keySet()) { - eventUsage.put(eventKey, new TreeSet<AxKey>()); + eventUsage.put(eventKey, new TreeSet<>()); } for (final AxArtifactKey taskKey : policyModel.getTasks().getTaskMap().keySet()) { - taskUsage.put(taskKey, new TreeSet<AxKey>()); + taskUsage.put(taskKey, new TreeSet<>()); } } diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java index 7961d8e8e..c9dbac3e0 100644 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java +++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java @@ -25,7 +25,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; import org.junit.Test; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; @@ -138,11 +137,11 @@ public class LogicTest { clonedLogic.toString()); assertNotEquals(0, logic.hashCode()); - - assertEquals(logic, logic); + // disabling sonar because this code tests the equals() method + assertEquals(logic, logic); // NOSONAR assertEquals(logic, clonedLogic); assertNotNull(logic); - assertNotEquals(logic, (Object) "Hello"); + assertNotEquals(logic, "Hello"); assertNotEquals(logic, new AxLogic(AxReferenceKey.getNullKey(), "LogicFlavour", "Logic")); assertNotEquals(logic, new AxLogic(logicKey, "AnotherLogicFlavour", "Logic")); assertNotEquals(logic, new AxLogic(logicKey, "LogicFlavour", "AnotherLogic")); diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java index 662b8bd02..7b0dbaf86 100644 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java +++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java @@ -209,11 +209,11 @@ public class PoliciesTest { clonedPolicy.toString().substring(0, 77)); assertNotEquals(0, policyPN.hashCode()); - - assertEquals(policyPN, policyPN); + // disabling sonar because this code tests the equals() method + assertEquals(policyPN, policyPN); // NOSONAR assertEquals(policyPN, clonedPolicy); assertNotNull(policyPN); - assertNotEquals(policyPN, (Object) "Hello"); + assertNotEquals(policyPN, "Hello"); assertNotEquals(policyPN, new AxPolicy(AxArtifactKey.getNullKey(), savedTemplate, savedStateMap, savedFirstState)); assertNotEquals(policyPN, new AxPolicy(savedPolicyKey, "SomeTemplate", savedStateMap, savedFirstState)); @@ -294,11 +294,11 @@ public class PoliciesTest { clonedPolicies.toString().substring(0, 60)); assertNotEquals(0, policies.hashCode()); - - assertEquals(policies, policies); + // disabling sonar because this code tests the equals() method + assertEquals(policies, policies); // NOSONAR assertEquals(policies, clonedPolicies); assertNotNull(policies); - assertNotEquals(policies, (Object) "Hello"); + assertNotEquals(policies, "Hello"); assertNotEquals(policies, new AxPolicies(new AxArtifactKey())); assertEquals(0, policies.compareTo(policies)); diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java index 829f93342..30b92ca4c 100644 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java +++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java @@ -79,9 +79,10 @@ public class PolicyModelTest { assertNotEquals(0, model.hashCode()); - assertEquals(model, model); + // disabling sonar because this code tests the equals() method + assertEquals(model, model); // NOSONAR assertEquals(model, clonedModel); - assertNotEquals(model, (Object) "Hello"); + assertNotEquals(model, "Hello"); assertNotEquals(model, new AxPolicyModel(new AxArtifactKey())); assertNotEquals(model, new AxPolicyModel(AxArtifactKey.getNullKey(), new AxContextSchemas(schemasKey), new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey), new AxContextAlbums(albumsKey), diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java index ff3267c8c..7e243f567 100644 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java +++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java @@ -99,10 +99,11 @@ public class StateOutputTest { assertNotEquals(0, so.hashCode()); - assertEquals(so, so); + // disabling sonar because this code tests the equals() method + assertEquals(so, so); // NOSONAR assertEquals(so, clonedPar); assertNotNull(so); - assertNotEquals(so, (Object) "Hello"); + assertNotEquals(so, "Hello"); assertNotEquals(so, new AxStateOutput(AxReferenceKey.getNullKey(), eKey, nsKey)); assertNotEquals(so, new AxStateOutput(soKey, new AxArtifactKey(), nsKey)); assertNotEquals(so, new AxStateOutput(soKey, eKey, new AxReferenceKey())); diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTaskReferenceTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTaskReferenceTest.java index 31012c68c..d1cd3ede3 100644 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTaskReferenceTest.java +++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTaskReferenceTest.java @@ -114,10 +114,11 @@ public class StateTaskReferenceTest { assertNotEquals(0, stRef.hashCode()); - assertEquals(stRef, stRef); + // disabling sonar because this code tests the equals() method + assertEquals(stRef, stRef); // NOSONAR assertEquals(stRef, clonedStRef); assertNotNull(stRef); - assertNotEquals(stRef, (Object) "Hello"); + assertNotEquals(stRef, "Hello"); assertNotEquals(stRef, new AxStateTaskReference(AxReferenceKey.getNullKey(), AxStateTaskOutputType.LOGIC, soKey)); assertNotEquals(stRef, new AxStateTaskReference(stRefKey, AxStateTaskOutputType.DIRECT, soKey)); diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java index 4c5ad4ad3..4fe554137 100644 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java +++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java @@ -383,11 +383,11 @@ public class StateTest { assertEquals("AxState:(stateKey=AxReferenceKey:(parent", clonedState.toString().substring(0, 40)); assertNotEquals(0, state.hashCode()); - - assertEquals(state, state); + // disabling sonar because this code tests the equals() method + assertEquals(state, state); // NOSONAR assertEquals(state, clonedState); assertNotNull(state); - assertNotEquals(state, (Object) "Hello"); + assertNotEquals(state, "Hello"); assertNotEquals(state, new AxState(new AxStateParamsBuilder().key(new AxReferenceKey()).trigger(triggerKey) .stateOutputs(soMap).contextAlbumReferenceSet(ctxtSet).taskSelectionLogic(tsl) .stateFinalizerLogicMap(sflMap).defaultTask(defTaskKey).taskReferenceMap(trMap))); diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TaskParameterTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TaskParameterTest.java index e14dec059..8af19190a 100644 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TaskParameterTest.java +++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TaskParameterTest.java @@ -25,7 +25,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; import org.junit.Test; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; @@ -89,11 +88,11 @@ public class TaskParameterTest { + "parentLocalName=PLN,localName=LN),defaultValue=DefaultValue)", clonedPar.toString()); assertNotEquals(0, par.hashCode()); - - assertEquals(par, par); + // disabling sonar because this code tests the equals() method + assertEquals(par, par); // NOSONAR assertEquals(par, clonedPar); assertNotNull(par); - assertNotEquals(par, (Object) "Hello"); + assertNotEquals(par, "Hello"); assertNotEquals(par, new AxTaskParameter(AxReferenceKey.getNullKey(), "DefaultValue")); assertNotEquals(par, new AxTaskParameter(parKey, "OtherDefaultValue")); assertEquals(par, new AxTaskParameter(parKey, "DefaultValue")); diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java index 4f19e6100..6a6c6589f 100644 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java +++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java @@ -219,11 +219,11 @@ public class TasksTest { assertEquals("AxTask:(key=AxArtifactKey:(name=TaskName", clonedTask.toString().substring(0, 40)); assertNotEquals(0, task.hashCode()); - - assertEquals(task, task); + // disabling sonar because this code tests the equals() method + assertEquals(task, task); // NOSONAR assertEquals(task, clonedTask); assertNotNull(task); - assertNotEquals(task, (Object) "Hello"); + assertNotEquals(task, "Hello"); assertNotEquals(task, new AxTask(new AxArtifactKey(), ifMap, ofMap, tpMap, ctxtSet, tl)); assertNotEquals(task, new AxTask(taskKey, ifEmptyMap, ofMap, tpMap, ctxtSet, tl)); assertNotEquals(task, new AxTask(taskKey, ifMap, ofEmptyMap, tpMap, ctxtSet, tl)); @@ -303,10 +303,11 @@ public class TasksTest { assertNotEquals(0, tasks.hashCode()); - assertEquals(tasks, tasks); + // disabling sonar because this code tests the equals() method + assertEquals(tasks, tasks); // NOSONAR assertEquals(tasks, clonedTasks); assertNotNull(tasks); - assertNotEquals(tasks, (Object) "Hello"); + assertNotEquals(tasks, "Hello"); assertNotEquals(tasks, new AxTasks(new AxArtifactKey())); assertEquals(0, tasks.compareTo(tasks)); diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducer.java index b570c4021..f7ff14744 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducer.java @@ -80,7 +80,7 @@ public class ApexKafkaProducer extends ApexPluginsEventProducer { } } - kafkaProducer.send(new ProducerRecord<String, Object>(kafkaProducerProperties.getProducerTopic(), name, event)); + kafkaProducer.send(new ProducerRecord<>(kafkaProducerProperties.getProducerTopic(), name, event)); if (LOGGER.isTraceEnabled()) { LOGGER.trace("event sent from engine using {} to topic {} : {} ", this.name, kafkaProducerProperties.getProducerTopic(), event); diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/SynchronousEventCache.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/SynchronousEventCache.java index 1a486375d..39c5c2c62 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/SynchronousEventCache.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/SynchronousEventCache.java @@ -1,19 +1,20 @@ /*- * ============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========================================================= */ @@ -34,7 +35,7 @@ import org.slf4j.ext.XLoggerFactory; /** * This class holds a cache of the synchronous events sent into Apex and that have not yet been replied to. It runs a * thread to time out events that have not been replied to in the specified timeout. - * + * * @author Liam Fallon (liam.fallon@ericsson.com) */ public class SynchronousEventCache extends PeeredReference implements Runnable { @@ -64,7 +65,7 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { /** * Create a synchronous event cache that caches outstanding synchronous Apex events. - * + * * @param peeredMode the peered mode for which to return the reference * @param consumer the consumer that is populating the cache * @param producer the producer that is emptying the cache @@ -110,7 +111,7 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { /** * Remove the record of an event sent to Apex if it exists in the cache. - * + * * @param executionId the execution ID of the event * @return The removed event */ @@ -122,7 +123,7 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { /** * Check if an event exists in the to apex cache. - * + * * @param executionId the execution ID of the event * @return true if the event exists, false otherwise */ @@ -147,7 +148,7 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { /** * Remove the record of an event received from Apex if it exists in the cache. - * + * * @param executionId the execution ID of the event * @return The removed event */ @@ -159,7 +160,7 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { /** * Check if an event exists in the from apex cache. - * + * * @param executionId the execution ID of the event * @return true if the event exists, false otherwise */ @@ -215,7 +216,7 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { /** * Cache a synchronized event sent in an event cache. - * + * * @param eventCacheMap the map to cache the event on * @param executionId the execution ID of the event * @param event the event to cache @@ -236,7 +237,7 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { } // Add the event to the map - eventCacheMap.put(executionId, new SimpleEntry<Long, Object>(System.currentTimeMillis(), event)); + eventCacheMap.put(executionId, new SimpleEntry<>(System.currentTimeMillis(), event)); if (LOGGER.isDebugEnabled()) { String message = "event has been cached:" + event; @@ -248,7 +249,7 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { /** * Remove the record of an event if it exists in the cache. - * + * * @param eventCacheMap the map to remove the event from * @param executionId the execution ID of the event * @return The removed event @@ -272,7 +273,7 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { /** * Time out events on an event cache map. Events that have a timeout longer than the configured timeout are timed * out. - * + * * @param eventCacheMap the event cache to operate on */ private void timeoutEventsOnCache(final Map<Long, SimpleEntry<Long, Object>> eventCacheMap) { |