Replaced all tabs with spaces in java and pom.xml
[so.git] / adapters / mso-adapter-utils / src / test / java / org / onap / so / openstack / utils / MsoMulticloudUtilsTest.java
index e066c4e..0d8f451 100644 (file)
@@ -30,11 +30,9 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.mockito.Mockito.when;
 import static org.onap.so.openstack.utils.MsoMulticloudUtils.MULTICLOUD_QUERY_BODY_NULL;
-
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Optional;
-
 import org.apache.http.HttpStatus;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -67,43 +65,40 @@ public class MsoMulticloudUtilsTest extends BaseTest {
     private CloudConfig cloudConfigMock;
 
     private static final String CREATE_STACK_RESPONSE = "{\"template_type\": \"TEST-template\", \"workload_id\": "
-        + "\"TEST-workload\", \"template_response\": {\"stack\": {\"id\": \"TEST-stack\", \"links\": []}}}";
-    private static final String UPDATE_STACK_RESPONSE = "{\"template_type\": \"TEST-template\", \"workload_id\": "
-            + "\"TEST-workload\"}";
+            + "\"TEST-workload\", \"template_response\": {\"stack\": {\"id\": \"TEST-stack\", \"links\": []}}}";
+    private static final String UPDATE_STACK_RESPONSE =
+            "{\"template_type\": \"TEST-template\", \"workload_id\": " + "\"TEST-workload\"}";
     private static final String GET_CREATE_STACK_RESPONSE = "{\"template_type\": \"TEST-template\", \"workload_id\": "
             + "\"TEST-workload\", \"workload_status\": \"CREATE_COMPLETE\"}";
     private static final String GET_UPDATE_STACK_RESPONSE = "{\"template_type\": \"TEST-template\", \"workload_id\": "
             + "\"TEST-workload\", \"workload_status\": \"UPDATE_COMPLETE\"}";
 
     private static final String MULTICLOUD_CREATE_PATH = "/api/multicloud/v1/CloudOwner/MTN14/infra_workload";
-    private static final String MULTICLOUD_UPDATE_PATH = "/api/multicloud/v1/CloudOwner/MTN14/infra_workload/TEST-workload";
-    private static final String MULTICLOUD_GET_PATH = "/api/multicloud/v1/CloudOwner/MTN14/infra_workload/TEST-workload";
+    private static final String MULTICLOUD_UPDATE_PATH =
+            "/api/multicloud/v1/CloudOwner/MTN14/infra_workload/TEST-workload";
+    private static final String MULTICLOUD_GET_PATH =
+            "/api/multicloud/v1/CloudOwner/MTN14/infra_workload/TEST-workload";
 
     @Test
     public void createStackSuccess() throws MsoException, IOException {
-        wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH)).inScenario("CREATE")
-            .willReturn(aResponse().withHeader("Content-Type", "application/json")
-                .withBody(CREATE_STACK_RESPONSE)
-                .withStatus(HttpStatus.SC_CREATED))
-            .willSetStateTo("CREATING"));
-        wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH))
-                .inScenario("CREATE").whenScenarioStateIs("CREATING")
-                .willReturn(aResponse().withHeader("Content-Type", "application/json")
-                    .withBody(GET_CREATE_STACK_RESPONSE)
-                    .withStatus(HttpStatus.SC_OK)));
-        wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_UPDATE_PATH)).inScenario("CREATE")
-                .willReturn(aResponse().withHeader("Content-Type", "application/json")
-                    .withBody(UPDATE_STACK_RESPONSE)
-                    .withStatus(HttpStatus.SC_ACCEPTED))
+        wireMockServer
+                .stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH)).inScenario("CREATE")
+                        .willReturn(aResponse().withHeader("Content-Type", "application/json")
+                                .withBody(CREATE_STACK_RESPONSE).withStatus(HttpStatus.SC_CREATED))
+                        .willSetStateTo("CREATING"));
+        wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH)).inScenario("CREATE")
+                .whenScenarioStateIs("CREATING").willReturn(aResponse().withHeader("Content-Type", "application/json")
+                        .withBody(GET_CREATE_STACK_RESPONSE).withStatus(HttpStatus.SC_OK)));
+        wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_UPDATE_PATH))
+                .inScenario("CREATE").willReturn(aResponse().withHeader("Content-Type", "application/json")
+                        .withBody(UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_ACCEPTED))
                 .willSetStateTo("UPDATING"));
