Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
madushajg committed Aug 22, 2023
1 parent fb4f4d2 commit be4ef3e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ public void testSingleModuleModelGeneration() throws IOException {
String generatedService = TestUtils.replaceStdLibVersionStrings(gson.toJson(service)
.replaceAll("\\s+", "")
.replaceAll("\\\\\\\\", "/")
.replaceAll("\"serviceId\": ?\"-?\\d*\"", "\"serviceId\": null"));
.replaceAll("\"id\":\"-?\\d*:", "\"id\":\"000:"));
String expectedService = TestUtils.replaceStdLibVersionStrings(
gson.toJson(expectedModel.getServices().get(id))
.replaceAll("\\s+", "")
.replaceAll("\\{srcPath}", RES_DIR.toString().replaceAll("\\\\", "/"))
.replaceAll("\"serviceId\": ?\"-?\\d*\"", "\"serviceId\": null"));
.replaceAll("\"id\":\"-?\\d*:", "\"id\":\"000:"));
Assert.assertEquals(generatedService, expectedService);
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
{
"version": "0.4.0",
"packageId": {
"name": "single_service_sample",
"org": "aneesha",
"version": "0.1.0"
},
"modelVersion": "0.4.0",
"id": "single_service_sample",
"orgName": "aneesha",
"version": "0.1.0",
"hasCompilationErrors": false,
"diagnostics": [],
"services": {
"001": {
"serviceId": "001",
"id": "001",
"label": "greeting-service",
"serviceType": "ballerina/http:2.8.1",
"resources": [
"type": "ballerina/http:2.8.1",
"resourceFunctions": [
{
"identifier": ".",
"resourceId": {
"serviceId": "001",
"serviceLabel": "greeting-service",
"path": ".",
"action": "get"
},
"id": "001:.:get",
"path": ".",
"parameters": [
{
"type": [
Expand All @@ -29,7 +22,7 @@
"name": "name",
"in": "query",
"isRequired": true,
"elementLocation": {
"sourceLocation": {
"filePath": "{srcPath}/ballerina/single_service_sample/main.bal",
"startPosition": {
"line": 15,
Expand All @@ -49,7 +42,7 @@
"name": "time",
"in": "query",
"isRequired": true,
"elementLocation": {
"sourceLocation": {
"filePath": "{srcPath}/ballerina/single_service_sample/main.bal",
"startPosition": {
"line": 15,
Expand All @@ -69,14 +62,9 @@
],
"interactions": [
{
"resourceId": {
"serviceId": "002",
"serviceLabel": "time-service",
"path": "[string]",
"action": "get"
},
"connectorType": "ballerina/http:2.8.1",
"elementLocation": {
"id": "002:[string]:get",
"type": "ballerina/http:2.8.1",
"sourceLocation": {
"filePath": "{srcPath}/ballerina/single_service_sample/main.bal",
"startPosition": {
"line": 21,
Expand All @@ -90,7 +78,7 @@
"diagnostics": []
}
],
"elementLocation": {
"sourceLocation": {
"filePath": "{srcPath}/ballerina/single_service_sample/main.bal",
"startPosition": {
"line": 15,
Expand All @@ -104,19 +92,14 @@
"diagnostics": []
},
{
"identifier": "accounts",
"resourceId": {
"serviceId": "001",
"serviceLabel": "greeting-service",
"path": "accounts",
"action": "get"
},
"id": "001:accounts:get",
"path": "accounts",
"parameters": [],
"returns": [
"aneesha/single_service_sample:model:0.1.0:Account"
],
"interactions": [],
"elementLocation": {
"sourceLocation": {
"filePath": "{srcPath}/ballerina/single_service_sample/main.bal",
"startPosition": {
"line": 25,
Expand All @@ -130,28 +113,18 @@
"diagnostics": []
},
{
"identifier": "weather",
"resourceId": {
"serviceId": "001",
"serviceLabel": "greeting-service",
"path": "weather",
"action": "get"
},
"id": "001:weather:get",
"path": "weather",
"parameters": [],
"returns": [
"string",
"error"
],
"interactions": [
{
"resourceId": {
"serviceId": "1934985684",
"serviceLabel": "",
"path": "getCurrentWeather",
"action": "get"
},
"connectorType": "ballerina/http:2.8.1",
"elementLocation": {
"id": "-459379229:getCurrentWeather:get",
"type": "ballerina/http:2.8.1",
"sourceLocation": {
"filePath": "{srcPath}/ballerina/single_service_sample/main.bal",
"startPosition": {
"line": 15,
Expand All @@ -165,7 +138,7 @@
"diagnostics": []
}
],
"elementLocation": {
"sourceLocation": {
"filePath": "{srcPath}/ballerina/single_service_sample/main.bal",
"startPosition": {
"line": 29,
Expand All @@ -179,10 +152,11 @@
"diagnostics": []
}
],
"remoteFunctions": [],
"annotation": {
"id": "001",
"label": "greeting-service",
"elementLocation": {
"sourceLocation": {
"filePath": "{srcPath}/ballerina/single_service_sample/main.bal",
"startPosition": {
"line": 10,
Expand All @@ -195,9 +169,8 @@
},
"diagnostics": []
},
"remoteFunctions": [],
"dependencyIDs": [],
"elementLocation": {
"dependencies": [],
"sourceLocation": {
"filePath": "{srcPath}/ballerina/single_service_sample/main.bal",
"startPosition": {
"line": 10,
Expand All @@ -211,18 +184,13 @@
"diagnostics": []
},
"002": {
"serviceId": "002",
"id": "002",
"label": "time-service",
"serviceType": "ballerina/http:2.8.1",
"resources": [
"type": "ballerina/http:2.8.1",
"resourceFunctions": [
{
"identifier": "greeting",
"resourceId": {
"serviceId": "002",
"serviceLabel": "time-service",
"path": "greeting",
"action": "get"
},
"id": "002:greeting:get",
"path": "greeting",
"parameters": [
{
"type": [
Expand All @@ -231,7 +199,7 @@
"name": "time",
"in": "query",
"isRequired": true,
"elementLocation": {
"sourceLocation": {
"filePath": "{srcPath}/ballerina/single_service_sample/main.bal",
"startPosition": {
"line": 41,
Expand All @@ -249,7 +217,7 @@
"string"
],
"interactions": [],
"elementLocation": {
"sourceLocation": {
"filePath": "{srcPath}/ballerina/single_service_sample/main.bal",
"startPosition": {
"line": 41,
Expand All @@ -263,10 +231,11 @@
"diagnostics": []
}
],
"remoteFunctions": [],
"annotation": {
"id": "002",
"label": "time-service",
"elementLocation": {
"sourceLocation": {
"filePath": "{srcPath}/ballerina/single_service_sample/main.bal",
"startPosition": {
"line": 36,
Expand All @@ -279,9 +248,8 @@
},
"diagnostics": []
},
"remoteFunctions": [],
"dependencyIDs": [],
"elementLocation": {
"dependencies": [],
"sourceLocation": {
"filePath": "{srcPath}/ballerina/single_service_sample/main.bal",
"startPosition": {
"line": 36,
Expand All @@ -306,7 +274,7 @@
"defaultValue": "",
"associations": [],
"isReadOnly": true,
"elementLocation": {
"sourceLocation": {
"filePath": "{srcPath}/ballerina/single_service_sample/modules/model/AccountModel.bal",
"startPosition": {
"line": 1,
Expand All @@ -327,7 +295,7 @@
"defaultValue": "",
"associations": [],
"isReadOnly": false,
"elementLocation": {
"sourceLocation": {
"filePath": "{srcPath}/ballerina/single_service_sample/modules/model/AccountModel.bal",
"startPosition": {
"line": 2,
Expand All @@ -348,7 +316,7 @@
"defaultValue": "",
"associations": [],
"isReadOnly": false,
"elementLocation": {
"sourceLocation": {
"filePath": "{srcPath}/ballerina/single_service_sample/modules/model/AccountModel.bal",
"startPosition": {
"line": 3,
Expand All @@ -364,7 +332,7 @@
],
"inclusions": [],
"isAnonymous": false,
"elementLocation": {
"sourceLocation": {
"filePath": "{srcPath}/ballerina/single_service_sample/modules/model/AccountModel.bal",
"startPosition": {
"line": 0,
Expand Down

0 comments on commit be4ef3e

Please sign in to comment.