Search in sources :

Example 16 with SequenceAdminServiceProxy

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);
}
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)

Example 17 with SequenceAdminServiceProxy

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();
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) ArrayList(java.util.ArrayList) OMElement(org.apache.axiom.om.OMElement)

Example 18 with SequenceAdminServiceProxy

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");
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) SequenceAdmin(org.wso2.carbon.sequences.services.SequenceAdmin) Test(org.junit.Test)

Example 19 with SequenceAdminServiceProxy

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");
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) SequenceAdmin(org.wso2.carbon.sequences.services.SequenceAdmin) Test(org.junit.Test)

Example 20 with SequenceAdminServiceProxy

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");
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) SequenceAdmin(org.wso2.carbon.sequences.services.SequenceAdmin) Test(org.junit.Test)

Aggregations

SequenceAdminServiceProxy (org.wso2.carbon.apimgt.gateway.utils.SequenceAdminServiceProxy)14 Test (org.junit.Test)12 EndpointAdminServiceProxy (org.wso2.carbon.apimgt.gateway.utils.EndpointAdminServiceProxy)10 RESTAPIAdminServiceProxy (org.wso2.carbon.apimgt.gateway.utils.RESTAPIAdminServiceProxy)10 OMElement (org.apache.axiom.om.OMElement)8 AxisFault (org.apache.axis2.AxisFault)7 SequenceAdmin (org.wso2.carbon.sequences.services.SequenceAdmin)4 XMLStreamException (javax.xml.stream.XMLStreamException)3 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)3 OMFactory (org.apache.axiom.om.OMFactory)2 LocalEntryServiceProxy (org.wso2.carbon.apimgt.gateway.utils.LocalEntryServiceProxy)2 MediationSecurityAdminServiceProxy (org.wso2.carbon.apimgt.gateway.utils.MediationSecurityAdminServiceProxy)2 CertificateManager (org.wso2.carbon.apimgt.impl.certificatemgt.CertificateManager)2 ArrayList (java.util.ArrayList)1 CredentialDto (org.wso2.carbon.apimgt.api.gateway.CredentialDto)1 GatewayContentDTO (org.wso2.carbon.apimgt.api.gateway.GatewayContentDTO)1