<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>
</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>
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;
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;
public class DefaultPackageDistributionServiceTest {
private ResponseBody result;
-
-
+
+
private HttpServletRequest mockRequest() throws IOException {
HttpServletRequest request = mock(HttpServletRequest.class);
when(request.getContentLength()).thenReturn(0);
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.getNsLcmJobStatus(serviceId,jobId, responseId,operationType);
}
-
+
@Test
public void itCanDeleteNsPackage() {
String csarId = "1";
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.deleteNsPackage(csarId);
}
-
+
@Test
public void itCanGetVnfPackages(){
//ResponseBody result=null;
// 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);
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.getVnfPackages();
}
-
+
@Test
public void itCanDeleteVFPackage() {
String csarId = "1";
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.deleteVnfPackage(csarId);
}
-
+
@Test
public void itCanGetNetworkServicePackages() {
VfcService vfcService = mock(VfcService.class);
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.getNetworkServicePackages();
}
-
+
@Test
public void itCanGetPnfPackages(){
VfcService vfcService = mock(VfcService.class);
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);
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";
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.downLoadNsPackage(nsdInfoId);
}
-
+
@Test
public void downLoadNsPackageThrowException(){
String nsdInfoId="1";
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.downLoadNsPackage(nsdInfoId);
}
-
+
@Test
public void itDownLoadPnfPackage(){
String pnfInfoId="1";
Assert.assertSame("{\"status\":\"SUCCESS\"}", service.downLoadPnfPackage(pnfInfoId));
}
-
+
@Test
public void downLoadPnfPackagehrowExceptionWhenVFCResponseError(){
String pnfInfoId="1";
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.downLoadPnfPackage(pnfInfoId);
}
-
+
@Test
public void downLoadPnfPackageThrowException(){
String pnfInfoId="1";
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.downLoadPnfPackage(pnfInfoId);
}
-
+
@Test
public void itDownLoadVnfPackage(){
String vnfInfoId="1";
Assert.assertSame("{\"status\":\"SUCCESS\"}", service.downLoadVnfPackage(vnfInfoId));
}
-
+
@Test
public void downLoadVnfPackagehrowExceptionWhenVFCResponseError(){
String vnfInfoId="1";
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.downLoadVnfPackage(vnfInfoId);
}
-
+
@Test
public void downLoadVnfPackageThrowException(){
String vnfInfoId="1";
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.downLoadVnfPackage(vnfInfoId);
}
-
+
@Test
public void itCanDeleteNsdPackage() {
String csarId = "1";
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.deleteNsdPackage(csarId);
}
-
+
@Test
public void itCanDeleteVnfPackage() {
String csarId = "1";
service.deleteVnfPackage(csarId);
Assert.assertSame("{\"status\":\"FAILED\"}", service.deleteVnfPackage(csarId));
}
-
+
@Test
public void itCanDeletePnfdPackage() {
String csarId = "1";
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.deletePnfPackage(csarId);
}
-
+
@Test
public void itCanDeleteNetworkServiceInstance() {
String csarId = "1";
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.deleteNetworkServiceInstance(csarId);
}
-
+
@Test
public void itCanCreateNetworkServiceInstance() throws IOException {
HttpServletRequest request = mockRequest();
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.createNetworkServiceInstance(request);
}
-
+
@Test
public void itCanGetNetworkServiceInfo() throws IOException {
nsServiceRsp ns = new nsServiceRsp();
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.getNetworkServiceInfo();
}
-
-
+
+
@Test
public void itCanHealNetworkServiceInstance() throws IOException {
HttpServletRequest request = mockRequest();
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
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.scaleNetworkServiceInstance(request,csarId);
}
-
-
+
+
@Test
public void itCaninstantiateNetworkServiceInstance() throws IOException {
HttpServletRequest request = mockRequest();
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.instantiateNetworkServiceInstance(request,serviceInstanceId);
}
-
-
+
+
@Test
public void itCanTerminateNetworkServiceInstance() throws IOException {
HttpServletRequest request = mockRequest();
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
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.createNetworkServiceData(request);
}
-
+
@Test
public void itCreateVnfData() throws IOException {
HttpServletRequest request = mockRequest();
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.createVnfData(request);
}
-
+
@Test
public void itCreatePnfData() throws IOException {
HttpServletRequest request = mockRequest();
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.createPnfData(request);
}
-
+
@Test
public void itGetNsdInfo() throws IOException {
String nsdId="1";
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.getNsdInfo(nsdId);
}
-
+
@Test
public void itGetVnfInfo() throws IOException {
String nsdId="1";
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.getVnfInfo(nsdId);
}
-
+
@Test
public void itGetPnfInfo() throws IOException {
String nsdId="1";
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.getPnfInfo(nsdId);
}
-
+
@Test
public void itCanListNsTemplates() throws IOException {
VfcService vfcService = mock(VfcService.class);
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.listNsTemplates();
}
-
+
@Test
public void itCanGetVnfInfoById() throws IOException {
String nsdId="1";
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.getVnfInfoById(nsdId);
}
-
+
@Test
public void itCanFetchNsTemplateData() throws IOException {
HttpServletRequest request = mockRequest();
service.fetchNsTemplateData(request);
}
- }
\ No newline at end of file
+ }