Search in sources :

Example 6 with OperationalEnvironment

use of org.onap.aai.domain.yang.OperationalEnvironment in project so by onap.

the class CreateVnfOperationalEnvironmentTest method testGetSearchKey.

@Test
public void testGetSearchKey() {
    createVnfOpEnv.setRequest(request);
    OperationalEnvironment ecompEnv = new OperationalEnvironment();
    ecompEnv.setTenantContext("Test");
    ecompEnv.setWorkloadContext("ECOMPL_PSL");
    assertEquals("Test.ECOMPL_PSL.*", createVnfOpEnv.getSearchKey(ecompEnv));
}
Also used : OperationalEnvironment(org.onap.aai.domain.yang.OperationalEnvironment) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Example 7 with OperationalEnvironment

use of org.onap.aai.domain.yang.OperationalEnvironment in project so by onap.

the class AAIClientHelperTest method testUpdateSuccess.

@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");
    }
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) OperationalEnvironment(org.onap.aai.domain.yang.OperationalEnvironment) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Example 8 with OperationalEnvironment

use of org.onap.aai.domain.yang.OperationalEnvironment in project so by onap.

the class AAIClientHelperTest method testcreateRelationshipSuccess.

@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");
    }
}
Also used : OperationalEnvironment(org.onap.aai.domain.yang.OperationalEnvironment) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Example 9 with OperationalEnvironment

use of org.onap.aai.domain.yang.OperationalEnvironment in project so by onap.

the class AAIClientHelperTest method testGetAaiOperationalEnvironmentSuccess.

@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());
}
Also used : AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) OperationalEnvironment(org.onap.aai.domain.yang.OperationalEnvironment) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Example 10 with OperationalEnvironment

use of org.onap.aai.domain.yang.OperationalEnvironment in project so by onap.

the class AAIClientHelperTest method testCreateSuccess.

@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");
    }
}
Also used : OperationalEnvironment(org.onap.aai.domain.yang.OperationalEnvironment) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Aggregations

OperationalEnvironment (org.onap.aai.domain.yang.OperationalEnvironment)13 Test (org.junit.Test)6 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)6 BaseTest (org.onap.so.apihandlerinfra.BaseTest)6 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)3 ErrorLoggerInfo (org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo)3 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 NotFoundException (javax.ws.rs.NotFoundException)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)1 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)1 AAIFluentTypeBuilder (org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder)1 TenantIsolationException (org.onap.so.apihandlerinfra.tenantisolation.exceptions.TenantIsolationException)1 AAIClientObjectBuilder (org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientObjectBuilder)1 Distribution (org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution)1 ServiceModelList (org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList)1 ServiceEndPoint (org.onap.so.client.grm.beans.ServiceEndPoint)1 ServiceEndPointList (org.onap.so.client.grm.beans.ServiceEndPointList)1 ServiceEndPointRequest (org.onap.so.client.grm.beans.ServiceEndPointRequest)1