aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java649
1 files changed, 623 insertions, 26 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java
index 831a789711..d8a6282a8a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java
@@ -20,16 +20,12 @@
package org.openecomp.mso.apihandlerinfra;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+import java.util.HashMap;
import javax.ws.rs.core.Response;
@@ -38,33 +34,40 @@ import org.apache.http.ProtocolVersion;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.entity.BasicHttpEntity;
import org.apache.http.message.BasicHttpResponse;
-import org.hibernate.HibernateException;
import org.hibernate.Session;
-import org.hibernate.criterion.Criterion;
-import org.hibernate.criterion.Order;
-import org.hibernate.internal.SessionFactoryImpl;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.junit.Ignore;
-import org.mockito.Mockito;
import org.openecomp.mso.apihandler.common.CamundaClient;
import org.openecomp.mso.apihandler.common.RequestClient;
import org.openecomp.mso.apihandler.common.RequestClientFactory;
+import org.openecomp.mso.apihandler.common.ValidationException;
+import org.openecomp.mso.db.AbstractSessionFactoryManager;
import org.openecomp.mso.db.catalog.CatalogDatabase;
import org.openecomp.mso.db.catalog.beans.Service;
import org.openecomp.mso.db.catalog.beans.ServiceRecipe;
import org.openecomp.mso.properties.MsoDatabaseException;
import org.openecomp.mso.properties.MsoJavaProperties;
import org.openecomp.mso.properties.MsoPropertiesFactory;
-import org.openecomp.mso.requestsdb.InfraActiveRequests;
import org.openecomp.mso.requestsdb.OperationStatus;
import org.openecomp.mso.requestsdb.RequestsDatabase;
+import org.openecomp.mso.serviceinstancebeans.ServiceInstancesRequest;
+import mockit.Expectations;
import mockit.Mock;
import mockit.MockUp;
+import mockit.Mocked;
public class E2EServiceInstancesTest {
+ private final String compareModelsRequest = "{" +
+ "\"globalSubscriberId\": \"60c3e96e-0970-4871-b6e0-3b6de7561519\"," +
+ "\"serviceType\": \"vnf\"," +
+ "\"modelInvariantIdTarget\": \"60c3e96e-0970-4871-b6e0-3b6de1234567\"," +
+ "\"modelVersionIdTarget\": \"modelVersionIdTarget\"" +
+ "}";
+
+ private final String scaleRequest = "{\"service\":{\"serviceType\":\"example-service-type\",\"globalSubscriberId\":\"test_custormer\",\"resources\":[{\"resourceInstanceId\":\"ns111\",\"scaleType\":\"SCALE_NS\",\"scaleNsData\":{\"scaleNsByStepsData\":{\"numberOfSteps\":\"4\",\"aspectId\":\"TIC_EDGE_HW\",\"scalingDirection\":\"UP\"}}}],\"serviceInstanceName\":\"XXXX\"}}";
+
String jsonBody = "{" +
"\"service\": {" +
"\"name\": \"so_test4\"," +
@@ -143,13 +146,6 @@ public class E2EServiceInstancesTest {
"}" +
"}";
- private final String compareModelsRequest = "{" +
- "\"globalSubscriberId\": \"60c3e96e-0970-4871-b6e0-3b6de7561519\"," +
- "\"serviceType\": \"vnf\"," +
- "\"modelInvariantIdTarget\": \"60c3e96e-0970-4871-b6e0-3b6de1234567\"," +
- "\"modelVersionIdTarget\": \"modelVersionIdTarget\"" +
- "}";
-
@BeforeClass
public static void setUp() throws Exception {
@@ -530,7 +526,8 @@ public class E2EServiceInstancesTest {
}
};
E2EServiceInstances instance = new E2EServiceInstances();
- String request = jsonBody;;
+ String request = jsonBody;
+ ;
Response resp = instance.createE2EServiceInstance(request, "v3");
String respStr = resp.getEntity().toString();
assertTrue(respStr.contains("SVC2000"));
@@ -673,15 +670,166 @@ public class E2EServiceInstancesTest {
.contains("Mapping of request to JSON object failed. No content to map due to end-of-input"));
}
- @Ignore // 1802 merge
@Test
public void deleteE2EServiceInstanceTestNormal() {
+
+ final MockUp<CatalogDatabase> mockCDB = new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName(String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
+ String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ rec.setOrchestrationUri("/test/delE2E");
+ rec.setRecipeTimeout(180);
+ return rec;
+ }
+ };
+
+ final MockUp<MsoRequest> mockMsoRequest = new MockUp<MsoRequest>() {
+ @Mock
+ public void createRequestRecord(Status status, Action action) {
+ return;
+ }
+ };
+
+ final MockUp<CamundaClient> mockCmaundaClient = new MockUp<CamundaClient>() {
+ @Mock
+ public HttpResponse post(String requestId, boolean isBaseVfModule,
+ int recipeTimeout, String requestAction, String serviceInstanceId,
+ String vnfId, String vfModuleId, String volumeGroupId, String networkId, String configurationId,
+ String serviceType, String vnfType, String vfModuleType, String networkType,
+ String requestDetails, String recipeParamXsd)
+ throws ClientProtocolException, IOException {
+ ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
+ HttpResponse resp = new BasicHttpResponse(pv, 200, "test response");
+ BasicHttpEntity entity = new BasicHttpEntity();
+ String body = "{\"response\":\"success\",\"message\":\"success\"}";
+ InputStream instream = new ByteArrayInputStream(body.getBytes());
+ entity.setContent(instream);
+ resp.setEntity(entity);
+ return resp;
+ }
+ };
+
+
E2EServiceInstances instance = new E2EServiceInstances();
String request = "{\"globalSubscriberId\":\"299392392\",\"serviceType\":\"VoLTE\"}";
- Response resp = instance.deleteE2EServiceInstance(request, "v3",
- "12345678");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("SVC1000"));
+
+ instance.deleteE2EServiceInstance(request, "v3", "12345678");
+ mockCDB.tearDown();
+ mockMsoRequest.tearDown();
+ mockCmaundaClient.tearDown();
+
+ }
+
+ @Test
+ public void deleteE2EServiceInstanceTestFail() {
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"globalSubscriberId\":\"299392392\",\"serviceType\":\"VoLTE\"}";
+ instance.deleteE2EServiceInstance(request, "v3", "12345678");
+ }
+
+ @Test
+ public void deleteE2EServiceInstanceTestFailClient(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session) {
+ final MockUp<CatalogDatabase> mockCDB = new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName(String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
+ String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ rec.setOrchestrationUri("/test/delE2E");
+ rec.setRecipeTimeout(180);
+ return rec;
+ }
+ };
+
+ final MockUp<MsoRequest> mockMsoRequest = new MockUp<MsoRequest>() {
+ @Mock
+ public void createRequestRecord(Status status, Action action) {
+ return;
+ }
+ };
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"globalSubscriberId\":\"299392392\",\"serviceType\":\"VoLTE\"}";
+
+ instance.deleteE2EServiceInstance(request, "v3", "12345678");
+ mockCDB.tearDown();
+ mockMsoRequest.tearDown();
+
+ }
+
+ @Test
+ public void deleteE2EServiceInstanceTestFailRecipe(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session) {
+ final MockUp<CatalogDatabase> mockCDB = new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName(String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
+ String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ return rec;
+ }
+ };
+
+ final MockUp<MsoRequest> mockMsoRequest = new MockUp<MsoRequest>() {
+ @Mock
+ public void createRequestRecord(Status status, Action action) {
+ return;
+ }
+ };
+
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession();
+ result = session;
+ }};
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"globalSubscriberId\":\"299392392\",\"serviceType\":\"VoLTE\"}";
+
+ instance.deleteE2EServiceInstance(request, "v3", "12345678");
+ mockCDB.tearDown();
+ mockMsoRequest.tearDown();
+
+ }
+
+ @Test
+ public void deleteE2EServiceInstanceTestFailModelName(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session) {
+ final MockUp<MsoRequest> mockMsoRequest = new MockUp<MsoRequest>() {
+ @Mock
+ public void createRequestRecord(Status status, Action action) {
+ return;
+ }
+ };
+
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession();
+ result = session;
+ }};
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"globalSubscriberId\":\"299392392\",\"serviceType\":\"VoLTE\"}";
+
+ instance.deleteE2EServiceInstance(request, "v3", "12345678");
+ mockMsoRequest.tearDown();
+
}
@Test
@@ -857,6 +1005,294 @@ public class E2EServiceInstancesTest {
}
@Test
+ public void updateE2EServiceInstanceExceptionMsoRequestTest() {
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public OperationStatus getOperationStatusByServiceId(
+ String serviceID) {
+ OperationStatus operationStatus = new OperationStatus();
+ operationStatus.setProgress("100");
+ operationStatus.setResult("finish");
+ return operationStatus;
+ }
+ };
+ new MockUp<E2EServiceInstances>() {
+ @Mock
+ private void createOperationStatusRecordForError(Action action,
+ String requestId) throws MsoDatabaseException {
+
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName(String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
+ String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ return rec;
+ }
+ };
+
+ new MockUp<RequestClientFactory>() {
+ @Mock
+ public RequestClient getRequestClient(String orchestrationURI,
+ MsoJavaProperties props) throws IllegalStateException {
+ RequestClient client = new CamundaClient();
+ client.setUrl("/test/url");
+ return client;
+ }
+ };
+
+ new MockUp<CamundaClient>() {
+ @Mock
+ public HttpResponse post(String requestId, boolean isBaseVfModule,
+ int recipeTimeout, String requestAction,
+ String serviceInstanceId, String vnfId, String vfModuleId,
+ String volumeGroupId, String networkId, String configurationId, String serviceType,
+ String vnfType, String vfModuleType, String networkType,
+ String requestDetails, String recipeParamXsd) {
+ ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
+ HttpResponse resp = new BasicHttpResponse(pv, 202,
+ "test response");
+ BasicHttpEntity entity = new BasicHttpEntity();
+ String body = "{\"response\":\"success\",\"message\":\"success\"}";
+ InputStream instream = new ByteArrayInputStream(body.getBytes());
+ entity.setContent(instream);
+ resp.setEntity(entity);
+ return resp;
+ }
+ };
+ MockUp<MsoRequest> msoRequest = new MockUp<MsoRequest>() {
+ @Mock
+ void parse (ServiceInstancesRequest sir, HashMap<String,String> instanceIdMap, Action action, String version, String originalRequestJSON) throws ValidationException {
+
+ throw new ValidationException("mock failure");
+ }
+ };
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = jsonBody;
+ Response resp = instance.updateE2EServiceInstance(request, "v3", "12345");
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus());
+ msoRequest.tearDown();
+ }
+
+ @Test
+ public void updateE2EServiceInstanceExceptionCatalogDbTest() {
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public OperationStatus getOperationStatusByServiceId(
+ String serviceID) {
+ OperationStatus operationStatus = new OperationStatus();
+ operationStatus.setProgress("100");
+ operationStatus.setResult("finish");
+ return operationStatus;
+ }
+ };
+ new MockUp<E2EServiceInstances>() {
+ @Mock
+ private void createOperationStatusRecordForError(Action action,
+ String requestId) throws MsoDatabaseException {
+
+ }
+ };
+ MockUp<CatalogDatabase> catalog = new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName(String modelName) throws Exception {
+ throw new Exception();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
+ String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ return rec;
+ }
+ };
+
+ new MockUp<RequestClientFactory>() {
+ @Mock
+ public RequestClient getRequestClient(String orchestrationURI,
+ MsoJavaProperties props) throws IllegalStateException {
+ RequestClient client = new CamundaClient();
+ client.setUrl("/test/url");
+ return client;
+ }
+ };
+
+ new MockUp<CamundaClient>() {
+ @Mock
+ public HttpResponse post(String requestId, boolean isBaseVfModule,
+ int recipeTimeout, String requestAction,
+ String serviceInstanceId, String vnfId, String vfModuleId,
+ String volumeGroupId, String networkId, String configurationId, String serviceType,
+ String vnfType, String vfModuleType, String networkType,
+ String requestDetails, String recipeParamXsd) {
+ ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
+ HttpResponse resp = new BasicHttpResponse(pv, 202,
+ "test response");
+ BasicHttpEntity entity = new BasicHttpEntity();
+ String body = "{\"response\":\"success\",\"message\":\"success\"}";
+ InputStream instream = new ByteArrayInputStream(body.getBytes());
+ entity.setContent(instream);
+ resp.setEntity(entity);
+ return resp;
+ }
+ };
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = jsonBody;
+ Response resp = instance.updateE2EServiceInstance(request, "v3", "12345");
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), resp.getStatus());
+ catalog.tearDown();
+ }
+
+ @Test
+ public void updateE2EServiceInstanceNullServiceTest() {
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public OperationStatus getOperationStatusByServiceId(
+ String serviceID) {
+ OperationStatus operationStatus = new OperationStatus();
+ operationStatus.setProgress("100");
+ operationStatus.setResult("finish");
+ return operationStatus;
+ }
+ };
+ new MockUp<E2EServiceInstances>() {
+ @Mock
+ private void createOperationStatusRecordForError(Action action,
+ String requestId) throws MsoDatabaseException {
+
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName(String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+ };
+
+ MockUp<CatalogDatabase> catalog = new MockUp<CatalogDatabase>() {
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
+ String action) {
+ return null;
+ }
+ };
+
+ new MockUp<RequestClientFactory>() {
+ @Mock
+ public RequestClient getRequestClient(String orchestrationURI,
+ MsoJavaProperties props) throws IllegalStateException {
+ RequestClient client = new CamundaClient();
+ client.setUrl("/test/url");
+ return client;
+ }
+ };
+
+ new MockUp<CamundaClient>() {
+ @Mock
+ public HttpResponse post(String requestId, boolean isBaseVfModule,
+ int recipeTimeout, String requestAction,
+ String serviceInstanceId, String vnfId, String vfModuleId,
+ String volumeGroupId, String networkId, String configurationId, String serviceType,
+ String vnfType, String vfModuleType, String networkType,
+ String requestDetails, String recipeParamXsd) {
+ ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
+ HttpResponse resp = new BasicHttpResponse(pv, 202,
+ "test response");
+ BasicHttpEntity entity = new BasicHttpEntity();
+ String body = "{\"response\":\"success\",\"message\":\"success\"}";
+ InputStream instream = new ByteArrayInputStream(body.getBytes());
+ entity.setContent(instream);
+ resp.setEntity(entity);
+ return resp;
+ }
+ };
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = jsonBody;
+ Response resp = instance.updateE2EServiceInstance(request, "v3", "12345");
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), resp.getStatus());
+ catalog.tearDown();
+ }
+
+ @Test
+ public void updateE2EServiceInstanceRequestClientExceptionTest() {
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public OperationStatus getOperationStatusByServiceId(
+ String serviceID) {
+ OperationStatus operationStatus = new OperationStatus();
+ operationStatus.setProgress("100");
+ operationStatus.setResult("finish");
+ return operationStatus;
+ }
+ };
+ new MockUp<E2EServiceInstances>() {
+ @Mock
+ private void createOperationStatusRecordForError(Action action,
+ String requestId) throws MsoDatabaseException {
+
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName(String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
+ String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ return rec;
+ }
+ };
+
+ new MockUp<RequestClientFactory>() {
+ @Mock
+ public RequestClient getRequestClient(String orchestrationURI,
+ MsoJavaProperties props) throws IllegalStateException {
+ RequestClient client = new CamundaClient();
+ client.setUrl("/test/url");
+ return client;
+ }
+ };
+
+ MockUp<CamundaClient> client = new MockUp<CamundaClient>() {
+ @Mock
+ public HttpResponse post(String requestId, boolean isBaseVfModule,
+ int recipeTimeout, String requestAction,
+ String serviceInstanceId, String vnfId, String vfModuleId,
+ String volumeGroupId, String networkId, String configurationId, String serviceType,
+ String vnfType, String vfModuleType, String networkType,
+ String requestDetails, String recipeParamXsd) throws Exception {
+ throw new Exception();
+ }
+ };
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = jsonBody;
+ Response resp = instance.updateE2EServiceInstance(request, "v3", "12345");
+ assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), resp.getStatus());
+ client.tearDown();
+ }
+
+ @Test
public void compareModelwithTargetVersionBadRequest(){
E2EServiceInstances instance = new E2EServiceInstances();
@@ -922,4 +1358,165 @@ public class E2EServiceInstancesTest {
assertTrue(response.getStatus()==202);
}
+
+ @Test
+ public void scaleE2EserviceInstancesTestFailInvalidRequest(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session ) {
+
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession(); result = session;
+ }};
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ Response response = instance.scaleE2EServiceInstance(jsonBody, "v3", "12345");
+ }
+
+ @Test
+ public void scaleE2EserviceInstancesTestNormal() {
+
+ final MockUp<MsoRequest> mockMsoRequest = new MockUp<MsoRequest>() {
+ @Mock
+ public void createRequestRecord(Status status, Action action) {
+ return;
+ }
+ };
+
+ final MockUp<CatalogDatabase> mockCDB = new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName(String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
+ String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ rec.setOrchestrationUri("/test/delE2E");
+ rec.setRecipeTimeout(180);
+ return rec;
+ }
+ };
+
+ final MockUp<RequestClientFactory> mockRequestClient = new MockUp<RequestClientFactory>() {
+ @Mock
+ public RequestClient getRequestClient(String orchestrationURI,
+ MsoJavaProperties props) throws IllegalStateException {
+ RequestClient client = new CamundaClient();
+ client.setUrl("/test/url");
+ return client;
+ }
+ };
+
+ final MockUp<CamundaClient> mockCamundaClient = new MockUp<CamundaClient>() {
+ @Mock
+ public HttpResponse post(String requestId, boolean isBaseVfModule,
+ int recipeTimeout, String requestAction,
+ String serviceInstanceId, String vnfId, String vfModuleId,
+ String volumeGroupId, String networkId, String configurationId, String serviceType,
+ String vnfType, String vfModuleType, String networkType,
+ String requestDetails, String recipeParamXsd) {
+ ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
+ HttpResponse resp = new BasicHttpResponse(pv, 202,
+ "test response");
+ BasicHttpEntity entity = new BasicHttpEntity();
+ String body = "{\"response\":\"success\",\"message\":\"success\"}";
+ InputStream instream = new ByteArrayInputStream(body.getBytes());
+ entity.setContent(instream);
+ resp.setEntity(entity);
+ return resp;
+ }
+ };
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ Response response = instance.scaleE2EServiceInstance(scaleRequest, "v3", "12345");
+ mockMsoRequest.tearDown();
+ mockCDB.tearDown();
+ mockRequestClient.tearDown();
+ mockCamundaClient.tearDown();
+ }
+
+ @Test
+ public void scaleE2EserviceInstancesTestFailCamundaClient(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session) {
+
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession(); result = session;
+ }};
+
+ final MockUp<MsoRequest> mockMsoRequest = new MockUp<MsoRequest>() {
+ @Mock
+ public void createRequestRecord(Status status, Action action) {
+ return;
+ }
+ };
+
+ final MockUp<CatalogDatabase> mockCDB = new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName(String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
+ String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ rec.setOrchestrationUri("/test/delE2E");
+ rec.setRecipeTimeout(180);
+ return rec;
+ }
+ };
+
+ final MockUp<RequestClientFactory> mockRequestClient = new MockUp<RequestClientFactory>() {
+ @Mock
+ public RequestClient getRequestClient(String orchestrationURI,
+ MsoJavaProperties props) throws IllegalStateException {
+ RequestClient client = new CamundaClient();
+ client.setUrl("/test/url");
+ return client;
+ }
+ };
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ Response response = instance.scaleE2EServiceInstance(scaleRequest, "v3", "12345");
+ mockMsoRequest.tearDown();
+ mockCDB.tearDown();
+ mockRequestClient.tearDown();
+ }
+
+ @Test
+ public void scaleE2EserviceInstancesTestFailRequestClient(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session) {
+
+ final MockUp<MsoRequest> mockMsoRequest = new MockUp<MsoRequest>() {
+ @Mock
+ public void createRequestRecord(Status status, Action action) {
+ return;
+ }
+ };
+
+ final MockUp<CatalogDatabase> mockCDB = new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName(String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
+ String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ rec.setOrchestrationUri("/test/delE2E");
+ rec.setRecipeTimeout(180);
+ return rec;
+ }
+ };
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ Response response = instance.scaleE2EServiceInstance(scaleRequest, "v3", "12345");
+ mockMsoRequest.tearDown();
+ mockCDB.tearDown();
+ }
+
}