Search in sources :

Example 1 with EndpointAdmin

use of org.wso2.carbon.endpoint.service.EndpointAdmin in project carbon-apimgt by wso2.

the class EndpointAdminServiceProxyTestCase method testRemoveEndpointsToUpdate.

@Test
public void testRemoveEndpointsToUpdate() throws Exception {
    EndpointAdminServiceProxy endpointAdminServiceProxy = null;
    APIIdentifier identifier = null;
    API api = null;
    try {
        endpointAdminServiceProxy = new EndpointAdminServiceProxy(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
        EndpointAdmin endpointAdmin = Mockito.mock(EndpointAdmin.class);
        String[] endpointNames = { "API1--v1.0.0_APIproductionEndpoint", "API1--v1.0.0_APIsandboxEndpoint" };
        identifier = new APIIdentifier("P1_API1_1.0.0");
        api = new API(identifier);
        Mockito.when(endpointAdmin.getEndPointsNames()).thenReturn(endpointNames);
        Mockito.when(endpointAdmin.getEndPointsNamesForTenant(Mockito.anyString())).thenReturn(endpointNames);
        Mockito.when(endpointAdmin.deleteEndpoint(Mockito.anyString())).thenReturn(true);
        Mockito.when(endpointAdmin.deleteEndpointForTenant(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
        endpointAdminServiceProxy.setEndpointAdmin(endpointAdmin);
    } catch (Exception e) {
        Assert.fail("Exception while testing removeEndpointsToUpdate");
    }
    try {
        endpointAdminServiceProxy.removeEndpointsToUpdate(api.getId().getApiName(), api.getId().getVersion());
        endpointAdminServiceProxy.removeEndpointsToUpdate(api.getId().getApiName(), api.getId().getVersion());
        endpointAdminServiceProxy.removeEndpointsToUpdate(api.getId().getApiName(), api.getId().getVersion());
    } catch (AxisFault e) {
        Assert.fail("AxisFault while testing removeEndpointsToUpdate");
    }
    try {
        endpointAdminServiceProxy.removeEndpointsToUpdate(api.getId().getApiName(), api.getId().getVersion());
    } catch (AxisFault e) {
        Assert.fail("AxisFault while testing removeEndpointsToUpdate for tenant");
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) APIIdentifier(org.wso2.carbon.apimgt.api.model.APIIdentifier) API(org.wso2.carbon.apimgt.api.model.API) EndpointAdmin(org.wso2.carbon.endpoint.service.EndpointAdmin) Test(org.junit.Test)

Example 2 with EndpointAdmin

use of org.wso2.carbon.endpoint.service.EndpointAdmin in project carbon-apimgt by wso2.

the class EndpointAdminServiceProxyTestCase method testCheckEndpointExistBeforeDelete.

@Test
public void testCheckEndpointExistBeforeDelete() {
    EndpointAdminServiceProxy endpointAdminServiceProxy = null;
    String endpointName = "PizzaShackAPI--v1.0.0_APIproductionEndpoint";
    String[] endpointArray = { "PizzaShackAPI--v1.0.0_APIproductionEndpoint", "PizzaShackAPI--v1.0.0_APIsandboxEndpoint" };
    String tenantDomain = "wso2.com";
    try {
        endpointAdminServiceProxy = new EndpointAdminServiceProxy(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
        EndpointAdmin endpointAdmin = Mockito.mock(EndpointAdmin.class);
        Mockito.when(endpointAdmin.deleteEndpoint(endpointName)).thenReturn(true);
        Mockito.when(endpointAdmin.deleteEndpointForTenant(endpointName, tenantDomain)).thenReturn(true);
        Mockito.when(endpointAdmin.getEndPointsNames()).thenReturn(endpointArray);
        Mockito.when(endpointAdmin.getEndPointsNamesForTenant(tenantDomain)).thenReturn(endpointArray);
        endpointAdminServiceProxy.setEndpointAdmin(endpointAdmin);
    } catch (Exception e) {
        Assert.fail("Exception while testing CheckEndpointExistBeforeDelete");
    }
}
Also used : EndpointAdmin(org.wso2.carbon.endpoint.service.EndpointAdmin) Test(org.junit.Test)

Example 3 with EndpointAdmin

use of org.wso2.carbon.endpoint.service.EndpointAdmin in project carbon-apimgt by wso2.

the class EndpointAdminServiceProxyTestCase method testAddEndpoint.

@Test
public void testAddEndpoint() {
    EndpointAdminServiceProxy endpointAdminServiceProxy = null;
    try {
        endpointAdminServiceProxy = new EndpointAdminServiceProxy(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
        EndpointAdmin endpointAdmin = Mockito.mock(EndpointAdmin.class);
        Mockito.when(endpointAdmin.addEndpoint(Mockito.anyString())).thenReturn(true);
        endpointAdminServiceProxy.setEndpointAdmin(endpointAdmin);
    } catch (Exception e) {
        Assert.fail("Exception while testing addEndpoint");
    }
    try {
        endpointAdminServiceProxy.addEndpoint(Mockito.anyString());
    } catch (AxisFault e) {
        Assert.fail("AxisFault while testing addEndpoint");
    }
    try {
        endpointAdminServiceProxy.addEndpoint(Mockito.anyString());
    } catch (AxisFault e) {
        Assert.fail("AxisFault while testing addEndpoint");
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) EndpointAdmin(org.wso2.carbon.endpoint.service.EndpointAdmin) Test(org.junit.Test)

Example 4 with EndpointAdmin

use of org.wso2.carbon.endpoint.service.EndpointAdmin in project carbon-apimgt by wso2.

the class EndpointAdminServiceProxyTestCase method testDeleteEndpoint.

@Test
public void testDeleteEndpoint() {
    EndpointAdminServiceProxy endpointAdminServiceProxy = null;
    try {
        endpointAdminServiceProxy = new EndpointAdminServiceProxy(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
        EndpointAdmin endpointAdmin = Mockito.mock(EndpointAdmin.class);
        Mockito.when(endpointAdmin.deleteEndpoint(Mockito.anyString())).thenReturn(true);
        Mockito.when(endpointAdmin.getEndPointsNames()).thenReturn(null);
        Mockito.when(endpointAdmin.getEndPointsNamesForTenant(Mockito.anyString())).thenReturn(null);
        endpointAdminServiceProxy.setEndpointAdmin(endpointAdmin);
    } catch (Exception e) {
        Assert.fail("Exception while testing deleteEndpoint");
    }
    try {
        endpointAdminServiceProxy.deleteEndpoint("PizzaShackAPI--v1.0.0_APIproductionEndpoint");
    } catch (AxisFault e) {
        Assert.fail("AxisFault while testing deleteEndpoint");
    }
    try {
        endpointAdminServiceProxy.deleteEndpoint("PizzaShackAPI--v1.0.0_APIproductionEndpoint");
    } catch (AxisFault e) {
        Assert.fail("AxisFault while testing deleteEndpoint");
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) EndpointAdmin(org.wso2.carbon.endpoint.service.EndpointAdmin) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 EndpointAdmin (org.wso2.carbon.endpoint.service.EndpointAdmin)4 AxisFault (org.apache.axis2.AxisFault)3 API (org.wso2.carbon.apimgt.api.model.API)1 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)1