use of org.wso2.carbon.apimgt.gateway.utils.EndpointAdminServiceProxy in project carbon-apimgt by wso2.
the class APIGatewayAdminTest method getSequenceForTenant.
@Test
public void getSequenceForTenant() throws Exception {
RESTAPIAdminServiceProxy restapiAdminServiceProxy = Mockito.mock(RESTAPIAdminServiceProxy.class);
EndpointAdminServiceProxy endpointAdminServiceProxy = Mockito.mock(EndpointAdminServiceProxy.class);
SequenceAdminServiceProxy sequenceAdminServiceProxy = Mockito.mock(SequenceAdminServiceProxy.class);
OMFactory fac = OMAbstractFactory.getOMFactory();
OMElement test1 = fac.createOMElement("test1", "", "");
Mockito.when(sequenceAdminServiceProxy.getSequence(name)).thenReturn(test1);
APIGatewayAdmin apiGatewayAdmin = new APIGatewayAdminWrapper(restapiAdminServiceProxy, endpointAdminServiceProxy, sequenceAdminServiceProxy);
Assert.assertEquals(apiGatewayAdmin.getSequence(name), test1);
}
use of org.wso2.carbon.apimgt.gateway.utils.EndpointAdminServiceProxy in project carbon-apimgt by wso2.
the class APIGatewayAdminTest method isExistingSequence.
@Test
public void isExistingSequence() 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.isExistingSequence(name), true);
}
use of org.wso2.carbon.apimgt.gateway.utils.EndpointAdminServiceProxy in project carbon-apimgt by wso2.
the class GatewayUtils method retrieveDeployedEndpoints.
public static List<String> retrieveDeployedEndpoints(String apiName, String version, String tenantDomain) throws APIManagementException {
List<String> deployedEndpoints = new ArrayList<>();
try {
MessageContext.setCurrentMessageContext(createAxis2MessageContext());
EndpointAdminServiceProxy endpointAdminServiceProxy = new EndpointAdminServiceProxy(tenantDomain);
String productionEndpointKey = apiName.concat("--v").concat(version).concat("_APIproductionEndpoint");
String sandboxEndpointKey = apiName.concat("--v").concat(version).concat("_APIsandboxEndpoint");
if (endpointAdminServiceProxy.isEndpointExist(productionEndpointKey)) {
String entry = endpointAdminServiceProxy.getEndpoint(productionEndpointKey);
deployedEndpoints.add(entry);
}
if (endpointAdminServiceProxy.isEndpointExist(sandboxEndpointKey)) {
String entry = endpointAdminServiceProxy.getEndpoint(sandboxEndpointKey);
deployedEndpoints.add(entry);
}
} catch (AxisFault e) {
throw new APIManagementException("Error in fetching deployed endpoints from Synapse Configuration", e, ExceptionCodes.INTERNAL_ERROR);
} finally {
MessageContext.destroyCurrentMessageContext();
}
return deployedEndpoints;
}
use of org.wso2.carbon.apimgt.gateway.utils.EndpointAdminServiceProxy 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");
}
}
use of org.wso2.carbon.apimgt.gateway.utils.EndpointAdminServiceProxy 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");
}
}
Aggregations