use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project ballerina by ballerina-lang.
the class GlobalVarServicePkgTest method testAssigningFuncInvFromSamePkg.
@Test(description = "Test assigning function invocation from same package", enabled = false)
public void testAssigningFuncInvFromSamePkg() {
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage("/globalvar-pkg/func-inv-from-same-pkg", "GET");
HTTPCarbonMessage response = Services.invokeNew(result, cMsg);
Assert.assertNotNull(response);
// Expected Json message : {"glbVarFunc":423277.72343}
BJSON bJson = new BJSON(new HttpMessageDataStreamer(response).getInputStream());
Assert.assertEquals(bJson.value().get("glbVarFunc").asText(), "423277.72343");
}
use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project ballerina by ballerina-lang.
the class GlobalVarServicePkgTest method testChangeAndAccessGlobalVarInDiffPkg.
@Test(description = "Test change global var in different package and access it", enabled = false)
public void testChangeAndAccessGlobalVarInDiffPkg() {
HTTPTestRequest cMsgChange = MessageUtils.generateHTTPMessage("/globalvar-pkg/change-global-var-diff-pkg", "GET");
Services.invokeNew(result, cMsgChange);
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage("/globalvar-second-pkg/get-changed-resource-level", "GET");
HTTPCarbonMessage response = Services.invokeNew(result, cMsg);
Assert.assertNotNull(response);
// Expected Json message : {"changeVarFloat":345432.454}
BJSON bJson = new BJSON(new HttpMessageDataStreamer(response).getInputStream());
Assert.assertEquals(bJson.value().get("changeVarFloat").asText(), "345432.454");
}
use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project carbon-apimgt by wso2.
the class AdditionalSubscriptionInfoMappingUtil method mapSolaceTopicObjects.
/**
* Map SolaceTopicsObjectDTO details from Solace package to DevPortal DTOs
*
* @param solaceTopicsObject SolaceTopicsObjectDTO object from Solace package
* @return AdditionalSubscriptionInfoSolaceTopicsObjectDTO object
*/
private static AdditionalSubscriptionInfoSolaceTopicsObjectDTO mapSolaceTopicObjects(SolaceTopicsObjectDTO solaceTopicsObject) {
AdditionalSubscriptionInfoSolaceTopicsObjectDTO solaceTopicsObjectDTO = new AdditionalSubscriptionInfoSolaceTopicsObjectDTO();
// Set default syntax object
org.wso2.carbon.apimgt.solace.dtos.SolaceTopicsDTO defaultSyntaxObject = solaceTopicsObject.getDefaultSyntax();
SolaceTopicsDTO storeDefaultSolaceTopicObject = new SolaceTopicsDTO();
storeDefaultSolaceTopicObject.setPublishTopics(defaultSyntaxObject.getPublishTopics());
storeDefaultSolaceTopicObject.setSubscribeTopics(defaultSyntaxObject.getSubscribeTopics());
solaceTopicsObjectDTO.setDefaultSyntax(storeDefaultSolaceTopicObject);
// Set mqtt syntax object
org.wso2.carbon.apimgt.solace.dtos.SolaceTopicsDTO mqttSyntaxObject = solaceTopicsObject.getMqttSyntax();
SolaceTopicsDTO storeMQTTSolaceTopicObject = new SolaceTopicsDTO();
storeMQTTSolaceTopicObject.setPublishTopics(mqttSyntaxObject.getPublishTopics());
storeMQTTSolaceTopicObject.setSubscribeTopics(mqttSyntaxObject.getSubscribeTopics());
solaceTopicsObjectDTO.setMqttSyntax(storeMQTTSolaceTopicObject);
return solaceTopicsObjectDTO;
}
use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project carbon-apimgt by wso2.
the class EndpointsApiServiceImplTestCase method endpointsEndpointIdGatewayConfigGetTest.
@Test
public void endpointsEndpointIdGatewayConfigGetTest() throws Exception {
APIMgtAdminServiceImpl apiMgtAdminService = Mockito.mock(APIMgtAdminServiceImpl.class);
APIManagerFactory instance = Mockito.mock(APIManagerFactory.class);
PowerMockito.mockStatic(APIManagerFactory.class);
PowerMockito.when(APIManagerFactory.getInstance()).thenReturn(instance);
Mockito.when(instance.getAPIMgtAdminService()).thenReturn(apiMgtAdminService);
EndpointsApiServiceImpl endpointsApiService = new EndpointsApiServiceImpl();
String endpointId = UUID.randomUUID().toString();
String endpointGatewayConfig = "package deployment.org.wso2.apim;\n" + "import ballerina.net.http;\n" + "\n" + "@http:BasePath(\"/aaa1\")\n" + "service aaa1_1489666767745 {\n" + "\n" + " @http:GET\n" + " @http:Path(\"/*\")\n" + " resource get_star_ (message m) {\n" + " http:ClientConnector productionEndpoint = create http:ClientConnector(getUrlFromKey" + "(\"aaa1_1.0.0__ep\"));\n http:ClientConnector sandboxEndpoint = create http:ClientConnector" + "(getUrlFromKey(\"aaa1_1.0.0__ep\"));\n message response;\n string endpointType;\n string " + "productionType;\n \n \n endpointType = \"production\";\n productionType = \"production\";\n" + "\n if (endpointType == productionType) {\n" + " response = http:ClientConnector.execute(productionEndpoint, \"get\", \"\", m);\n" + " } else {\n" + " response = http:ClientConnector.execute(sandboxEndpoint, \"get\", \"\", m);\n" + " }\n" + "\n" + " reply response;\n" + " }\n" + "}";
Mockito.when(apiMgtAdminService.getEndpointGatewayConfig(endpointId)).thenReturn(endpointGatewayConfig);
Response response = endpointsApiService.endpointsEndpointIdGatewayConfigGet(endpointId, null, getRequest());
Assert.assertEquals(response.getStatus(), 200);
}
use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project carbon-business-process by wso2.
the class HumanTaskApplicationAdmin method getHumanTaskAppData.
/**
* Gives a HumanTaskAppMetadata object with all humantask packages deployed through the
* given app.
*
* @param appName - input app name
* @return - HumanTaskAppMetadata object with found artifact info
* @throws Exception - error on retrieving metadata
*/
public HumanTaskAppMetadata getHumanTaskAppData(String appName) throws Exception {
HumanTaskAppMetadata data = new HumanTaskAppMetadata();
String tenantId = AppDeployerUtils.getTenantIdString(getAxisConfig());
// Check whether there is an application in the system from the given name
ArrayList<CarbonApplication> appList = HumanTaskAppMgtServiceComponent.getAppManager().getCarbonApps(tenantId);
CarbonApplication currentApplication = null;
for (CarbonApplication application : appList) {
if (appName.equals(application.getAppNameWithVersion())) {
currentApplication = application;
break;
}
}
// If the app not found, throw an exception
if (currentApplication == null) {
String msg = "No Carbon Application found of the name : " + appName;
log.error(msg);
throw new Exception(msg);
}
// get all dependent artifacts of the cApp
List<Artifact.Dependency> deps = currentApplication.getAppConfig().getApplicationArtifact().getDependencies();
// we use the humantask backend admin service to get tasks from a humantask package
HumanTaskPackageManagementSkeleton humantaskAdmin = new HumanTaskPackageManagementSkeleton();
// package list to return
List<PackageMetadata> packageList = new ArrayList<PackageMetadata>();
String packageName;
for (Artifact.Dependency dep : deps) {
Artifact artifact = dep.getArtifact();
packageName = artifact.getRuntimeObjectName();
if (packageName == null) {
continue;
}
if (HumanTaskAppDeployer.HUMANTASK_TYPE.equals(artifact.getType())) {
PackageMetadata packageMetadata = new PackageMetadata();
packageMetadata.setPackageName(packageName);
// get the list of tasks
List<String> taskList = new ArrayList<String>();
Task_type0[] tasksInPackage = humantaskAdmin.listTasksInPackage(packageName);
for (Task_type0 taskInfo : tasksInPackage) {
taskList.add(taskInfo.getName());
}
String[] tasks = new String[taskList.size()];
packageMetadata.setTaskList(tasks);
packageList.add(packageMetadata);
}
}
// convert the List into an array
data.setPackages(packageList.toArray(new PackageMetadata[packageList.size()]));
return data;
}
Aggregations