From be4ef3e2488985e34510a5405421f566457edc77 Mon Sep 17 00:00:00 2001 From: Madusha Date: Tue, 22 Aug 2023 13:29:17 +0530 Subject: [PATCH] Update tests --- .../core/ServiceGeneratorTests.java | 4 +- .../results/simple_service_sample.json | 118 +++++++----------- 2 files changed, 45 insertions(+), 77 deletions(-) diff --git a/architecture-model-generator/modules/architecture-model-generator-core/src/test/java/io/ballerina/architecturemodelgenerator/core/ServiceGeneratorTests.java b/architecture-model-generator/modules/architecture-model-generator-core/src/test/java/io/ballerina/architecturemodelgenerator/core/ServiceGeneratorTests.java index 9520b98ed..aeff0cfad 100644 --- a/architecture-model-generator/modules/architecture-model-generator-core/src/test/java/io/ballerina/architecturemodelgenerator/core/ServiceGeneratorTests.java +++ b/architecture-model-generator/modules/architecture-model-generator-core/src/test/java/io/ballerina/architecturemodelgenerator/core/ServiceGeneratorTests.java @@ -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); }); } diff --git a/architecture-model-generator/modules/architecture-model-generator-core/src/test/resources/results/simple_service_sample.json b/architecture-model-generator/modules/architecture-model-generator-core/src/test/resources/results/simple_service_sample.json index bd307eb24..d946bbe18 100644 --- a/architecture-model-generator/modules/architecture-model-generator-core/src/test/resources/results/simple_service_sample.json +++ b/architecture-model-generator/modules/architecture-model-generator-core/src/test/resources/results/simple_service_sample.json @@ -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": [ @@ -29,7 +22,7 @@ "name": "name", "in": "query", "isRequired": true, - "elementLocation": { + "sourceLocation": { "filePath": "{srcPath}/ballerina/single_service_sample/main.bal", "startPosition": { "line": 15, @@ -49,7 +42,7 @@ "name": "time", "in": "query", "isRequired": true, - "elementLocation": { + "sourceLocation": { "filePath": "{srcPath}/ballerina/single_service_sample/main.bal", "startPosition": { "line": 15, @@ -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, @@ -90,7 +78,7 @@ "diagnostics": [] } ], - "elementLocation": { + "sourceLocation": { "filePath": "{srcPath}/ballerina/single_service_sample/main.bal", "startPosition": { "line": 15, @@ -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, @@ -130,13 +113,8 @@ "diagnostics": [] }, { - "identifier": "weather", - "resourceId": { - "serviceId": "001", - "serviceLabel": "greeting-service", - "path": "weather", - "action": "get" - }, + "id": "001:weather:get", + "path": "weather", "parameters": [], "returns": [ "string", @@ -144,14 +122,9 @@ ], "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, @@ -165,7 +138,7 @@ "diagnostics": [] } ], - "elementLocation": { + "sourceLocation": { "filePath": "{srcPath}/ballerina/single_service_sample/main.bal", "startPosition": { "line": 29, @@ -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, @@ -195,9 +169,8 @@ }, "diagnostics": [] }, - "remoteFunctions": [], - "dependencyIDs": [], - "elementLocation": { + "dependencies": [], + "sourceLocation": { "filePath": "{srcPath}/ballerina/single_service_sample/main.bal", "startPosition": { "line": 10, @@ -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": [ @@ -231,7 +199,7 @@ "name": "time", "in": "query", "isRequired": true, - "elementLocation": { + "sourceLocation": { "filePath": "{srcPath}/ballerina/single_service_sample/main.bal", "startPosition": { "line": 41, @@ -249,7 +217,7 @@ "string" ], "interactions": [], - "elementLocation": { + "sourceLocation": { "filePath": "{srcPath}/ballerina/single_service_sample/main.bal", "startPosition": { "line": 41, @@ -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, @@ -279,9 +248,8 @@ }, "diagnostics": [] }, - "remoteFunctions": [], - "dependencyIDs": [], - "elementLocation": { + "dependencies": [], + "sourceLocation": { "filePath": "{srcPath}/ballerina/single_service_sample/main.bal", "startPosition": { "line": 36, @@ -306,7 +274,7 @@ "defaultValue": "", "associations": [], "isReadOnly": true, - "elementLocation": { + "sourceLocation": { "filePath": "{srcPath}/ballerina/single_service_sample/modules/model/AccountModel.bal", "startPosition": { "line": 1, @@ -327,7 +295,7 @@ "defaultValue": "", "associations": [], "isReadOnly": false, - "elementLocation": { + "sourceLocation": { "filePath": "{srcPath}/ballerina/single_service_sample/modules/model/AccountModel.bal", "startPosition": { "line": 2, @@ -348,7 +316,7 @@ "defaultValue": "", "associations": [], "isReadOnly": false, - "elementLocation": { + "sourceLocation": { "filePath": "{srcPath}/ballerina/single_service_sample/modules/model/AccountModel.bal", "startPosition": { "line": 3, @@ -364,7 +332,7 @@ ], "inclusions": [], "isAnonymous": false, - "elementLocation": { + "sourceLocation": { "filePath": "{srcPath}/ballerina/single_service_sample/modules/model/AccountModel.bal", "startPosition": { "line": 0,