Search in sources :

Example 11 with WSDL11SOAPOperationExtractor

use of org.wso2.carbon.apimgt.impl.wsdl.WSDL11SOAPOperationExtractor in project carbon-apimgt by wso2.

the class WSDLSOAPOperationExtractorImplTestCase method testGetSwaggerModelForCompositeComplexType.

@Test
public void testGetSwaggerModelForCompositeComplexType() throws Exception {
    APIMWSDLReader wsdlReader = new APIMWSDLReader(Thread.currentThread().getContextClassLoader().getResource("wsdls/sample-service.wsdl").toExternalForm());
    byte[] wsdlContent = wsdlReader.getWSDL();
    WSDL11SOAPOperationExtractor processor = SOAPOperationBindingUtils.getWSDL11SOAPOperationExtractor(wsdlContent, wsdlReader);
    Map<String, ModelImpl> parameterModelMap = processor.getWsdlInfo().getParameterModelMap();
    Assert.assertNotNull(parameterModelMap);
    Assert.assertTrue("wsdl complex types has not been properly parsed", parameterModelMap.size() == 12);
    // composite complex type
    Assert.assertNotNull(parameterModelMap.get("ItemSearchRequest"));
    Assert.assertEquals(7, parameterModelMap.get("ItemSearchRequest").getProperties().size());
    Assert.assertNotNull(parameterModelMap.get("ItemSearchRequest").getProperties().get("Tracks"));
    Assert.assertNotNull(parameterModelMap.get("ItemSearchRequest").getProperties().get("Tracks"));
    Assert.assertEquals(ArrayProperty.TYPE, parameterModelMap.get("ItemSearchRequest").getProperties().get("Tracks").getType());
    Assert.assertNotNull(((ArrayProperty) parameterModelMap.get("ItemSearchRequest").getProperties().get("Tracks")).getItems());
}
Also used : APIMWSDLReader(org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader) ModelImpl(io.swagger.models.ModelImpl) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 12 with WSDL11SOAPOperationExtractor

use of org.wso2.carbon.apimgt.impl.wsdl.WSDL11SOAPOperationExtractor in project carbon-apimgt by wso2.

the class WSDLSOAPOperationExtractorImplTestCase method testGetSwaggerModelForImportedSchemas.

@Test
public void testGetSwaggerModelForImportedSchemas() throws Exception {
    APIMWSDLReader wsdlReader = new APIMWSDLReader(Thread.currentThread().getContextClassLoader().getResource("wsdls/import-schemas/sampleservice.wsdl").toExternalForm());
    byte[] wsdlContent = wsdlReader.getWSDL();
    WSDL11SOAPOperationExtractor processor = SOAPOperationBindingUtils.getWSDL11SOAPOperationExtractor(wsdlContent, wsdlReader);
    Set<WSDLSOAPOperation> operations = processor.getWsdlInfo().getSoapBindingOperations();
    Assert.assertNotNull(operations);
    Map<String, ModelImpl> parameterModelMap = processor.getWsdlInfo().getParameterModelMap();
    Assert.assertNotNull(parameterModelMap);
}
Also used : APIMWSDLReader(org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader) WSDLSOAPOperation(org.wso2.carbon.apimgt.impl.wsdl.model.WSDLSOAPOperation) ModelImpl(io.swagger.models.ModelImpl) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 13 with WSDL11SOAPOperationExtractor

use of org.wso2.carbon.apimgt.impl.wsdl.WSDL11SOAPOperationExtractor in project carbon-apimgt by wso2.

the class WSDLSOAPOperationExtractorImplTestCase method setup.

@Before
public void setup() throws Exception {
    APIMWSDLReader wsdlReader = new APIMWSDLReader(Thread.currentThread().getContextClassLoader().getResource("wsdls/phoneverify.wsdl").toExternalForm());
    byte[] wsdlContent = wsdlReader.getWSDL();
    WSDL11SOAPOperationExtractor processor = SOAPOperationBindingUtils.getWSDL11SOAPOperationExtractor(wsdlContent, wsdlReader);
    operations = processor.getWsdlInfo().getSoapBindingOperations();
}
Also used : APIMWSDLReader(org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader) Before(org.junit.Before)

Example 14 with WSDL11SOAPOperationExtractor

use of org.wso2.carbon.apimgt.impl.wsdl.WSDL11SOAPOperationExtractor in project carbon-apimgt by wso2.

the class APIMWSDLReader method getWSDLSOAPOperationExtractor.

/**
 * Returns a WSDL11SOAPOperationExtractor for the url {@code url}. Only WSDL 1.1 is supported.
 *
 * @param wsdlPath File path containing WSDL files and dependant files
 * @return WSDL11SOAPOperationExtractor for the provided URL
 * @throws APIManagementException If an error occurs while determining the processor
 */
public static WSDL11SOAPOperationExtractor getWSDLSOAPOperationExtractor(String wsdlPath, APIMWSDLReader wsdlReader) throws APIManagementException {
    WSDL11SOAPOperationExtractor processor = new WSDL11SOAPOperationExtractor();
    processor.loadXSDs(wsdlReader, wsdlPath);
    processor.initPath(wsdlPath);
    return processor;
}
Also used : WSDL11SOAPOperationExtractor(org.wso2.carbon.apimgt.impl.wsdl.WSDL11SOAPOperationExtractor)

Aggregations

APIMWSDLReader (org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader)8 WSDL11SOAPOperationExtractor (org.wso2.carbon.apimgt.impl.wsdl.WSDL11SOAPOperationExtractor)7 Test (org.junit.Test)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 ModelImpl (io.swagger.models.ModelImpl)4 WSDLInfo (org.wso2.carbon.apimgt.impl.wsdl.model.WSDLInfo)3 WSDLSOAPOperation (org.wso2.carbon.apimgt.impl.wsdl.model.WSDLSOAPOperation)2 URL (java.net.URL)1 Before (org.junit.Before)1