-        wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH))
-                .inScenario("CREATE").whenScenarioStateIs("UPDATING")
-                .willReturn(aResponse().withHeader("Content-Type", "application/json")
-                    .withBody(GET_UPDATE_STACK_RESPONSE)
-                    .withStatus(HttpStatus.SC_OK)));
-        StackInfo result = multicloudUtils.createStack("MTN14", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(),
-            "TEST-heat", new HashMap<>(), true, 200, "TEST-env",
-            new HashMap<>(), new HashMap<>(), false);
+        wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH)).inScenario("CREATE")
+                .whenScenarioStateIs("UPDATING").willReturn(aResponse().withHeader("Content-Type", "application/json")
+                        .withBody(GET_UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_OK)));
+        StackInfo result =
+                multicloudUtils.createStack("MTN14", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(),
+                        "TEST-heat", new HashMap<>(), true, 200, "TEST-env", new HashMap<>(), new HashMap<>(), false);
         wireMockServer.resetScenarios();
         assertNotNull(result);
         assertEquals("TEST-stack", result.getName());
@@ -125,9 +120,8 @@ public class MsoMulticloudUtilsTest extends BaseTest {
     @Test
     public void queryStackWithNullMulticloudQueryBody() throws MsoException {
         wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload/instanceId"))
-            .willReturn(aResponse().withHeader("Content-Type", "application/json")
-                .withBody(CREATE_STACK_RESPONSE)
-                .withStatus(HttpStatus.SC_OK)));
+                .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(CREATE_STACK_RESPONSE)
+                        .withStatus(HttpStatus.SC_OK)));
 
         StackInfo result = multicloudUtils.queryStack("MTN13", "CloudOwner", "TEST-tenant", "instanceId");
         assertTrue(HeatStatus.FAILED == result.getStatus());
@@ -136,8 +130,7 @@ public class MsoMulticloudUtilsTest extends BaseTest {
 
     @Test(expected = VduException.class)
     public void updateVdu() throws MsoException {
-        multicloudUtils.updateVdu(new CloudInfo(), "instanceId", new HashMap<>(), new  VduModelInfo(),
-            false);
+        multicloudUtils.updateVdu(new CloudInfo(), "instanceId", new HashMap<>(), new VduModelInfo(), false);
     }
 
     @Test
@@ -148,17 +141,16 @@ public class MsoMulticloudUtilsTest extends BaseTest {
         assertTrue(VduStateType.DELETED == vduInstance.getStatus().getState());
     }
 
-    @Ignore @Test
+    @Ignore
+    @Test
     public void createStackMulticloudClientIsNull() {
         try {
             multicloudUtilsMock.cloudConfig = cloudConfigMock;
             CloudSite cloudSite = new CloudSite();
             cloudSite.setIdentityService(new CloudIdentity());
-            when(cloudConfigMock.getCloudSite("MTN13")).
-                thenReturn(Optional.of(cloudSite));
+            when(cloudConfigMock.getCloudSite("MTN13")).thenReturn(Optional.of(cloudSite));
             multicloudUtilsMock.createStack("MNT14", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(),
-                "TEST-heat", new HashMap<>(), false, 200, "TEST-env",
-                new HashMap<>(), new HashMap<>(), false);
+                    "TEST-heat", new HashMap<>(), false, 200, "TEST-env", new HashMap<>(), new HashMap<>(), false);
         } catch (MsoException e) {
             assertEquals("0 : Multicloud client could not be initialized", e.toString());
             return;
@@ -169,12 +161,10 @@ public class MsoMulticloudUtilsTest extends BaseTest {
     @Test
     public void createStackBadRequest() {
         try {
-            wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH))
-                .willReturn(aResponse().withHeader("Content-Type", "application/json")
-                    .withStatus(HttpStatus.SC_BAD_REQUEST)));
+            wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH)).willReturn(
+                    aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_BAD_REQUEST)));
             multicloudUtils.createStack("MTN14", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(),
-                "TEST-heat", new HashMap<>(), false, 200, "TEST-env",
-                new HashMap<>(), new HashMap<>(), false);
+                    "TEST-heat", new HashMap<>(), false, 200, "TEST-env", new HashMap<>(), new HashMap<>(), false);
         } catch (MsoException e) {
             assertEquals("0 : Bad Request", e.toString());
             return;
@@ -184,12 +174,11 @@ public class MsoMulticloudUtilsTest extends BaseTest {
 
     @Test
     public void createStackEmptyResponseEntity() throws MsoException {
-        wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH))
-            .willReturn(aResponse().withHeader("Content-Type", "application/json")
-                .withStatus(HttpStatus.SC_CREATED)));
-        StackInfo result = multicloudUtils.createStack("MTN14", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(),
-            "TEST-heat", new HashMap<>(), false, 200, "TEST-env",
-            new HashMap<>(), new HashMap<>(), false);
+        wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH)).willReturn(
+                aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_CREATED)));
+        StackInfo result =
+                multicloudUtils.createStack("MTN14", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(),
+                        "TEST-heat", new HashMap<>(), false, 200, "TEST-env", new HashMap<>(), new HashMap<>(), false);
         assertNotNull(result);
         assertEquals("TEST-stack/", result.getName());
     }