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 / CloudOrchestrationTest.java
index 5c5a9e9..9ae1e5b 100644 (file)
@@ -27,12 +27,9 @@ import static com.github.tomakehurst.wiremock.client.WireMock.post;
 import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-
 import java.io.File;
 import java.io.IOException;
-
 import javax.ws.rs.core.MediaType;
-
 import org.apache.http.HttpStatus;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -47,207 +44,242 @@ import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpMethod;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.util.UriComponentsBuilder;
-
 import com.fasterxml.jackson.databind.ObjectMapper;
 
 
 public class CloudOrchestrationTest extends BaseTest {
-       
-       private static final String path = "/onap/so/infra/cloudResources/v1";
-
-       private HttpHeaders headers = new HttpHeaders();
-
-       @Before
-       public void setupTestClass() throws Exception{
-               wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl(""))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_CREATED)));
-       }
-
-       @Test
-       public void testCreateOpEnvObjectMapperError() throws IOException {
-               
-               headers.set("Accept", MediaType.APPLICATION_JSON);
-               headers.set("Content-Type", MediaType.APPLICATION_JSON);
-               HttpEntity<String> entity = new HttpEntity<String>(null, headers);
-       
-               UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments");
-               ResponseEntity<String> response = restTemplate.exchange(
-                               builder.toUriString(),
-                               HttpMethod.POST, entity, String.class);
-
-               String body = response.getBody().toString();
-               assertTrue(body.contains("Mapping of request to JSON object failed."));
-               assertEquals(400, response.getStatusCodeValue());
-       }
-       
-       @Test
-       public void testCreateOpEnvError() throws IOException {
-               
-               String request = "{\"requestDetails\":{\"requestInfo\":{\"resourceType\":\"operationalEnvironment\",\"instanceName\": \"myOpEnv\",\"source\": \"VID\",\"requestorId\": \"xxxxxx\"},"
-                                                                                       + "     \"requestParameters\": {\"tenantContext\": \"Test\",\"workloadContext\": \"ECOMP_E2E-IST\"}}}";
-               headers.set("Accept", MediaType.APPLICATION_JSON);
-               headers.set("Content-Type", MediaType.APPLICATION_JSON);
-               HttpEntity<String> entity = new HttpEntity<String>(request, headers);
-       
-               UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments");
-                      
-               ResponseEntity<String> response = restTemplate.exchange(
-                               builder.toUriString(),
-                               HttpMethod.POST, entity, String.class);
-
-               String body = response.getBody().toString();
-               assertTrue(body.contains("Mapping of request to JSON object failed"));
-               assertEquals(400, response.getStatusCodeValue());
-       }
-       
-       @Test
-       public void testCreateOpEnvReqRecordDuplicateCheck() throws IOException {
-               wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo("{\"instanceIdMap\":null,\"instanceName\":\"myOpEnv\",\"requestScope\":\"operationalEnvironment\"}")).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
-                               .withBody(String.format(getResponseTemplate, "123", "PENDING"))
-                               .withStatus(HttpStatus.SC_OK)));
-               ObjectMapper mapper = new ObjectMapper();
-               TenantIsolationRequest request = mapper.readValue(new File("src/test/resources/TenantIsolation/ECOMPOperationEnvironmentCreate.json"), TenantIsolationRequest.class);
-               headers.set("Accept", MediaType.APPLICATION_JSON);
-               headers.set("Content-Type", MediaType.APPLICATION_JSON);
-               HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
-
-
-               UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments");
-                      
-               ResponseEntity<String> response = restTemplate.exchange(
-                               builder.toUriString(),
-                               HttpMethod.POST, entity, String.class);
-               
-               assertEquals(409, response.getStatusCodeValue());
-       }
-       
-       @Test
-       public void testCreateOperationalEnvironment() throws IOException {
-               ObjectMapper mapper = new ObjectMapper();
-               TenantIsolationRequest request = mapper.readValue(new File("src/test/resources/TenantIsolation/ECOMPOperationEnvironmentCreate.json"), TenantIsolationRequest.class);
-               headers.set("Accept", MediaType.APPLICATION_JSON);
-               headers.set("Content-Type", MediaType.APPLICATION_JSON);
-               headers.set("X-TransactionID", "987654321");
-               HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
-       
-               UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments");
-               wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo("{\"instanceIdMap\":null,\"instanceName\":\"myOpEnv\",\"requestScope\":\"operationalEnvironment\"}")).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
-                               .withStatus(HttpStatus.SC_NOT_FOUND)));
-               ResponseEntity<String> response = restTemplate.exchange(
-                               builder.toUriString(),
-                               HttpMethod.POST, entity, String.class);
-               assertEquals(200, response.getStatusCodeValue());
-       }
-       
-       @Test
-       public void testCreateVNFDuplicateCheck() throws IOException {
-               wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo("{\"instanceIdMap\":null,\"instanceName\":\"myVnfOpEnv\",\"requestScope\":\"operationalEnvironment\"}")).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
-                               .withBody(String.format(getResponseTemplate, "requestId", Status.IN_PROGRESS.toString()))
-                               .withStatus(HttpStatus.SC_OK)));
-               ObjectMapper mapper = new ObjectMapper();
-               TenantIsolationRequest request = mapper.readValue(new File("src/test/resources/TenantIsolation/VNFOperationEnvironmentCreate.json"), TenantIsolationRequest.class);
-               headers.set("Accept", MediaType.APPLICATION_JSON);
-               headers.set("Content-Type", MediaType.APPLICATION_JSON);
-               HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
-       
-               UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments");
-                      
-               ResponseEntity<String> response = restTemplate.exchange(
-                               builder.toUriString(),
-                               HttpMethod.POST, entity, String.class);
-               assertEquals(409, response.getStatusCodeValue());
-       }
-       
-       @Test
-       public void testCreateVNF() throws IOException {
-               ObjectMapper mapper = new ObjectMapper();
-               TenantIsolationRequest request = mapper.readValue(new File("src/test/resources/TenantIsolation/VNFOperationEnvironmentCreate.json"), TenantIsolationRequest.class);
-               headers.set("Accept", MediaType.APPLICATION_JSON);
-               headers.set("Content-Type", MediaType.APPLICATION_JSON);
-               HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
-       
-               UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments");
-               wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo("{\"instanceIdMap\":null,\"instanceName\":\"myVnfOpEnv\",\"requestScope\":\"operationalEnvironment\"}")).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
-                               .withStatus(HttpStatus.SC_NOT_FOUND)));
-
-               ResponseEntity<String> response = restTemplate.exchange(
-                               builder.toUriString(),
-                               HttpMethod.POST, entity, String.class);
-               assertEquals(200, response.getStatusCodeValue());
-       }
-       
-       @Test
-       public void testActivate() throws IOException {
-               ObjectMapper mapper = new ObjectMapper();
-               TenantIsolationRequest request = mapper.readValue(new File("src/test/resources/TenantIsolation/ActivateOperationEnvironment.json"), TenantIsolationRequest.class);
-               headers.set("Accept", MediaType.APPLICATION_JSON);
-               headers.set("Content-Type", MediaType.APPLICATION_JSON);
-               HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
-       
-               UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments/ff3514e3-5a33-55df-13ab-12abad84e7ff/activate");
-               wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo("{\"instanceIdMap\":{\"operationalEnvironmentId\":\"ff3514e3-5a33-55df-13ab-12abad84e7ff\"},\"instanceName\":\"myVnfOpEnv\",\"requestScope\":\"operationalEnvironment\"}")).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
-                               .withStatus(HttpStatus.SC_NOT_FOUND)));
-
-               wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl("checkVnfIdStatus/ff3514e3-5a33-55df-13ab-12abad84e7ff"))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
-                               .withStatus(HttpStatus.SC_OK)));
-
-               ResponseEntity<String> response = restTemplate.exchange(
-                               builder.toUriString(),
-                               HttpMethod.POST, entity, String.class);
-               
-               assertEquals(200, response.getStatusCodeValue());
-       }
-       
-       @Test
-       public void testDeactivate() throws IOException {
-               ObjectMapper mapper = new ObjectMapper();
-               TenantIsolationRequest request = mapper.readValue(new File("src/test/resources/TenantIsolation/DeactivateOperationEnvironment.json"), TenantIsolationRequest.class);
-               
-               headers.set("Accept", MediaType.APPLICATION_JSON);
-               headers.set("Content-Type", MediaType.APPLICATION_JSON);
-               HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
-
-
-//             wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo("{\"instanceIdMap\":{\"operationalEnvironmentId\":\"ff3514e3-5a33-55df-13ab-12abad84e7fa\"},\"instanceName\":null,\"requestScope\":\"operationalEnvironment\"}")).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
-//                             .withBodyFile((String.format(getResponseTemplate, "ff3514e3-5a33-55df-13ab-12abad84e7fa", Status.COMPLETE.toString()))).withStatus(HttpStatus.SC_OK)));
-
-               wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl("checkVnfIdStatus/ff3514e3-5a33-55df-13ab-12abad84e7fa"))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
-                               .withStatus(HttpStatus.SC_OK)));
-
-               UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments/ff3514e3-5a33-55df-13ab-12abad84e7fa/deactivate");
-                      
-               ResponseEntity<String> response = restTemplate.exchange(
-                               builder.toUriString(),
-                               HttpMethod.POST, entity, String.class);
-               
-               assertEquals(200, response.getStatusCodeValue());
-       }
-       
-
-       @Test
-       @Ignore
-       public void testDeactivateDupCheck() throws IOException {
-               
-               InfraActiveRequests iar = new InfraActiveRequests();
-               iar.setRequestId("requestId");
-               iar.setOperationalEnvName("myVnfOpEnv");
-               iar.setRequestStatus(Status.IN_PROGRESS.toString());
-               iar.setAction(Action.create.toString());
-               iar.setRequestAction(Action.create.toString());
-               iar.setRequestScope("UNKNOWN");
-               //iarRepo.saveAndFlush(iar);
-               ObjectMapper mapper = new ObjectMapper();
-               String request = mapper.readValue(new File("src/test/resources/TenantIsolation/DeactivateOperationEnvironment.json"), String.class);
-               
-               headers.set("Accept", MediaType.APPLICATION_JSON);
-               headers.set("Content-Type", MediaType.APPLICATION_JSON);
-               HttpEntity<String> entity = new HttpEntity<String>(request, headers);
-       
-               UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments/ff3514e3-5a33-55df-13ab-12abad84e7ff/deactivate");
-                      
-               ResponseEntity<String> response = restTemplate.exchange(
-                               builder.toUriString(),
-                               HttpMethod.POST, entity, String.class);
-               assertEquals(409, response.getStatusCodeValue());
-       }
-       
-}
\ No newline at end of file
+
+    private static final String path = "/onap/so/infra/cloudResources/v1";
+
+    private HttpHeaders headers = new HttpHeaders();
+
+    @Before
+    public void setupTestClass() throws Exception {
+        wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl(""))).willReturn(
+                aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+                        .withStatus(HttpStatus.SC_CREATED)));
+    }
+
+    @Test
+    public void testCreateOpEnvObjectMapperError() throws IOException {
+
+        headers.set("Accept", MediaType.APPLICATION_JSON);
+        headers.set("Content-Type", MediaType.APPLICATION_JSON);
+        HttpEntity<String> entity = new HttpEntity<String>(null, headers);
+
+        UriComponentsBuilder builder =
+                UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments");
+        ResponseEntity<String> response =
+                restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
+
+        String body = response.getBody().toString();
+        assertTrue(body.contains("Mapping of request to JSON object failed."));
+        assertEquals(400, response.getStatusCodeValue());
+    }
+
+    @Test
+    public void testCreateOpEnvError() throws IOException {
+
+        String request =
+                "{\"requestDetails\":{\"requestInfo\":{\"resourceType\":\"operationalEnvironment\",\"instanceName\": \"myOpEnv\",\"source\": \"VID\",\"requestorId\": \"xxxxxx\"},"
+                        + "    \"requestParameters\": {\"tenantContext\": \"Test\",\"workloadContext\": \"ECOMP_E2E-IST\"}}}";
+        headers.set("Accept", MediaType.APPLICATION_JSON);
+        headers.set("Content-Type", MediaType.APPLICATION_JSON);
+        HttpEntity<String> entity = new HttpEntity<String>(request, headers);
+
+        UriComponentsBuilder builder =
+                UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments");
+
+        ResponseEntity<String> response =
+                restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
+
+        String body = response.getBody().toString();
+        assertTrue(body.contains("Mapping of request to JSON object failed"));
+        assertEquals(400, response.getStatusCodeValue());
+    }
+
+    @Test
+    public void testCreateOpEnvReqRecordDuplicateCheck() throws IOException {
+        wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo(
+                "{\"instanceIdMap\":null,\"instanceName\":\"myOpEnv\",\"requestScope\":\"operationalEnvironment\"}"))
+                .willReturn(aResponse()
+                        .withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+                        .withBody(String.format(getResponseTemplate, "123", "PENDING")).withStatus(HttpStatus.SC_OK)));
+        ObjectMapper mapper = new ObjectMapper();
+        TenantIsolationRequest request =
+                mapper.readValue(new File("src/test/resources/TenantIsolation/ECOMPOperationEnvironmentCreate.json"),
+                        TenantIsolationRequest.class);
+        headers.set("Accept", MediaType.APPLICATION_JSON);
+        headers.set("Content-Type", MediaType.APPLICATION_JSON);
+        HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
+
+
+        UriComponentsBuilder builder =
+                UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments");
+
+        ResponseEntity<String> response =
+                restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
+
+        assertEquals(409, response.getStatusCodeValue());
+    }
+
+    @Test
+    public void testCreateOperationalEnvironment() throws IOException {
+        ObjectMapper mapper = new ObjectMapper();
+        TenantIsolationRequest request =
+                mapper.readValue(new File("src/test/resources/TenantIsolation/ECOMPOperationEnvironmentCreate.json"),
+                        TenantIsolationRequest.class);
+        headers.set("Accept", MediaType.APPLICATION_JSON);
+        headers.set("Content-Type", MediaType.APPLICATION_JSON);
+        headers.set("X-TransactionID", "987654321");
+        HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
+
+        UriComponentsBuilder builder =
+                UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments");
+        wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo(
+                "{\"instanceIdMap\":null,\"instanceName\":\"myOpEnv\",\"requestScope\":\"operationalEnvironment\"}"))
+                .willReturn(
+                        aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+                                .withStatus(HttpStatus.SC_NOT_FOUND)));
+        ResponseEntity<String> response =
+                restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
+        assertEquals(200, response.getStatusCodeValue());
+    }
+
+    @Test
+    public void testCreateVNFDuplicateCheck() throws IOException {
+        wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo(
+                "{\"instanceIdMap\":null,\"instanceName\":\"myVnfOpEnv\",\"requestScope\":\"operationalEnvironment\"}"))
+                .willReturn(aResponse()
+                        .withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+                        .withBody(String.format(getResponseTemplate, "requestId", Status.IN_PROGRESS.toString()))
+                        .withStatus(HttpStatus.SC_OK)));
+        ObjectMapper mapper = new ObjectMapper();
+        TenantIsolationRequest request =
+                mapper.readValue(new File("src/test/resources/TenantIsolation/VNFOperationEnvironmentCreate.json"),
+                        TenantIsolationRequest.class);
+        headers.set("Accept", MediaType.APPLICATION_JSON);
+        headers.set("Content-Type", MediaType.APPLICATION_JSON);
+        HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
+
+        UriComponentsBuilder builder =
+                UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments");
+
+        ResponseEntity<String> response =
+                restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
+        assertEquals(409, response.getStatusCodeValue());
+    }
+
+    @Test
+    public void testCreateVNF() throws IOException {
+        ObjectMapper mapper = new ObjectMapper();
+        TenantIsolationRequest request =
+                mapper.readValue(new File("src/test/resources/TenantIsolation/VNFOperationEnvironmentCreate.json"),
+                        TenantIsolationRequest.class);
+        headers.set("Accept", MediaType.APPLICATION_JSON);
+        headers.set("Content-Type", MediaType.APPLICATION_JSON);
+        HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
+
+        UriComponentsBuilder builder =
+                UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments");
+        wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo(
+                "{\"instanceIdMap\":null,\"instanceName\":\"myVnfOpEnv\",\"requestScope\":\"operationalEnvironment\"}"))
+                .willReturn(
+                        aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+                                .withStatus(HttpStatus.SC_NOT_FOUND)));
+
+        ResponseEntity<String> response =
+                restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
+        assertEquals(200, response.getStatusCodeValue());
+    }
+
+    @Test
+    public void testActivate() throws IOException {
+        ObjectMapper mapper = new ObjectMapper();
+        TenantIsolationRequest request =
+                mapper.readValue(new File("src/test/resources/TenantIsolation/ActivateOperationEnvironment.json"),
+                        TenantIsolationRequest.class);
+        headers.set("Accept", MediaType.APPLICATION_JSON);
+        headers.set("Content-Type", MediaType.APPLICATION_JSON);
+        HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
+
+        UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
+                createURLWithPort(path) + "/operationalEnvironments/ff3514e3-5a33-55df-13ab-12abad84e7ff/activate");
+        wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo(
+                "{\"instanceIdMap\":{\"operationalEnvironmentId\":\"ff3514e3-5a33-55df-13ab-12abad84e7ff\"},\"instanceName\":\"myVnfOpEnv\",\"requestScope\":\"operationalEnvironment\"}"))
+                .willReturn(
+                        aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+                                .withStatus(HttpStatus.SC_NOT_FOUND)));
+
+        wireMockServer.stubFor(
+                get(urlPathEqualTo(getTestUrl("checkVnfIdStatus/ff3514e3-5a33-55df-13ab-12abad84e7ff"))).willReturn(
+                        aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+                                .withStatus(HttpStatus.SC_OK)));
+
+        ResponseEntity<String> response =
+                restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
+
+        assertEquals(200, response.getStatusCodeValue());
+    }
+
+    @Test
+    public void testDeactivate() throws IOException {
+        ObjectMapper mapper = new ObjectMapper();
+        TenantIsolationRequest request =
+                mapper.readValue(new File("src/test/resources/TenantIsolation/DeactivateOperationEnvironment.json"),
+                        TenantIsolationRequest.class);
+
+        headers.set("Accept", MediaType.APPLICATION_JSON);
+        headers.set("Content-Type", MediaType.APPLICATION_JSON);
+        HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
+
+
+        // wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo("{\"instanceIdMap\":{\"operationalEnvironmentId\":\"ff3514e3-5a33-55df-13ab-12abad84e7fa\"},\"instanceName\":null,\"requestScope\":\"operationalEnvironment\"}")).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE,
+        // MediaType.APPLICATION_JSON)
+        // .withBodyFile((String.format(getResponseTemplate, "ff3514e3-5a33-55df-13ab-12abad84e7fa",
+        // Status.COMPLETE.toString()))).withStatus(HttpStatus.SC_OK)));
+
+        wireMockServer.stubFor(
+                get(urlPathEqualTo(getTestUrl("checkVnfIdStatus/ff3514e3-5a33-55df-13ab-12abad84e7fa"))).willReturn(
+                        aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+                                .withStatus(HttpStatus.SC_OK)));
+
+        UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
+                createURLWithPort(path) + "/operationalEnvironments/ff3514e3-5a33-55df-13ab-12abad84e7fa/deactivate");
+
+        ResponseEntity<String> response =
+                restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
+
+        assertEquals(200, response.getStatusCodeValue());
+    }
+
+
+    @Test
+    @Ignore
+    public void testDeactivateDupCheck() throws IOException {
+
+        InfraActiveRequests iar = new InfraActiveRequests();
+        iar.setRequestId("requestId");
+        iar.setOperationalEnvName("myVnfOpEnv");
+        iar.setRequestStatus(Status.IN_PROGRESS.toString());
+        iar.setAction(Action.create.toString());
+        iar.setRequestAction(Action.create.toString());
+        iar.setRequestScope("UNKNOWN");
+        // iarRepo.saveAndFlush(iar);
+        ObjectMapper mapper = new ObjectMapper();
+        String request = mapper.readValue(
+                new File("src/test/resources/TenantIsolation/DeactivateOperationEnvironment.json"), String.class);
+
+        headers.set("Accept", MediaType.APPLICATION_JSON);
+        headers.set("Content-Type", MediaType.APPLICATION_JSON);
+        HttpEntity<String> entity = new HttpEntity<String>(request, headers);
+
+        UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
+                createURLWithPort(path) + "/operationalEnvironments/ff3514e3-5a33-55df-13ab-12abad84e7ff/deactivate");
+
+        ResponseEntity<String> response =
+                restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
+        assertEquals(409, response.getStatusCodeValue());
+    }
+
+}