sonar issue, MsoMulticloudUtilsTest Use assertSame instead
[so.git] / adapters / mso-adapter-utils / src / test / java / org / onap / so / openstack / utils / MsoMulticloudUtilsTest.java
index 995db52..d197550 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2019 Samsung Intellectual Property. All rights reserved.
+ * Copyright (C) 2022 Samsung Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,11 +24,11 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
 import static com.github.tomakehurst.wiremock.client.WireMock.delete;
 import static com.github.tomakehurst.wiremock.client.WireMock.get;
 import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertSame;
 import static org.junit.Assert.fail;
 import static org.mockito.Mockito.when;
 import static org.onap.so.openstack.utils.MsoMulticloudUtils.MULTICLOUD_QUERY_BODY_NULL;
@@ -95,9 +95,9 @@ public class MsoMulticloudUtilsTest extends BaseTest {
         wireMockServer.stubFor(get(urlEqualTo(MULTICLOUD_GET_PATH)).inScenario("CREATE").whenScenarioStateIs("UPDATING")
                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
                         .withBodyFile("MulticloudGetUpdateResponse.json").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);
+        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, false);
         wireMockServer.resetScenarios();
         assertNotNull(result);
         assertEquals("TEST-stack", result.getName());
@@ -113,13 +113,13 @@ public class MsoMulticloudUtilsTest extends BaseTest {
         StackInfo result =
                 multicloudUtils.deleteStack("MTN14", "CloudOwner", "TEST-tenant", "TEST-stack/TEST-workload");
         assertNotNull(result);
-        assertTrue(HeatStatus.NOTFOUND == result.getStatus());
+        assertSame(HeatStatus.NOTFOUND, result.getStatus());
     }
 
     @Test
     public void queryStack() throws MsoException {
         StackInfo result = multicloudUtils.queryStack("MTN13", "CloudOwner", "TEST-tenant", "instanceId");
-        assertTrue(HeatStatus.NOTFOUND == result.getStatus());
+        assertSame(HeatStatus.NOTFOUND, result.getStatus());
     }
 
     @Test
@@ -129,7 +129,7 @@ public class MsoMulticloudUtilsTest extends BaseTest {
                         .withStatus(HttpStatus.SC_OK)));
 
         StackInfo result = multicloudUtils.queryStack("MTN13", "CloudOwner", "TEST-tenant", "instanceName/instanceId");
-        assertTrue(HeatStatus.FAILED == result.getStatus());
+        assertSame(HeatStatus.FAILED, result.getStatus());
         assertEquals(MULTICLOUD_QUERY_BODY_NULL, result.getStatusMessage());
     }
 
@@ -143,7 +143,7 @@ public class MsoMulticloudUtilsTest extends BaseTest {
         CloudInfo cloudInfo = new CloudInfo("cloudSiteId", "cloudOwner", "tenantId", "tenantName");
         VduInstance vduInstance = multicloudUtils.deleteVdu(cloudInfo, "instanceId", 3);
         assertNotNull(vduInstance);
-        assertTrue(VduStateType.DELETED == vduInstance.getStatus().getState());
+        assertSame(VduStateType.DELETED, vduInstance.getStatus().getState());
     }
 
     @Ignore
@@ -155,7 +155,8 @@ public class MsoMulticloudUtilsTest extends BaseTest {
             cloudSite.setIdentityService(new CloudIdentity());
             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,
+                    false);
         } catch (MsoException e) {
             assertEquals("0 : Multicloud client could not be initialized", e.toString());
             return;
@@ -169,7 +170,8 @@ public class MsoMulticloudUtilsTest extends BaseTest {
             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,
+                    false);
         } catch (MsoException e) {
             assertEquals("0 : Bad Request", e.toString());
             return;
@@ -179,12 +181,12 @@ 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).withBody("{}")));
+        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, false);
         assertNotNull(result);
-        assertEquals("TEST-stack/", result.getName());
+        assertEquals("TEST-stack", result.getName());
     }
 }