use of org.wso2.carbon.apimgt.gateway.utils.SequenceAdminServiceProxy 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.SequenceAdminServiceProxy in project carbon-apimgt by wso2.
the class GatewayUtils method retrieveDeployedSequences.
public static List<String> retrieveDeployedSequences(String apiName, String version, String tenantDomain) throws APIManagementException {
try {
List<String> deployedSequences = new ArrayList<>();
String inSequenceExtensionName = APIUtil.getSequenceExtensionName(apiName, version) + APIConstants.API_CUSTOM_SEQ_IN_EXT;
String outSequenceExtensionName = APIUtil.getSequenceExtensionName(apiName, version) + APIConstants.API_CUSTOM_SEQ_OUT_EXT;
String faultSequenceExtensionName = APIUtil.getSequenceExtensionName(apiName, version) + APIConstants.API_CUSTOM_SEQ_FAULT_EXT;
SequenceAdminServiceProxy sequenceAdminServiceProxy = new SequenceAdminServiceProxy(tenantDomain);
MessageContext.setCurrentMessageContext(createAxis2MessageContext());
if (sequenceAdminServiceProxy.isExistingSequence(inSequenceExtensionName)) {
OMElement sequence = sequenceAdminServiceProxy.getSequence(inSequenceExtensionName);
deployedSequences.add(sequence.toString());
}
if (sequenceAdminServiceProxy.isExistingSequence(outSequenceExtensionName)) {
OMElement sequence = sequenceAdminServiceProxy.getSequence(outSequenceExtensionName);
deployedSequences.add(sequence.toString());
}
if (sequenceAdminServiceProxy.isExistingSequence(faultSequenceExtensionName)) {
OMElement sequence = sequenceAdminServiceProxy.getSequence(faultSequenceExtensionName);
deployedSequences.add(sequence.toString());
}
return deployedSequences;
} catch (AxisFault axisFault) {
throw new APIManagementException("Error while retrieving Deployed Sequences", axisFault, ExceptionCodes.INTERNAL_ERROR);
} finally {
MessageContext.destroyCurrentMessageContext();
}
}
use of org.wso2.carbon.apimgt.gateway.utils.SequenceAdminServiceProxy in project carbon-apimgt by wso2.
the class SequenceAdminServiceProxyTestCase method testIsExsistingSequence.
@Test
public void testIsExsistingSequence() {
SequenceAdminServiceProxy sequenceAdminServiceProxy = null;
try {
sequenceAdminServiceProxy = new SequenceAdminServiceProxy("abc.com");
SequenceAdmin sequenceAdmin = Mockito.mock(SequenceAdmin.class);
Mockito.when(sequenceAdmin.isExistingSequence("xyz")).thenReturn(true);
Mockito.when(sequenceAdmin.isExistingSequenceForTenant("xyz", "abc.com")).thenReturn(true);
sequenceAdminServiceProxy.setSequenceAdmin(sequenceAdmin);
} catch (Exception axisFault) {
// test for axisFault
}
try {
Assert.assertTrue(sequenceAdminServiceProxy.isExistingSequence("xyz"));
} catch (AxisFault axisFault) {
fail("AxisFault while testing getSequence");
}
try {
Assert.assertTrue(sequenceAdminServiceProxy.isExistingSequence("xyz"));
} catch (AxisFault axisFault) {
fail("AxisFault while testing getSequenceForTenant");
}
}
use of org.wso2.carbon.apimgt.gateway.utils.SequenceAdminServiceProxy in project carbon-apimgt by wso2.
the class SequenceAdminServiceProxyTestCase method testDeleteSequence.
@Test
public void testDeleteSequence() {
SequenceAdminServiceProxy sequenceAdminServiceProxy = null;
try {
sequenceAdminServiceProxy = new SequenceAdminServiceProxy("abc.com");
SequenceAdmin sequenceAdmin = Mockito.mock(SequenceAdmin.class);
Mockito.doNothing().when(sequenceAdmin).deleteSequence("xyz");
sequenceAdminServiceProxy.setSequenceAdmin(sequenceAdmin);
} catch (Exception e) {
fail("Exception while testing deleteSequence");
}
try {
sequenceAdminServiceProxy.deleteSequence("xyz");
} catch (AxisFault axisFault) {
fail("AxisFault while testing deleteSequence");
}
try {
sequenceAdminServiceProxy.deleteSequence("xyz");
} catch (AxisFault axisFault) {
fail("AxisFault while testing deleteSequenceForTenant");
}
}
use of org.wso2.carbon.apimgt.gateway.utils.SequenceAdminServiceProxy in project carbon-apimgt by wso2.
the class SequenceAdminServiceProxyTestCase method testAddSequence.
@Test
public void testAddSequence() {
SequenceAdminServiceProxy sequenceAdminServiceProxy = null;
try {
sequenceAdminServiceProxy = new SequenceAdminServiceProxy("abc.com");
SequenceAdmin sequenceAdmin = Mockito.mock(SequenceAdmin.class);
Mockito.doNothing().when(sequenceAdmin).addSequence(omElement);
sequenceAdminServiceProxy.setSequenceAdmin(sequenceAdmin);
} catch (Exception e) {
fail("Exception while testing addSequence");
}
try {
sequenceAdminServiceProxy.addSequence(omElement);
} catch (AxisFault e) {
fail("AxisFault while testing addSequence");
}
try {
sequenceAdminServiceProxy.addSequence(omElement);
} catch (AxisFault axisFault) {
fail("AxisFault while testing addSequenceForTenant");
}
}
Aggregations