use of org.wso2.ballerinalang.compiler.semantics.analyzer.Types 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());
}
use of org.wso2.ballerinalang.compiler.semantics.analyzer.Types in project carbon-apimgt by wso2.
the class FaultyRequestDataCollector method collectData.
public void collectData() throws AnalyticsException {
log.debug("Handling faulty analytics types");
Event faultyEvent = getFaultyEvent();
switch(provider.getFaultType()) {
case AUTH:
authDataCollector.collectFaultData(faultyEvent);
break;
case THROTTLED:
throttledDataCollector.collectFaultData(faultyEvent);
break;
case TARGET_CONNECTIVITY:
targetDataCollector.collectFaultData(faultyEvent);
break;
case OTHER:
unclassifiedFaultDataCollector.collectFaultData(faultyEvent);
break;
}
}
use of org.wso2.ballerinalang.compiler.semantics.analyzer.Types in project carbon-apimgt by wso2.
the class SuccessRequestDataCollector method collectData.
public void collectData() throws AnalyticsException {
log.debug("Handling success analytics types");
long requestInTime = provider.getRequestTime();
String offsetDateTime = getTimeInISO(requestInTime);
Event event = new Event();
API api = provider.getApi();
Operation operation = provider.getOperation();
Target target = provider.getTarget();
Application application;
if (provider.isAnonymous()) {
application = getAnonymousApp();
} else {
application = provider.getApplication();
}
Latencies latencies = provider.getLatencies();
MetaInfo metaInfo = provider.getMetaInfo();
String userAgent = provider.getUserAgentHeader();
String userIp = provider.getEndUserIP();
if (userIp == null) {
userIp = Constants.UNKNOWN_VALUE;
}
event.setApi(api);
event.setOperation(operation);
event.setTarget(target);
event.setApplication(application);
event.setLatencies(latencies);
event.setProxyResponseCode(provider.getProxyResponseCode());
event.setRequestTimestamp(offsetDateTime);
event.setMetaInfo(metaInfo);
event.setUserAgentHeader(userAgent);
event.setUserIp(userIp);
this.processor.publish(event);
}
use of org.wso2.ballerinalang.compiler.semantics.analyzer.Types in project carbon-apimgt by wso2.
the class APIUtil method getTokenEndpointsByType.
public static String getTokenEndpointsByType(String type, String organization) throws APIManagementException {
Map<String, Environment> environments = getEnvironments(organization);
Map<String, String> map = new HashMap<>();
String productionUrl = "";
String sandboxUrl = "";
String hybridUrl = "";
// Set URL for a given default env
for (Environment environment : environments.values()) {
String environmentUrl = getHttpsEnvironmentUrl(environment);
String environmentType = environment.getType();
boolean isDefault = environment.isDefault();
if (APIConstants.GATEWAY_ENV_TYPE_HYBRID.equals(environmentType)) {
if (isDefault) {
map.put(APIConstants.GATEWAY_ENV_TYPE_HYBRID, environmentUrl);
} else {
hybridUrl = environmentUrl;
}
} else if (APIConstants.GATEWAY_ENV_TYPE_PRODUCTION.equals(environmentType)) {
if (isDefault) {
map.put(APIConstants.GATEWAY_ENV_TYPE_PRODUCTION, environmentUrl);
} else {
productionUrl = environmentUrl;
}
} else if (APIConstants.GATEWAY_ENV_TYPE_SANDBOX.equals(environmentType)) {
if (isDefault) {
map.put(APIConstants.GATEWAY_ENV_TYPE_SANDBOX, environmentUrl);
} else {
sandboxUrl = environmentUrl;
}
} else {
log.warn("Invalid gateway environment type : " + environmentType + " has been configured in api-manager.xml");
}
}
// If no default envs are specified, set URL from each of the configured env types at random
if (map.isEmpty()) {
if (StringUtils.isNotEmpty(productionUrl)) {
map.put(APIConstants.GATEWAY_ENV_TYPE_PRODUCTION, productionUrl);
}
if (StringUtils.isNotEmpty(sandboxUrl)) {
map.put(APIConstants.GATEWAY_ENV_TYPE_SANDBOX, sandboxUrl);
}
if (StringUtils.isNotEmpty(hybridUrl)) {
map.put(APIConstants.GATEWAY_ENV_TYPE_HYBRID, hybridUrl);
}
}
if (map.containsKey(APIConstants.GATEWAY_ENV_TYPE_HYBRID)) {
return map.get(APIConstants.GATEWAY_ENV_TYPE_HYBRID);
}
if (map.containsKey(APIConstants.GATEWAY_ENV_TYPE_PRODUCTION)) {
return map.get(APIConstants.GATEWAY_ENV_TYPE_PRODUCTION);
}
if (map.containsKey(APIConstants.GATEWAY_ENV_TYPE_SANDBOX)) {
return map.get(APIConstants.GATEWAY_ENV_TYPE_SANDBOX);
}
return map.get(type);
}
use of org.wso2.ballerinalang.compiler.semantics.analyzer.Types in project carbon-apimgt by wso2.
the class ExtendedHTTPEventAdaptorTestCase method testHttpPublisherFactory.
@Test
public void testHttpPublisherFactory() {
logger.info("Test case for factory properties of Extended HTTP output adaptor.");
ExtendedHTTPEventAdapterFactory adapterFactory = new ExtendedHTTPEventAdapterFactory();
List<Property> dyPropertyList = adapterFactory.getDynamicPropertyList();
List<Property> propertyList = new ArrayList<>();
Property property = new Property("http.url");
property.setRequired(true);
property.setSecured(false);
property.setEncrypted(false);
property.setDisplayName("URL");
property.setDefaultValue(null);
property.setOptions(null);
property.setHint("The target HTTP/HTTPS URL, e.g. \"http://yourhost:8080/service\"");
propertyList.add(property);
property = new Property("http.username");
property.setRequired(false);
property.setSecured(false);
property.setEncrypted(false);
property.setDisplayName("Username");
property.setDefaultValue(null);
property.setOptions(null);
property.setHint("HTTP BasicAuth username");
propertyList.add(property);
property = new Property("http.password");
property.setRequired(false);
property.setSecured(true);
property.setEncrypted(true);
property.setDisplayName("Password");
property.setDefaultValue(null);
property.setOptions(null);
property.setHint("HTTP BasicAuth password");
propertyList.add(property);
property = new Property("http.headers");
property.setRequired(false);
property.setSecured(false);
property.setEncrypted(false);
property.setDisplayName("Headers");
property.setDefaultValue(null);
property.setOptions(null);
property.setHint("Custom HTTP headers, e.g. \"header1: value1, header2: value2\"");
propertyList.add(property);
Assert.assertEquals(4, dyPropertyList.size());
int i = 0;
for (Property prop : propertyList) {
Assert.assertEquals(prop.getPropertyName(), dyPropertyList.get(i).getPropertyName());
Assert.assertEquals(prop.getDefaultValue(), dyPropertyList.get(i).getDefaultValue());
Assert.assertEquals(prop.getDisplayName(), dyPropertyList.get(i).getDisplayName());
Assert.assertEquals(prop.getHint(), dyPropertyList.get(i).getHint());
i++;
}
List<String> types = new ArrayList<>();
types.add("text");
types.add("xml");
types.add("json");
List<String> supportedTypes = adapterFactory.getSupportedMessageFormats();
Assert.assertEquals(supportedTypes.toString(), types.toString());
Assert.assertEquals("http-extended", adapterFactory.getType());
setupCarbonConfig();
PrivilegedCarbonContext privilegedCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
privilegedCarbonContext.setTenantId(-1234);
OutputEventAdapterConfiguration eventAdapterConfiguration = new OutputEventAdapterConfiguration();
eventAdapterConfiguration.setName("TestHttpAdaptor");
eventAdapterConfiguration.setType("http-extended");
eventAdapterConfiguration.setMessageFormat("text");
Map<String, String> staticPropertes = new HashMap<>();
staticPropertes.put("http.client.method", "HttpPost");
staticPropertes.put("http.proxy.port", "9090");
staticPropertes.put("http.proxy.host", "localhost");
staticPropertes.put("oauth.url", "localhost:9090/token");
staticPropertes.put("oauth.consumer.key", "key");
staticPropertes.put("oauth.consumer.secret", "secret");
eventAdapterConfiguration.setStaticProperties(staticPropertes);
Map<String, String> globalProperties = new HashMap<>();
globalProperties.put("jobQueueSize", "10000");
globalProperties.put("keepAliveTimeInMillis", "20000");
globalProperties.put("maxThread", "100");
globalProperties.put("minThread", "8");
globalProperties.put("defaultMaxConnectionsPerHost", "50");
globalProperties.put("maxTotalConnections", "1000");
adapterFactory.createEventAdapter(eventAdapterConfiguration, globalProperties);
}
Aggregations