Search in sources :

Example 36 with StackInfo

use of org.onap.so.openstack.beans.StackInfo in project so by onap.

the class MsoHeatUtilsWithUpdateTest method updateStackWithFilesTest.

@Test
public void updateStackWithFilesTest() throws MsoException, JsonParseException, JsonMappingException, IOException {
    String environmentString = "environmentString";
    Map<String, Object> files = new HashMap<>();
    files.put("file1", new Object());
    CloudSite cloudSite = new CloudSite();
    Heat heatClient = new Heat("endpoint");
    Stack heatStack = mapper.readValue(new File(RESOURCE_PATH + "HeatStack.json"), Stack.class);
    Stack updateStack = mapper.readValue(new File(RESOURCE_PATH + "UpdateStack.json"), Stack.class);
    StackInfo expectedStackInfo = new StackInfo("stackName", HeatStatus.UPDATED, "stackStatusReason", null);
    expectedStackInfo.setCanonicalName("stackName/id");
    doReturn(heatClient).when(heatUtils).getHeatClient(isA(String.class), isA(String.class));
    doReturn(null).when(heatUtils).executeAndRecordOpenstackRequest(isA(OpenStackRequest.class));
    doReturn("0").when(environment).getProperty(isA(String.class), isA(String.class));
    doReturn(updateStack).when(heatUtils).queryHeatStack(isA(Heat.class), isA(String.class));
    StackInfo actualStackInfo = heatUtils.updateStack(cloudSiteId, cloudOwner, tenantId, stackName, heatTemplate, stackInputs, pollForCompletion, timeoutMinutes, environmentString, files);
    assertThat(actualStackInfo, sameBeanAs(expectedStackInfo));
}
Also used : Heat(com.woorea.openstack.heat.Heat) HashMap(java.util.HashMap) CloudSite(org.onap.so.db.catalog.beans.CloudSite) OpenStackRequest(com.woorea.openstack.base.client.OpenStackRequest) File(java.io.File) StackInfo(org.onap.so.openstack.beans.StackInfo) Stack(com.woorea.openstack.heat.model.Stack) Test(org.junit.Test)

Example 37 with StackInfo

use of org.onap.so.openstack.beans.StackInfo in project so by onap.

the class MsoHeatUtilsWithUpdateTest method updateStackTest.

@Test
public void updateStackTest() throws MsoException, JsonParseException, JsonMappingException, IOException {
    CloudSite cloudSite = new CloudSite();
    Heat heatClient = new Heat("endpoint");
    Stack heatStack = mapper.readValue(new File(RESOURCE_PATH + "HeatStack.json"), Stack.class);
    Stack updateStack = mapper.readValue(new File(RESOURCE_PATH + "UpdateStack.json"), Stack.class);
    StackInfo expectedStackInfo = new StackInfo("stackName", HeatStatus.UPDATED, "stackStatusReason", null);
    expectedStackInfo.setCanonicalName("stackName/id");
    doReturn(heatClient).when(heatUtils).getHeatClient(isA(String.class), isA(String.class));
    doReturn(null).when(heatUtils).executeAndRecordOpenstackRequest(isA(OpenStackRequest.class));
    doReturn("0").when(environment).getProperty(isA(String.class), isA(String.class));
    doReturn(updateStack).when(heatUtils).queryHeatStack(isA(Heat.class), isA(String.class));
    StackInfo actualStackInfo = heatUtils.updateStack(cloudSiteId, cloudOwner, tenantId, stackName, heatTemplate, stackInputs, pollForCompletion, timeoutMinutes);
    assertThat(actualStackInfo, sameBeanAs(expectedStackInfo));
}
Also used : Heat(com.woorea.openstack.heat.Heat) CloudSite(org.onap.so.db.catalog.beans.CloudSite) OpenStackRequest(com.woorea.openstack.base.client.OpenStackRequest) File(java.io.File) StackInfo(org.onap.so.openstack.beans.StackInfo) Stack(com.woorea.openstack.heat.model.Stack) Test(org.junit.Test)

Example 38 with StackInfo

use of org.onap.so.openstack.beans.StackInfo in project so by onap.

the class MsoMulticloudUtilsTest method queryStackWithNullMulticloudQueryBody.

@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)));
    StackInfo result = multicloudUtils.queryStack("MTN13", "CloudOwner", "TEST-tenant", "instanceName/instanceId");
    assertTrue(HeatStatus.FAILED == result.getStatus());
    assertEquals(MULTICLOUD_QUERY_BODY_NULL, result.getStatusMessage());
}
Also used : StackInfo(org.onap.so.openstack.beans.StackInfo) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

Aggregations

StackInfo (org.onap.so.openstack.beans.StackInfo)38 MsoException (org.onap.so.openstack.exceptions.MsoException)17 HashMap (java.util.HashMap)11 Test (org.junit.Test)11 Stack (com.woorea.openstack.heat.model.Stack)9 CloudSite (org.onap.so.db.catalog.beans.CloudSite)8 MsoOpenstackException (org.onap.so.openstack.exceptions.MsoOpenstackException)8 VduException (org.onap.so.adapters.vdu.VduException)7 BaseTest (org.onap.so.BaseTest)6 MsoAdapterException (org.onap.so.openstack.exceptions.MsoAdapterException)6 Heat (com.woorea.openstack.heat.Heat)4 MalformedURLException (java.net.MalformedURLException)4 Response (javax.ws.rs.core.Response)4 UriBuilderException (javax.ws.rs.core.UriBuilderException)4 RestClient (org.onap.so.client.RestClient)4 HeatTemplate (org.onap.so.db.catalog.beans.HeatTemplate)4 StackInfoMapper (org.onap.so.openstack.mappers.StackInfoMapper)4 OpenStackConnectException (com.woorea.openstack.base.client.OpenStackConnectException)3 OpenStackRequest (com.woorea.openstack.base.client.OpenStackRequest)3 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)3