Search in sources :

Example 16 with APIGatewayAdmin

use of org.wso2.carbon.apimgt.gateway.service.APIGatewayAdmin in project carbon-apimgt by wso2.

the class APIGatewayAdminTest method getApi.

@Test
public void getApi() throws Exception {
    APIData apiData = new APIData();
    apiData.setContext("/abc");
    apiData.setName(name);
    apiData.setFileName(name);
    ResourceData resourceData = new ResourceData();
    resourceData.setMethods(new String[] { "get" });
    resourceData.setContentType("application/json");
    resourceData.setUriTemplate("/*");
    apiData.setResources(new ResourceData[] { resourceData });
    RESTAPIAdminServiceProxy restapiAdminServiceProxy = Mockito.mock(RESTAPIAdminServiceProxy.class);
    Mockito.when(restapiAdminServiceProxy.getApi(apiName)).thenReturn(apiData);
    APIGatewayAdmin apiGatewayAdmin = new APIGatewayAdminWrapper(restapiAdminServiceProxy, null, null);
    Assert.assertNotNull(apiGatewayAdmin.getApi(name, version));
}
Also used : RESTAPIAdminServiceProxy(org.wso2.carbon.apimgt.gateway.utils.RESTAPIAdminServiceProxy) ResourceData(org.wso2.carbon.rest.api.ResourceData) APIData(org.wso2.carbon.rest.api.APIData) Test(org.junit.Test)

Example 17 with APIGatewayAdmin

use of org.wso2.carbon.apimgt.gateway.service.APIGatewayAdmin in project carbon-apimgt by wso2.

the class APIGatewayAdminTest method addEndpointForTenant.

@Test
public void addEndpointForTenant() throws Exception {
    String endpointData = "<endpoint></endpoint>";
    EndpointAdminServiceProxy endpointAdminServiceProxy = Mockito.mock(EndpointAdminServiceProxy.class);
    Mockito.when(endpointAdminServiceProxy.addEndpoint(Mockito.anyString())).thenReturn(true);
    APIGatewayAdmin apiGatewayAdmin = new APIGatewayAdminWrapper(null, endpointAdminServiceProxy, null);
    Assert.assertTrue(apiGatewayAdmin.addEndpoint(endpointData));
}
Also used : EndpointAdminServiceProxy(org.wso2.carbon.apimgt.gateway.utils.EndpointAdminServiceProxy) Test(org.junit.Test)

Example 18 with APIGatewayAdmin

use of org.wso2.carbon.apimgt.gateway.service.APIGatewayAdmin in project carbon-apimgt by wso2.

the class APIGatewayAdminTest method deleteEndpoint.

@Test
public void deleteEndpoint() throws Exception {
    String endpointName = "PizzaShackAPI--v1.0.0_APIproductionEndpoint";
    EndpointAdminServiceProxy endpointAdminServiceProxy = Mockito.mock(EndpointAdminServiceProxy.class);
    Mockito.when(endpointAdminServiceProxy.deleteEndpoint(Mockito.anyString())).thenReturn(true);
    APIGatewayAdmin apiGatewayAdmin = new APIGatewayAdminWrapper(null, endpointAdminServiceProxy, null);
    Assert.assertTrue(apiGatewayAdmin.deleteEndpoint(endpointName));
}
Also used : EndpointAdminServiceProxy(org.wso2.carbon.apimgt.gateway.utils.EndpointAdminServiceProxy) Test(org.junit.Test)

Example 19 with APIGatewayAdmin

use of org.wso2.carbon.apimgt.gateway.service.APIGatewayAdmin in project carbon-apimgt by wso2.

the class APIGatewayAdminTest method addEndpoint.

@Test
public void addEndpoint() throws Exception {
    String endpointData = "<endpoint></endpoint>";
    EndpointAdminServiceProxy endpointAdminServiceProxy = Mockito.mock(EndpointAdminServiceProxy.class);
    Mockito.when(endpointAdminServiceProxy.addEndpoint(Mockito.anyString())).thenReturn(true);
    APIGatewayAdmin apiGatewayAdmin = new APIGatewayAdminWrapper(null, endpointAdminServiceProxy, null);
    Assert.assertTrue(apiGatewayAdmin.addEndpoint(endpointData));
}
Also used : EndpointAdminServiceProxy(org.wso2.carbon.apimgt.gateway.utils.EndpointAdminServiceProxy) Test(org.junit.Test)

Example 20 with APIGatewayAdmin

use of org.wso2.carbon.apimgt.gateway.service.APIGatewayAdmin in project carbon-apimgt by wso2.

the class APIGatewayAdminTest method isExistingSequenceForTenant.

@Test
public void isExistingSequenceForTenant() throws Exception {
    RESTAPIAdminServiceProxy restapiAdminServiceProxy = Mockito.mock(RESTAPIAdminServiceProxy.class);
    EndpointAdminServiceProxy endpointAdminServiceProxy = Mockito.mock(EndpointAdminServiceProxy.class);
    SequenceAdminServiceProxy sequenceAdminServiceProxy = Mockito.mock(SequenceAdminServiceProxy.class);
    Mockito.when(sequenceAdminServiceProxy.isExistingSequence(name)).thenReturn(true);
    APIGatewayAdmin apiGatewayAdmin = new APIGatewayAdminWrapper(restapiAdminServiceProxy, endpointAdminServiceProxy, sequenceAdminServiceProxy);
    Assert.assertEquals(apiGatewayAdmin.isExistingSequenceForTenant(name, tenantDomain), true);
}
Also used : RESTAPIAdminServiceProxy(org.wso2.carbon.apimgt.gateway.utils.RESTAPIAdminServiceProxy) EndpointAdminServiceProxy(org.wso2.carbon.apimgt.gateway.utils.EndpointAdminServiceProxy) SequenceAdminServiceProxy(org.wso2.carbon.apimgt.gateway.utils.SequenceAdminServiceProxy) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)32 RESTAPIAdminServiceProxy (org.wso2.carbon.apimgt.gateway.utils.RESTAPIAdminServiceProxy)28 EndpointAdminServiceProxy (org.wso2.carbon.apimgt.gateway.utils.EndpointAdminServiceProxy)12 SequenceAdminServiceProxy (org.wso2.carbon.apimgt.gateway.utils.SequenceAdminServiceProxy)8 APIData (org.wso2.carbon.rest.api.APIData)4 OMElement (org.apache.axiom.om.OMElement)3 GatewayAPIDTO (org.wso2.carbon.apimgt.api.gateway.GatewayAPIDTO)3 APIGatewayAdmin (org.wso2.carbon.apimgt.gateway.service.APIGatewayAdmin)3 ArtifactSynchronizerException (org.wso2.carbon.apimgt.impl.gatewayartifactsynchronizer.exception.ArtifactSynchronizerException)3 OMFactory (org.apache.axiom.om.OMFactory)2 AxisFault (org.apache.axis2.AxisFault)2 Gson (com.google.gson.Gson)1 IOException (java.io.IOException)1 API (org.wso2.carbon.apimgt.api.model.API)1 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)1 APIProductIdentifier (org.wso2.carbon.apimgt.api.model.APIProductIdentifier)1 APIEvent (org.wso2.carbon.apimgt.impl.notifier.events.APIEvent)1 ResourceData (org.wso2.carbon.rest.api.ResourceData)1