Upgrade and clean up dependencies 84/133084/1
authorliamfallon <liam.fallon@est.tech>
Tue, 31 Jan 2023 10:42:45 +0000 (10:42 +0000)
committerliamfallon <liam.fallon@est.tech>
Tue, 31 Jan 2023 12:46:37 +0000 (12:46 +0000)
- Upgrade Hibernate
- Upgrade Mockito
- Upgrade Mockserver
- Remove Powermock (no longer supported) and replace with spring-test ReflectionTestUtils
- Upgrade Spring Framework
- Add spring-security to allow authentication on unit tests using MockMVC

Minor clean-up
- Replace deprecated authorization configuraiton on spring boot applications with SecurityFilterChain bean
- Change @LocalPort include on tests to use test include rather than runtime include
- Remove unused imports
- Remove unused constants and variables
- Add deprecation annotations where required

Issue-ID: POLICY-4482
Change-Id: Ie004dcc5303e92f6e2c2154967c3537b91868dd5
Signed-off-by: liamfallon <liam.fallon@est.tech>
services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventConverterTest.java
services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventHandlerForPojoTest.java
services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventHandlerTest.java
services/services-onappf/pom.xml
services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterConstants.java
services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/rest/CommonApexStarterRestServer.java

index ed1e09b..6e346a2 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2018 Ericsson. All rights reserved.
- *  Modifications Copyright (C) 2020 Nordix Foundation
+ *  Modifications Copyright (C) 2020,2023 Nordix Foundation
  *  Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -34,6 +34,7 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParame
  *
  */
 public class JsonEventConverterTest {
+    @SuppressWarnings("deprecation")
     @Test
     public void testJsonEventConverter() {
         Apex2JsonEventConverter converter = new Apex2JsonEventConverter();
@@ -63,4 +64,4 @@ public class JsonEventConverterTest {
                 "here", "there", "")))
             .hasMessage("Model for org.onap.policy.apex.model.eventmodel.concepts.AxEvents not found in model service");
     }
-}
\ No newline at end of file
+}
index e2149ef..3bee638 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
- *  Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ *  Modifications Copyright (C) 2020,2022-2023 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -202,6 +202,7 @@ public class JsonEventHandlerForPojoTest {
      * @throws ApexException the apex exception
      * @throws IOException on IO exceptions
      */
+    @SuppressWarnings("deprecation")
     @Test
     public void testJsonBadPojoApexEvent() throws ApexException, IOException {
         final Apex2JsonEventConverter jsonEventConverter = new Apex2JsonEventConverter();
index dd7acdd..a724b6d 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
- *  Modifications Copyright (C) 2020 Nordix Foundation.
+ *  Modifications Copyright (C) 2020,2023 Nordix Foundation.
  *  Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -136,6 +136,7 @@ public class JsonEventHandlerTest {
      *
      * @throws ApexException the apex exception
      */
+    @SuppressWarnings("deprecation")
     @Test
     public void testJsontoApexBadEvent() throws ApexException {
         final Apex2JsonEventConverter jsonEventConverter = new Apex2JsonEventConverter();
@@ -268,4 +269,4 @@ public class JsonEventHandlerTest {
         assertTrue(apexEvent0000JsonString.contains("\"intPar\": 12345"));
         assertTrue(apexEvent0000JsonString.contains("\"toscaPolicyState\": \"ENTRY\""));
     }
-}
\ No newline at end of file
+}
index 2d7b348..7dc9760 100644 (file)
@@ -1,6 +1,6 @@
 <!--
   ============LICENSE_START=======================================================
-   Copyright (C) 2019-2020 Nordix Foundation.
+   Copyright (C) 2019-2020,2023 Nordix Foundation.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.powermock</groupId>
-            <artifactId>powermock-api-mockito2</artifactId>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
index ab20f4b..f1a2a08 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2019 Nordix Foundation.
+ *  Copyright (C) 2019,2023 Nordix Foundation.
  *  Modifications Copyright (C) 2020 Nordix Foundation
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,8 +23,8 @@ package org.onap.policy.apex.services.onappf;
 
 import static org.assertj.core.api.Assertions.assertThatCode;
 
+import java.lang.reflect.Constructor;
 import org.junit.Test;
-import org.powermock.reflect.Whitebox;
 
 /**
  * Class to perform unit test of {@link ApexStarterConstants}}.
@@ -35,6 +35,10 @@ public class TestApexStarterConstants {
     @Test
     public void test() throws Exception {
         // verify that constructor does not throw an exception
-        assertThatCode(() -> Whitebox.invokeConstructor(ApexStarterConstants.class)).doesNotThrowAnyException();
+        assertThatCode(() -> {
+            Constructor<ApexStarterConstants> c = ApexStarterConstants.class.getDeclaredConstructor();
+            c.setAccessible(true);
+            c.newInstance();
+        }).doesNotThrowAnyException();
     }
 }
index 7313f91..67aae33 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2019 Nordix Foundation.
+ *  Copyright (C) 2019,2023 Nordix Foundation.
  *  Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -54,9 +54,9 @@ import org.onap.policy.common.utils.coder.StandardCoder;
 import org.onap.policy.common.utils.network.NetworkUtil;
 import org.onap.policy.common.utils.security.SelfSignedKeyStore;
 import org.onap.policy.common.utils.services.Registry;
-import org.powermock.reflect.Whitebox;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.test.util.ReflectionTestUtils;
 
 /**
  * Class to perform unit test of {@link ApexStarterRestServer}.
@@ -208,9 +208,9 @@ public class CommonApexStarterRestServer {
     }
 
     private void markActivator(final boolean wasAlive) {
-        final Object manager = Whitebox.getInternalState(
+        final Object manager = ReflectionTestUtils.getField(
                 Registry.get(ApexStarterConstants.REG_APEX_STARTER_ACTIVATOR, ApexStarterActivator.class), "manager");
-        AtomicBoolean running = Whitebox.getInternalState(manager, "running");
+        AtomicBoolean running = (AtomicBoolean) ReflectionTestUtils.getField(manager, "running");
         running.set(wasAlive);
     }