diff options
Diffstat (limited to 'adapters/mso-openstack-adapters/src/test/java')
10 files changed, 56 insertions, 16 deletions
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/msoopenstackadapters/EmbeddedMariaDbConfig.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/msoopenstackadapters/EmbeddedMariaDbConfig.java index f1ee0eae78..d552f8d893 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/msoopenstackadapters/EmbeddedMariaDbConfig.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/msoopenstackadapters/EmbeddedMariaDbConfig.java @@ -23,7 +23,7 @@ import ch.vorburger.exec.ManagedProcessException; import ch.vorburger.mariadb4j.DBConfigurationBuilder; import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; +import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/BpelRestClientTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/BpelRestClientTest.java index 845155f7f0..02a5f25b41 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/BpelRestClientTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/BpelRestClientTest.java @@ -28,7 +28,7 @@ import org.junit.Test; import org.onap.so.adapters.vnf.BaseRestTestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.context.embedded.LocalServerPort; +import org.springframework.boot.web.server.LocalServerPort; public class BpelRestClientTest extends BaseRestTestUtils { diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java index 094d308221..f8dcddde04 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java @@ -25,10 +25,12 @@ import org.junit.Test; import org.onap.so.adapters.vnf.BaseRestTestUtils; import org.onap.so.entity.MsoRequest; import org.onap.so.openstack.beans.NetworkRollback; +import org.onap.so.openstack.beans.Subnet; import org.springframework.beans.factory.annotation.Autowired; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.containing; @@ -184,8 +186,11 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils { " </soapenv:Body>\n" + "</soapenv:Envelope>") .withStatus(HttpStatus.SC_OK))); + HashMap<String,String> networkParams = new HashMap<String,String>(); + networkParams.put("shared", "true"); + networkParams.put("external", "false"); impl.updateNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c", "dvspg-VCE_VPE-mtjnj40avbc", - "dvspg-VCE_VPE-mtjnj40avbc", "physicalNetworkName", new ArrayList<>(), new ArrayList<>(), "messageId", + "dvspg-VCE_VPE-mtjnj40avbc", "physicalNetworkName", new ArrayList<>(), new ArrayList<Subnet>(), networkParams, "messageId", new MsoRequest(), "http://localhost:"+wireMockPort+"/notificationUrl"); } @@ -199,14 +204,17 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils { mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", "dvspg-VCE_VPE-mtjnj40avbc"); mockOpenStackGetStackDeleteOrUpdateComplete_200("OpenstackResponse_Stack_UpdateComplete.json"); mockOpenStackPutPublicUrlStackByNameAndID_NETWORK2_200(); + HashMap<String,String> networkParams = new HashMap<String,String>(); + networkParams.put("shared", "true"); + networkParams.put("external", "false"); impl.updateNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c", "dvspg-VCE_VPE-mtjnj40avbc", - "dvspg-VCE_VPE-mtjnj40avbc", "physicalNetworkName", new ArrayList<>(), new ArrayList<>(), "messageId", + "dvspg-VCE_VPE-mtjnj40avbc", "physicalNetworkName", new ArrayList<>(), new ArrayList<>(), networkParams, "messageId", new MsoRequest(), "http://localhost:"+wireMockPort+"/notificationUrl"); } @Test public void updateNetworkATest_NetworkException() { impl.updateNetworkA("cloudSiteId", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c", "networkId", - "dvspg-VCE_VPE-mtjnj40avbc", "physicalNetworkName", new ArrayList<>(), new ArrayList<>(), "messageId", + "dvspg-VCE_VPE-mtjnj40avbc", "physicalNetworkName", new ArrayList<>(), new ArrayList<>(), new HashMap<String,String>(), "messageId", new MsoRequest(), "http://localhost:"+wireMockPort+"/notificationUrl"); } @@ -237,8 +245,10 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils { .withStatus(HttpStatus.SC_OK))); mockOpenStackGetStackCreatedVUSP_200(); mockOpenStackPostStacks_200(); + mockOpenStackPostStacks_200(); + HashMap<String,String> networkParams = new HashMap<String,String>(); impl.createNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c", "vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0", - "physicalNetworkName", new ArrayList<>(), false, false, new ArrayList<>(), "messageId", + "physicalNetworkName", new ArrayList<>(), false, false, new ArrayList<>(), networkParams, "messageId", new MsoRequest(), "http://localhost:"+wireMockPort+"/notificationUrl"); } @@ -251,15 +261,18 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils { .withStatus(HttpStatus.SC_OK))); mockOpenStackGetStackCreatedVUSP_200(); mockOpenStackPostStacks_200(); + HashMap<String,String> networkParams = new HashMap<String,String>(); + networkParams.put("shared", "true"); + networkParams.put("external", "false"); impl.createNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c", "vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0", - "physicalNetworkName", new ArrayList<>(), false, false, new ArrayList<>(), "messageId", + "physicalNetworkName", new ArrayList<>(), false, false, new ArrayList<>(), networkParams, "messageId", new MsoRequest(), "http://localhost:"+wireMockPort+"/notificationUrl"); } @Test public void createNetworkATest_NetworkException() { impl.createNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c", "vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0", - "physicalNetworkName", new ArrayList<>(), false, false, new ArrayList<>(), "messageId", + "physicalNetworkName", new ArrayList<>(), false, false, new ArrayList<>(), new HashMap<String,String>(), "messageId", new MsoRequest(), "http://localhost:"+wireMockPort+"/notificationUrl"); } } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java index 6123415b41..3910d9ec44 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java @@ -88,7 +88,7 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils { request.setSkipAAI(true); request.setFailIfExists(false); MsoRequest msoReq = new MsoRequest(); - NetworkTechnology networkTechnology = NetworkTechnology.CONTRAIL; + String networkTechnology = "CONTRAIL"; msoReq.setRequestId(MSO_REQUEST_ID); msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID); @@ -296,6 +296,33 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils { assertThat(response.getBody(), sameBeanAs(expectedResponse)); } + @Test + public void testCreateNetworkNC_Shared_JSON() throws JSONException, JsonParseException, JsonMappingException, IOException { + + mockOpenStackResponseAccess(wireMockPort); + + mockOpenStackPostPublicUrlWithBodyFile_200(); + + mockOpenStackGetStackCreatedAppC_200(); + + mockOpenStackGetStackAppC_404(); + + headers.add("Content-Type", MediaType.APPLICATION_JSON); + headers.add("Accept", MediaType.APPLICATION_JSON); + + String request = readJsonFileAsString("src/test/resources/CreateNetwork4.json"); + HttpEntity<String> entity = new HttpEntity<String>(request, headers); + + ResponseEntity<CreateNetworkResponse> response = restTemplate.exchange( + createURLWithPort("/services/rest/v1/networks"), HttpMethod.POST, entity, CreateNetworkResponse.class); + + CreateNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( + new File("src/test/resources/__files/CreateNetworkResponse4.json"), CreateNetworkResponse.class); + + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + assertThat(response.getBody(), sameBeanAs(expectedResponse)); + } + @Override protected String readJsonFileAsString(String fileLocation) throws JsonParseException, JsonMappingException, IOException{ return new String(Files.readAllBytes(Paths.get(fileLocation))); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/MsoTenantAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/MsoTenantAdapterImplTest.java index 8a55177f1e..df7e415724 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/MsoTenantAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/MsoTenantAdapterImplTest.java @@ -28,7 +28,7 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.adapters.tenantrest.TenantRollback; import org.onap.so.cloud.CloudConfig; import org.onap.so.entity.MsoRequest; diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java index 9ead28b577..017aa26758 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java @@ -37,7 +37,7 @@ import org.onap.so.db.catalog.beans.ServerType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.embedded.LocalServerPort; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; @@ -61,7 +61,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; @SpringBootTest(classes = MsoOpenstackAdaptersApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") @AutoConfigureWireMock(port = 0) -public class BaseRestTestUtils { +public abstract class BaseRestTestUtils { @Value("${wiremock.server.port}") protected int wireMockPort; @Autowired diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BpelRestClientTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BpelRestClientTest.java index 1038299190..20a3e62ade 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BpelRestClientTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BpelRestClientTest.java @@ -27,7 +27,7 @@ import javax.inject.Provider; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.context.embedded.LocalServerPort; +import org.springframework.boot.web.server.LocalServerPort; public class BpelRestClientTest extends BaseRestTestUtils{ diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java index d0425371bb..4f1c2c8707 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java @@ -43,7 +43,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static com.github.tomakehurst.wiremock.client.WireMock.verify; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess; diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java index 20c2231032..1fd3ffc90a 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java @@ -32,7 +32,7 @@ import org.onap.so.cloud.CloudConfig; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.entity.MsoRequest; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.embedded.LocalServerPort; +import org.springframework.boot.web.server.LocalServerPort; import javax.xml.ws.Holder; import java.util.HashMap; diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/QueryTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/QueryTest.java index d6cdbdfccd..2740e254e1 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/QueryTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/QueryTest.java @@ -37,7 +37,7 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.adapters.vnf.exceptions.VnfException; import org.onap.so.openstack.beans.HeatStatus; import org.onap.so.openstack.beans.StackInfo; |