aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogic.java11
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java5
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java22
4 files changed, 35 insertions, 9 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
index 706985fb5..c46266790 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
@@ -38,6 +38,7 @@ import org.onap.vid.services.AsyncInstantiationBusinessLogic;
import org.onap.vid.services.AuditService;
import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -168,6 +169,11 @@ public class AsyncInstantiationController extends VidRestrictedBaseController {
return new MsoResponseWrapper2(200, uuids);
}
+ @GetMapping("templateTopology/{jobId}")
+ public ServiceInstantiation getTemplateTopology(HttpServletRequest request, @PathVariable(value="jobId") UUID jobId) {
+ return asyncInstantiationBL.getJobRequestAsTemplate(jobId);
+ }
+
@RequestMapping(value = "/auditStatusForRetry/{trackById}", method = RequestMethod.GET)
public JobAuditStatus getResourceAuditStatus(HttpServletRequest request, @PathVariable(value="trackById") String trackById) {
return auditService.getResourceAuditStatus(trackById);
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogic.java b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogic.java
index 1202fc9e3..e00758aa1 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogic.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogic.java
@@ -20,6 +20,10 @@
package org.onap.vid.services;
+import java.util.Arrays;
+import java.util.List;
+import java.util.UUID;
+import java.util.function.Consumer;
import org.onap.vid.aai.model.ResourceType;
import org.onap.vid.job.Job;
import org.onap.vid.job.impl.JobSharedData;
@@ -28,11 +32,6 @@ import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
import org.onap.vid.mso.RestObject;
import org.onap.vid.mso.rest.AsyncRequestStatus;
-import java.util.Arrays;
-import java.util.List;
-import java.util.UUID;
-import java.util.function.Consumer;
-
public interface AsyncInstantiationBusinessLogic {
List<String> PARAMS_TO_IGNORE = Arrays.asList("vnf_name", "vf_module_name");
@@ -109,5 +108,7 @@ public interface AsyncInstantiationBusinessLogic {
ServiceInstantiation getBulkForRetry(UUID jobId);
+ ServiceInstantiation getJobRequestAsTemplate(UUID jobId);
+
String getResumeRequestPath(String requestId);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java
index c77eb8230..86d630b2a 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java
@@ -534,6 +534,11 @@ public class AsyncInstantiationBusinessLogicImpl implements
}
@Override
+ public ServiceInstantiation getJobRequestAsTemplate(UUID jobId) {
+ return asyncInstantiationRepository.getJobRequest(jobId);
+ }
+
+ @Override
public void addResourceInfo(JobSharedData sharedData, Job.JobStatus jobStatus, String instanceId) {
String trackById = ((BaseResource) sharedData.getRequest()).getTrackById();
ResourceInfo resourceInfo = new ResourceInfo(trackById, sharedData.getRootJobId(), instanceId, jobStatus, null);
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java
index 54015d4b3..56aaf1e83 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java
@@ -35,15 +35,16 @@ import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.matchesPattern;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
+import static org.hamcrest.Matchers.sameInstance;
import static org.hamcrest.core.Every.everyItem;
import static org.hamcrest.core.IsEqual.equalTo;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.anyInt;
-import static org.mockito.Mockito.anyString;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
@@ -199,6 +200,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
Mockito.reset(aaiClient);
Mockito.reset(jobAdapterMock);
Mockito.reset(jobsBrokerServiceMock);
+ Mockito.reset(asyncInstantiationRepository);
mockAaiClientAnyNameFree();
enableAddCloudOwnerOnMsoRequest();
}
@@ -1366,4 +1368,16 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
assertThat(path, equalTo("/serviceInstantiation/v7/serviceInstances/myService/vnfs/myVNF/vfModules/myVFModule/replace"));
}
+
+ @Test
+ public void getJobRequestAsTemplate_whenIsCalled_asyncInstantiationRepositoryGetJobRequestIsDelegated() {
+ UUID jobId = UUID.randomUUID();
+ ServiceInstantiation expected = mock(ServiceInstantiation.class);
+ doReturn(expected).when(asyncInstantiationRepository).getJobRequest(jobId);
+
+ ServiceInstantiation jobRequestAsTemplate = asyncInstantiationBL.getJobRequestAsTemplate(jobId);
+
+ assertThat(jobRequestAsTemplate, is(sameInstance(expected)));
+
+ }
}