Clean up dependencies in uui-server 51/139951/2
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Fri, 17 Jan 2025 06:37:12 +0000 (07:37 +0100)
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Fri, 17 Jan 2025 12:49:24 +0000 (13:49 +0100)
- remove msb-java-sdk since msb is not used in the java code
  (and it has lots of outdated transient dependencies)
- change scope of junit, mockito and powermock dependencies to test
- do not pin spring framework version as it is already managed by spring-boot dependency management [0]
- replace spring-boot-starter-data-rest with -web since the former bundles the latter and actually nothing
  of -data-rest is used in the codebase
- update jacoco plugin to be compatible with Java 17

[0] defining a separate version also bears the risk of incompatability between the two

Issue-ID: USECASEUI-855
Change-Id: I0c236f3eec35fac07e8f5969d4d8f654fc10c068
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
server/pom.xml
server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionServiceTest.java
server/src/test/java/org/onap/usecaseui/server/service/slicingdomain/kpi/bean/KpiPDUSessionEstSRTest.java

index ef04613..65622ff 100644 (file)
@@ -28,6 +28,8 @@
     <description>source code for usecase-ui server</description>
 
     <properties>
+        <spring-boot.version>3.0.11</spring-boot.version>
+        <jackson.version>2.16.1</jackson.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
         <java.version>17</java.version>
 
     <dependencyManagement>
         <dependencies>
-            <dependency>
-                <groupId>org.springframework</groupId>
-                <artifactId>spring-framework-bom</artifactId>
-                <version>6.1.3</version>
-                <type>pom</type>
-                <scope>import</scope>
-            </dependency>
             <dependency>
                 <!-- Import dependency management from Spring Boot -->
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-dependencies</artifactId>
-                <version>3.0.11</version>
+                <version>${spring-boot.version}</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-actuator</artifactId>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.yaml</groupId>
-                    <artifactId>snakeyaml</artifactId>
-                </exclusion>
-            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
@@ -90,7 +79,7 @@
         </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-data-rest</artifactId>
+            <artifactId>spring-boot-starter-web</artifactId>
         </dependency>
         <dependency>
             <groupId>org.projectlombok</groupId>
             </exclusions>
         </dependency>
 
-        <!-- jackson-databind -->
         <dependency>
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-databind</artifactId>
-            <version>2.16.1</version>
+            <version>${jackson.version}</version>
         </dependency>
-
-        <!-- jackson-core -->
         <dependency>
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-core</artifactId>
-            <version>2.16.1</version>
+            <version>${jackson.version}</version>
         </dependency>
-
-        <!-- jackson-annotations -->
         <dependency>
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-annotations</artifactId>
-            <version>2.16.1</version>
+            <version>${jackson.version}</version>
         </dependency>
 
         <dependency>
         </dependency>
 
         <dependency>
-            <groupId>org.onap.msb.java-sdk</groupId>
-            <artifactId>msb-java-sdk</artifactId>
-            <version>1.0.0</version>
+            <groupId>org.glassfish.jersey.core</groupId>
+            <artifactId>jersey-client</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-inline</artifactId>
-            <scope>compile</scope>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.powermock</groupId>
             <artifactId>powermock-api-mockito2</artifactId>
             <version>2.0.2</version>
+            <scope>test</scope>
             <exclusions>
                 <exclusion>
                     <groupId>org.mockito</groupId>
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
+            <scope>test</scope>
             <version>4.13.2</version>
         </dependency>
         <dependency>
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
-                <version>3.0.11</version>
+                <version>${spring-boot.version}</version>
                 <configuration>
                     <executable>true</executable>
                 </configuration>
             <plugin>
                 <groupId>org.jacoco</groupId>
                 <artifactId>jacoco-maven-plugin</artifactId>
-                <version>0.8.5</version>
+                <version>0.8.9</version>
                 <executions>
                     <execution>
                         <id>prepare-agent</id>
index 1daa443..68dd91c 100644 (file)
@@ -18,7 +18,6 @@ package org.onap.usecaseui.server.service.lcm.impl;
 import okhttp3.MediaType;
 import okio.Buffer;
 import okio.BufferedSource;
