Replaced all tabs with spaces in java and pom.xml
[so.git] / mso-api-handlers / mso-api-handler-infra / src / test / java / org / onap / so / apihandlerinfra / tenantisolation / helpers / AAIClientHelperTest.java
index 6c5e968..3a389ce 100644 (file)
@@ -33,11 +33,9 @@ import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
-
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
-
 import org.apache.http.HttpStatus;
 import org.junit.Test;
 import org.onap.aai.domain.yang.OperationalEnvironment;
@@ -48,100 +46,112 @@ import org.springframework.beans.factory.annotation.Autowired;
 
 
 
-public class AAIClientHelperTest extends BaseTest{
-    
-       @Autowired
-       private AAIClientHelper clientHelper;
-       
-       @Test
-       public void testGetAaiOperationalEnvironmentSuccess() throws Exception { 
-               wireMockServer.stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
-                               .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED)));
-               
-               AAIResultWrapper wrapper = clientHelper.getAaiOperationalEnvironment("EMOE-001");
-               Optional<OperationalEnvironment> aaiOpEnv = wrapper.asBean(OperationalEnvironment.class);
-               assertEquals("EMOE-001", aaiOpEnv.get().getOperationalEnvironmentId());
-       }
-       
-       @Test
-       public void testUpdateSuccess() { 
-               wireMockServer.stubFor(post(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
-                               .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
-               
-               OperationalEnvironment ecompEnv = new OperationalEnvironment();
-               ecompEnv.setTenantContext("Test");
-               ecompEnv.setWorkloadContext("ECOMPL_PSL");
-               
-               try {
-                       AAIClientHelper clientHelper = mock(AAIClientHelper.class);
-                       doNothing().when(clientHelper).updateAaiOperationalEnvironment(any(String.class), any(OperationalEnvironment.class));
-                       clientHelper.updateAaiOperationalEnvironment("EMOE-001", ecompEnv);
-                       
-                       verify(clientHelper, times(1)).updateAaiOperationalEnvironment("EMOE-001", ecompEnv);
-               } catch(Exception e) {
-                       fail("shouldn't reach here");
-               }
-       }
-       
-       @Test
-       public void testUpdateMapSuccess() { 
-               wireMockServer.stubFor(post(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
-                               .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
-               
-               Map<String, String> payload = new HashMap<String, String>();
-               payload.put("tenant-context", "Test");
-               payload.put("workload-context", "ECOMPL_PSL");
-               payload.put("operational-environment-status", "ACTIVE");
-               
-               try {
-                       AAIClientHelper clientHelper = mock(AAIClientHelper.class);
-                       doNothing().when(clientHelper).updateAaiOperationalEnvironment("EMOE-001", payload);
-                       clientHelper.updateAaiOperationalEnvironment("EMOE-001", payload);
-                       
-                       verify(clientHelper, times(1)).updateAaiOperationalEnvironment("EMOE-001", payload);
-               } catch(Exception e) {
-                       fail("shouldn't reach here");
-               }
-       }       
-       
-       @Test
-       public void testCreateSuccess() { 
-               wireMockServer.stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
-                               .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
-               
-               OperationalEnvironment ecompEnv = new OperationalEnvironment();
-               ecompEnv.setOperationalEnvironmentId("opeEvnId");
-               ecompEnv.setTenantContext("Test");
-               ecompEnv.setWorkloadContext("ECOMPL_PSL");
-               
-               try {
-                       AAIClientHelper clientHelper = mock(AAIClientHelper.class);
-                       doNothing().when(clientHelper).createOperationalEnvironment(any(OperationalEnvironment.class));
-                       clientHelper.createOperationalEnvironment(ecompEnv);
-                       
-                       verify(clientHelper, times(1)).createOperationalEnvironment(ecompEnv);
-               } catch(Exception e) {
-                       fail("shouldn't reach here");
-               }
-       }
-       
-       @Test
-       public void testcreateRelationshipSuccess() { 
-               wireMockServer.stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
-                               .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
-               
-               OperationalEnvironment ecompEnv = new OperationalEnvironment();
-               ecompEnv.setTenantContext("Test");
-               ecompEnv.setWorkloadContext("ECOMPL_PSL");
-               
-               try {
-                       AAIClientHelper clientHelper = mock(AAIClientHelper.class);
-                       doNothing().when(clientHelper).createRelationship(anyString(), anyString());
-                       clientHelper.createRelationship("managingEcomp", "vnfOp");
-                       
-                       verify(clientHelper, times(1)).createRelationship("managingEcomp", "vnfOp");
-               } catch(Exception e) {
-                       fail("shouldn't reach here");
-               }
-       }
+public class AAIClientHelperTest extends BaseTest {
+
+    @Autowired
+    private AAIClientHelper clientHelper;
+
+    @Test
+    public void testGetAaiOperationalEnvironmentSuccess() throws Exception {
+        wireMockServer.stubFor(
+                get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+                        .willReturn(aResponse().withHeader("Content-Type", "application/json")
+                                .withBodyFile("vnfoperenv/ecompOperationalEnvironment.json")
+                                .withStatus(HttpStatus.SC_ACCEPTED)));
+
+        AAIResultWrapper wrapper = clientHelper.getAaiOperationalEnvironment("EMOE-001");
+        Optional<OperationalEnvironment> aaiOpEnv = wrapper.asBean(OperationalEnvironment.class);
+        assertEquals("EMOE-001", aaiOpEnv.get().getOperationalEnvironmentId());
+    }
+
+    @Test
+    public void testUpdateSuccess() {
+        wireMockServer.stubFor(
+                post(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+                        .willReturn(aResponse().withHeader("Content-Type", "application/json")
+                                .withStatus(HttpStatus.SC_ACCEPTED)));
+
+        OperationalEnvironment ecompEnv = new OperationalEnvironment();
+        ecompEnv.setTenantContext("Test");
+        ecompEnv.setWorkloadContext("ECOMPL_PSL");
+
+        try {
+            AAIClientHelper clientHelper = mock(AAIClientHelper.class);
+            doNothing().when(clientHelper).updateAaiOperationalEnvironment(any(String.class),
+                    any(OperationalEnvironment.class));
+            clientHelper.updateAaiOperationalEnvironment("EMOE-001", ecompEnv);
+
+            verify(clientHelper, times(1)).updateAaiOperationalEnvironment("EMOE-001", ecompEnv);
+        } catch (Exception e) {
+            fail("shouldn't reach here");
+        }
+    }
+
+    @Test
+    public void testUpdateMapSuccess() {
+        wireMockServer.stubFor(
+                post(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+                        .willReturn(aResponse().withHeader("Content-Type", "application/json")
+                                .withStatus(HttpStatus.SC_ACCEPTED)));
+
+        Map<String, String> payload = new HashMap<String, String>();
+        payload.put("tenant-context", "Test");
+        payload.put("workload-context", "ECOMPL_PSL");
+        payload.put("operational-environment-status", "ACTIVE");
+
+        try {
+            AAIClientHelper clientHelper = mock(AAIClientHelper.class);
+            doNothing().when(clientHelper).updateAaiOperationalEnvironment("EMOE-001", payload);
+            clientHelper.updateAaiOperationalEnvironment("EMOE-001", payload);
+
+            verify(clientHelper, times(1)).updateAaiOperationalEnvironment("EMOE-001", payload);
+        } catch (Exception e) {
+            fail("shouldn't reach here");
+        }
+    }
+
+    @Test
+    public void testCreateSuccess() {
+        wireMockServer.stubFor(
+                put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+                        .willReturn(aResponse().withHeader("Content-Type", "application/json")
+                                .withStatus(HttpStatus.SC_ACCEPTED)));
+
+        OperationalEnvironment ecompEnv = new OperationalEnvironment();
+        ecompEnv.setOperationalEnvironmentId("opeEvnId");
+        ecompEnv.setTenantContext("Test");
+        ecompEnv.setWorkloadContext("ECOMPL_PSL");
+
+        try {
+            AAIClientHelper clientHelper = mock(AAIClientHelper.class);
+            doNothing().when(clientHelper).createOperationalEnvironment(any(OperationalEnvironment.class));
+            clientHelper.createOperationalEnvironment(ecompEnv);
+
+            verify(clientHelper, times(1)).createOperationalEnvironment(ecompEnv);
+        } catch (Exception e) {
+            fail("shouldn't reach here");
+        }
+    }
+
+    @Test
+    public void testcreateRelationshipSuccess() {
+        wireMockServer.stubFor(
+                put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+                        .willReturn(aResponse().withHeader("Content-Type", "application/json")
+                                .withStatus(HttpStatus.SC_ACCEPTED)));
+
+        OperationalEnvironment ecompEnv = new OperationalEnvironment();
+        ecompEnv.setTenantContext("Test");
+        ecompEnv.setWorkloadContext("ECOMPL_PSL");
+
+        try {
+            AAIClientHelper clientHelper = mock(AAIClientHelper.class);
+            doNothing().when(clientHelper).createRelationship(anyString(), anyString());
+            clientHelper.createRelationship("managingEcomp", "vnfOp");
+
+            verify(clientHelper, times(1)).createRelationship("managingEcomp", "vnfOp");
+        } catch (Exception e) {
+            fail("shouldn't reach here");
+        }
+    }
 }