-import org.apache.commons.lang3.StringUtils;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.junit.Assert;
@@ -57,6 +56,8 @@ import jakarta.servlet.ServletInputStream;
 import jakarta.servlet.http.HttpServletRequest;
 
 import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -68,8 +69,8 @@ import static org.onap.usecaseui.server.util.CallStub.successfulCall;
 public class DefaultPackageDistributionServiceTest {
 
     private ResponseBody result;
-       
-       
+
+
     private HttpServletRequest mockRequest() throws IOException {
         HttpServletRequest request = mock(HttpServletRequest.class);
         when(request.getContentLength()).thenReturn(0);
@@ -321,7 +322,7 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.getNsLcmJobStatus(serviceId,jobId, responseId,operationType);
     }
-    
+
     @Test
     public void itCanDeleteNsPackage() {
         String csarId = "1";
@@ -350,7 +351,7 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.deleteNsPackage(csarId);
     }
-    
+
     @Test
     public void itCanGetVnfPackages(){
        //ResponseBody result=null;
@@ -361,16 +362,16 @@ public class DefaultPackageDistributionServiceTest {
        // Assert.assertSame(result, service.getVnfPackages());
         Assert.assertNotNull(service.getVnfPackages());
     }
-    
+
     @Test
     public void getVnfPackagesThrowExceptionWhenVFCResponseError(){
-       
+
        VfcService vfcService = mock(VfcService.class);
        when(vfcService.getVnfPackages ()).thenReturn(emptyBodyCall());
        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
        service.getVnfPackages();
     }
-    
+
     @Test
     public void getVnfPackagesThrowException(){
        VfcService vfcService = mock(VfcService.class);
@@ -378,7 +379,7 @@ public class DefaultPackageDistributionServiceTest {
        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
        service.getVnfPackages();
     }
-    
+
     @Test
     public void itCanDeleteVFPackage() {
         String csarId = "1";
@@ -407,7 +408,7 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.deleteVnfPackage(csarId);
     }
-    
+
     @Test
     public void itCanGetNetworkServicePackages() {
         VfcService vfcService = mock(VfcService.class);
@@ -431,7 +432,7 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.getNetworkServicePackages();
     }
-    
+
     @Test
     public void itCanGetPnfPackages(){
         VfcService vfcService = mock(VfcService.class);
@@ -440,16 +441,16 @@ public class DefaultPackageDistributionServiceTest {
 
         Assert.assertNotNull(service.getPnfPackages());
     }
-    
+
     @Test
     public void getPnfPackagesThrowExceptionWhenVFCResponseError(){
-       
+
        VfcService vfcService = mock(VfcService.class);
        when(vfcService.getPnfPackages ()).thenReturn(emptyBodyCall());
        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
        service.getPnfPackages();
     }
-    
+
     @Test
     public void getPnfPackagesThrowException(){
        VfcService vfcService = mock(VfcService.class);
@@ -457,18 +458,20 @@ public class DefaultPackageDistributionServiceTest {
        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
        service.getPnfPackages();
     }
-    
+
     @Test
     public void itDownLoadNsPackage(){
        String nsdInfoId="1";
-       ResponseBody result=null;
+       ResponseBody successResponse=null;
         VfcService vfcService = mock(VfcService.class);
-        when(vfcService.downLoadNsPackage(nsdInfoId)).thenReturn(successfulCall(result));
+        when(vfcService.downLoadNsPackage(nsdInfoId)).thenReturn(successfulCall(successResponse));
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
 
-        Assert.assertTrue(StringUtils.isNotEmpty(service.downLoadNsPackage(nsdInfoId)));
+        String result = service.downLoadNsPackage(nsdInfoId);
+        assertNotNull(result);
+        assertNotEquals("", result);
     }
-    
+
     @Test
     public void downLoadNsPackagehrowExceptionWhenVFCResponseError(){
        String nsdInfoId="1";
@@ -477,7 +480,7 @@ public class DefaultPackageDistributionServiceTest {
        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
        service.downLoadNsPackage(nsdInfoId);
     }
-    
+
     @Test
     public void downLoadNsPackageThrowException(){
        String nsdInfoId="1";
@@ -486,7 +489,7 @@ public class DefaultPackageDistributionServiceTest {
        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
        service.downLoadNsPackage(nsdInfoId);
     }
-    
+
     @Test
     public void itDownLoadPnfPackage(){
        String pnfInfoId="1";
@@ -496,7 +499,7 @@ public class DefaultPackageDistributionServiceTest {
 
         Assert.assertSame("{\"status\":\"SUCCESS\"}", service.downLoadPnfPackage(pnfInfoId));
     }
-    
+
     @Test
     public void downLoadPnfPackagehrowExceptionWhenVFCResponseError(){
        String pnfInfoId="1";
@@ -505,7 +508,7 @@ public class DefaultPackageDistributionServiceTest {
        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
        service.downLoadPnfPackage(pnfInfoId);
     }
-    
+
     @Test
     public void downLoadPnfPackageThrowException(){
        String pnfInfoId="1";
@@ -514,7 +517,7 @@ public class DefaultPackageDistributionServiceTest {
        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
        service.downLoadPnfPackage(pnfInfoId);
     }
-    
+
     @Test
     public void itDownLoadVnfPackage(){
        String vnfInfoId="1";
@@ -524,7 +527,7 @@ public class DefaultPackageDistributionServiceTest {
 
         Assert.assertSame("{\"status\":\"SUCCESS\"}", service.downLoadVnfPackage(vnfInfoId));
     }
-    
+
     @Test
     public void downLoadVnfPackagehrowExceptionWhenVFCResponseError(){
        String vnfInfoId="1";
@@ -533,7 +536,7 @@ public class DefaultPackageDistributionServiceTest {
        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
        service.downLoadVnfPackage(vnfInfoId);
     }
-    
+
     @Test
     public void downLoadVnfPackageThrowException(){
        String vnfInfoId="1";
@@ -542,7 +545,7 @@ public class DefaultPackageDistributionServiceTest {
        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
        service.downLoadVnfPackage(vnfInfoId);
     }
-    
+
     @Test
     public void itCanDeleteNsdPackage() {
         String csarId = "1";
@@ -571,7 +574,7 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.deleteNsdPackage(csarId);
     }
-    
+
     @Test
     public void itCanDeleteVnfPackage() {
         String csarId = "1";
@@ -600,7 +603,7 @@ public class DefaultPackageDistributionServiceTest {
         service.deleteVnfPackage(csarId);
         Assert.assertSame("{\"status\":\"FAILED\"}", service.deleteVnfPackage(csarId));
     }
-    
+
     @Test
     public void itCanDeletePnfdPackage() {
         String csarId = "1";
@@ -630,7 +633,7 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.deletePnfPackage(csarId);
     }
-    
+
     @Test
     public void itCanDeleteNetworkServiceInstance() {
         String csarId = "1";
@@ -660,7 +663,7 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.deleteNetworkServiceInstance(csarId);
     }
-    
+
     @Test
     public void itCanCreateNetworkServiceInstance() throws IOException {
        HttpServletRequest request = mockRequest();
@@ -689,7 +692,7 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.createNetworkServiceInstance(request);
     }
-    
+
     @Test
     public void itCanGetNetworkServiceInfo() throws IOException {
         nsServiceRsp ns = new nsServiceRsp();
@@ -721,9 +724,9 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.getNetworkServiceInfo();
     }
-    
 
-    
+
+
     @Test
     public void itCanHealNetworkServiceInstance() throws IOException {
        HttpServletRequest request = mockRequest();
@@ -756,17 +759,17 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.healNetworkServiceInstance(request,csarId);
     }
-    
+
     @Test
     public void itCanScaleNetworkServiceInstance() throws IOException {
        HttpServletRequest request = mockRequest();
         String csarId = "1";
-        ResponseBody result=null;
         VfcService vfcService = mock(VfcService.class);
-        //when(vfcService.scaleNetworkServiceInstance(csarId,anyObject())).thenReturn(successfulCall(result));
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
 
-        Assert.assertTrue(StringUtils.isNotEmpty(service.scaleNetworkServiceInstance(request,csarId)));
+        String result = service.scaleNetworkServiceInstance(request,csarId);
+        assertNotNull(result);
+        assertNotEquals("", result);
     }
 
     @Test
@@ -788,8 +791,8 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.scaleNetworkServiceInstance(request,csarId);
     }
-    
-    
+
+
     @Test
     public void itCaninstantiateNetworkServiceInstance() throws IOException {
        HttpServletRequest request = mockRequest();
@@ -821,8 +824,8 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.instantiateNetworkServiceInstance(request,serviceInstanceId);
     }
-    
-    
+
+
     @Test
     public void itCanTerminateNetworkServiceInstance() throws IOException {
        HttpServletRequest request = mockRequest();
@@ -855,16 +858,18 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.terminateNetworkServiceInstance(request,csarId);
     }
-    
+
     @Test
     public void itCreateNetworkServiceData() throws IOException {
        HttpServletRequest request = mockRequest();
-        ResponseBody result=null;
+        ResponseBody responseBody = null;
         VfcService vfcService = mock(VfcService.class);
-        when(vfcService.createNetworkServiceData(Mockito.any())).thenReturn(successfulCall(result));
+        when(vfcService.createNetworkServiceData(Mockito.any())).thenReturn(successfulCall(responseBody));
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
 
-        Assert.assertTrue(StringUtils.isNotEmpty(service.createNetworkServiceData(request)));
+        String result = service.createNetworkServiceData(request);
+        assertNotNull(result);
+        assertNotEquals("", result);
     }
 
     @Test
@@ -884,7 +889,7 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.createNetworkServiceData(request);
     }
-    
+
     @Test
     public void itCreateVnfData() throws IOException {
        HttpServletRequest request = mockRequest();
@@ -913,7 +918,7 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.createVnfData(request);
     }
-    
+
     @Test
     public void itCreatePnfData() throws IOException {
        HttpServletRequest request = mockRequest();
@@ -942,7 +947,7 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.createPnfData(request);
     }
-    
+
     @Test
     public void itGetNsdInfo() throws IOException {
        String nsdId="1";
@@ -971,7 +976,7 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.getNsdInfo(nsdId);
     }
-    
+
     @Test
     public void itGetVnfInfo() throws IOException {
        String nsdId="1";
@@ -1000,7 +1005,7 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.getVnfInfo(nsdId);
     }
-    
+
     @Test
     public void itGetPnfInfo() throws IOException {
        String nsdId="1";
@@ -1029,7 +1034,7 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.getPnfInfo(nsdId);
     }
-    
+
     @Test
     public void itCanListNsTemplates() throws IOException {
         VfcService vfcService = mock(VfcService.class);
@@ -1054,7 +1059,7 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.listNsTemplates();
     }
-    
+
     @Test
     public void itCanGetVnfInfoById() throws IOException {
        String nsdId="1";
@@ -1082,7 +1087,7 @@ public class DefaultPackageDistributionServiceTest {
         PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
         service.getVnfInfoById(nsdId);
     }
-    
+
     @Test
     public void itCanFetchNsTemplateData() throws IOException {
        HttpServletRequest request = mockRequest();
@@ -1112,4 +1117,4 @@ public class DefaultPackageDistributionServiceTest {
         service.fetchNsTemplateData(request);
     }
 
-  }
\ No newline at end of file
+  }
index 9195fa3..98ff23d 100644 (file)
@@ -22,7 +22,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.onap.usecaseui.server.bean.nsmf.monitor.SlicingKpiReqInfo;
 
-class KpiPDUSessionEstSRTest {
+public class KpiPDUSessionEstSRTest {
 
        @Before
     public void before() throws Exception {
@@ -34,9 +34,9 @@ class KpiPDUSessionEstSRTest {
 
     @Test
     public void testSetAndGetKpiPDUSessionEstSR() throws Exception {
-       
+
        KpiPDUSessionEstSR kpiPDUSessionEstSR = new KpiPDUSessionEstSR();
-               
+
        List<PDUSessionEstSR> pDUSessionEstSRList = new ArrayList<>();
        PDUSessionEstSR pDUSessionEstSR = new PDUSessionEstSR();
        pDUSessionEstSR.setTimeStamp("12345634456");