├── src
├── test
│ ├── resources
│ │ ├── test1
│ │ │ ├── .gitignore
│ │ │ ├── Ballerina.toml
│ │ │ ├── modules
│ │ │ │ └── module_test1
│ │ │ │ │ ├── resources
│ │ │ │ │ └── Issue_data.json
│ │ │ │ │ ├── connector_endpoint.bal
│ │ │ │ │ └── connector_types.bal
│ │ │ └── main.bal
│ │ ├── test10
│ │ │ ├── .gitignore
│ │ │ ├── Ballerina.toml
│ │ │ ├── main.bal
│ │ │ └── modules
│ │ │ │ └── module_test10
│ │ │ │ ├── connector_endpoint.bal
│ │ │ │ ├── resources
│ │ │ │ └── Issue_data.json
│ │ │ │ └── connector_types.bal
│ │ ├── test11
│ │ │ ├── .gitignore
│ │ │ ├── Ballerina.toml
│ │ │ ├── modules
│ │ │ │ └── module_test11
│ │ │ │ │ ├── resources
│ │ │ │ │ └── Issue_data.json
│ │ │ │ │ ├── connector_endpoint.bal
│ │ │ │ │ └── connector_types.bal
│ │ │ └── main.bal
│ │ ├── test12
│ │ │ ├── .gitignore
│ │ │ ├── Ballerina.toml
│ │ │ ├── modules
│ │ │ │ └── module_test12
│ │ │ │ │ ├── resources
│ │ │ │ │ ├── menu_data.json
│ │ │ │ │ └── Issue_data.json
│ │ │ │ │ ├── connector_endpoint.bal
│ │ │ │ │ └── connector_types.bal
│ │ │ └── main.bal
│ │ ├── test13
│ │ │ ├── .gitignore
│ │ │ ├── Ballerina.toml
│ │ │ ├── main.bal
│ │ │ └── modules
│ │ │ │ └── module_test13
│ │ │ │ └── connector_endpoint.bal
│ │ ├── test14
│ │ │ ├── .gitignore
│ │ │ └── main.bal
│ │ ├── test15
│ │ │ ├── .gitignore
│ │ │ ├── Ballerina.toml
│ │ │ ├── resources
│ │ │ │ └── Issue_data.json
│ │ │ ├── modules
│ │ │ │ └── module_test15
│ │ │ │ │ ├── resources
│ │ │ │ │ └── Issue_data.json
│ │ │ │ │ ├── connector_endpoint.bal
│ │ │ │ │ └── connector_types.bal
│ │ │ ├── main.bal
│ │ │ ├── connector_endpoint.bal
│ │ │ └── connector_types.bal
│ │ ├── test17
│ │ │ ├── .gitignore
│ │ │ ├── Ballerina.toml
│ │ │ ├── modules
│ │ │ │ └── module_test17
│ │ │ │ │ ├── resources
│ │ │ │ │ ├── Issue_data.json
│ │ │ │ │ └── Issue2_data.json
│ │ │ │ │ ├── connector_endpoint.bal
│ │ │ │ │ └── connector_types.bal
│ │ │ └── main.bal
│ │ ├── test18
│ │ │ ├── .gitignore
│ │ │ └── main.bal
│ │ ├── test2
│ │ │ ├── .gitignore
│ │ │ ├── Ballerina.toml
│ │ │ ├── main.bal
│ │ │ └── modules
│ │ │ │ └── module_test2
│ │ │ │ ├── connector_endpoint.bal
│ │ │ │ ├── connector_types.bal
│ │ │ │ └── resources
│ │ │ │ └── Issue_data.json
│ │ ├── test3
│ │ │ ├── .gitignore
│ │ │ ├── Ballerina.toml
│ │ │ ├── main.bal
│ │ │ └── modules
│ │ │ │ └── module_test3
│ │ │ │ ├── resources
│ │ │ │ └── Issue_data.json
│ │ │ │ ├── connector_endpoint.bal
│ │ │ │ └── connector_types.bal
│ │ ├── test4
│ │ │ ├── .gitignore
│ │ │ ├── Ballerina.toml
│ │ │ ├── modules
│ │ │ │ └── module_test4
│ │ │ │ │ ├── resources
│ │ │ │ │ └── Issue_data.json
│ │ │ │ │ ├── connector_endpoint.bal
│ │ │ │ │ └── connector_types.bal
│ │ │ └── main.bal
│ │ ├── test5
│ │ │ ├── .gitignore
│ │ │ ├── Ballerina.toml
│ │ │ ├── modules
│ │ │ │ └── module_test5
│ │ │ │ │ ├── resources
│ │ │ │ │ ├── Creator_data.json
│ │ │ │ │ └── Issue_data.json
│ │ │ │ │ ├── connector_endpoint.bal
│ │ │ │ │ └── connector_types.bal
│ │ │ └── main.bal
│ │ ├── test6
│ │ │ ├── .gitignore
│ │ │ ├── Ballerina.toml
│ │ │ ├── modules
│ │ │ │ └── module_test6
│ │ │ │ │ ├── resources
│ │ │ │ │ ├── Creator_data.json
│ │ │ │ │ └── Issue_data.json
│ │ │ │ │ ├── connector_endpoint.bal
│ │ │ │ │ └── connector_types.bal
│ │ │ └── main.bal
│ │ ├── test7
│ │ │ ├── .gitignore
│ │ │ ├── Ballerina.toml
│ │ │ ├── modules
│ │ │ │ └── module_test7
│ │ │ │ │ ├── resources
│ │ │ │ │ └── Issue_data.json
│ │ │ │ │ ├── connector_endpoint.bal
│ │ │ │ │ └── connector_types.bal
│ │ │ └── main.bal
│ │ ├── test8
│ │ │ ├── .gitignore
│ │ │ ├── Ballerina.toml
│ │ │ └── main.bal
│ │ ├── test9
│ │ │ ├── .gitignore
│ │ │ ├── Ballerina.toml
│ │ │ ├── modules
│ │ │ │ └── module_test9
│ │ │ │ │ ├── resources
│ │ │ │ │ └── Issue_data.json
│ │ │ │ │ ├── connector_endpoint.bal
│ │ │ │ │ └── connector_types.bal
│ │ │ └── main.bal
│ │ ├── test16.package
│ │ │ ├── .gitignore
│ │ │ ├── Ballerina.toml
│ │ │ ├── resources
│ │ │ │ └── Issue_data.json
│ │ │ ├── modules
│ │ │ │ └── module_test16
│ │ │ │ │ ├── resources
│ │ │ │ │ └── Issue_data.json
│ │ │ │ │ ├── connector_endpoint.bal
│ │ │ │ │ └── connector_types.bal
│ │ │ ├── main.bal
│ │ │ ├── connector_endpoint.bal
│ │ │ └── connector_types.bal
│ │ ├── testng.xml
│ │ └── logging.properties
│ └── java
│ │ └── org
│ │ └── ballerinax
│ │ └── datamapper
│ │ └── DataMapperPluginTest.java
└── main
│ ├── resources
│ ├── META-INF
│ │ └── services
│ │ │ └── io.ballerina.projects.plugins.CompilerPlugin
│ └── datamapper.properties
│ └── java
│ └── org
│ └── ballerinax
│ └── datamapper
│ ├── exceptions
│ └── DataMapperException.java
│ ├── DataMapperCompilerPlugin.java
│ ├── DataMapperCodeAnalyzer.java
│ ├── FunctionRecord.java
│ ├── util
│ └── Utils.java
│ ├── diagnostic
│ ├── DiagnosticErrorCode.java
│ └── DataMapperDiagnosticLog.java
│ ├── DataMapperNodeVisitor.java
│ └── SampleDataAnalysisTask.java
├── gradle
├── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
└── javaProject.gradle
├── .github
├── CODEOWNERS
└── workflows
│ ├── pull-request.yml
│ ├── build-master.yml
│ └── publish-release.yml
├── spotbugs-exclude.xml
├── gradle.properties
├── .gitignore
├── issue_template.md
├── settings.gradle
├── pull_request_template.md
├── gradlew.bat
├── README.md
├── gradlew
└── LICENSE
/src/test/resources/test1/.gitignore:
--------------------------------------------------------------------------------
1 | target
--------------------------------------------------------------------------------
/src/test/resources/test10/.gitignore:
--------------------------------------------------------------------------------
1 | target
--------------------------------------------------------------------------------
/src/test/resources/test11/.gitignore:
--------------------------------------------------------------------------------
1 | target
--------------------------------------------------------------------------------
/src/test/resources/test12/.gitignore:
--------------------------------------------------------------------------------
1 | target
--------------------------------------------------------------------------------
/src/test/resources/test13/.gitignore:
--------------------------------------------------------------------------------
1 | target
--------------------------------------------------------------------------------
/src/test/resources/test14/.gitignore:
--------------------------------------------------------------------------------
1 | target
--------------------------------------------------------------------------------
/src/test/resources/test15/.gitignore:
--------------------------------------------------------------------------------
1 | target
--------------------------------------------------------------------------------
/src/test/resources/test17/.gitignore:
--------------------------------------------------------------------------------
1 | target
--------------------------------------------------------------------------------
/src/test/resources/test18/.gitignore:
--------------------------------------------------------------------------------
1 | target
--------------------------------------------------------------------------------
/src/test/resources/test2/.gitignore:
--------------------------------------------------------------------------------
1 | target
--------------------------------------------------------------------------------
/src/test/resources/test3/.gitignore:
--------------------------------------------------------------------------------
1 | target
--------------------------------------------------------------------------------
/src/test/resources/test4/.gitignore:
--------------------------------------------------------------------------------
1 | target
--------------------------------------------------------------------------------
/src/test/resources/test5/.gitignore:
--------------------------------------------------------------------------------
1 | target
--------------------------------------------------------------------------------
/src/test/resources/test6/.gitignore:
--------------------------------------------------------------------------------
1 | target
--------------------------------------------------------------------------------
/src/test/resources/test7/.gitignore:
--------------------------------------------------------------------------------
1 | target
--------------------------------------------------------------------------------
/src/test/resources/test8/.gitignore:
--------------------------------------------------------------------------------
1 | target
--------------------------------------------------------------------------------
/src/test/resources/test9/.gitignore:
--------------------------------------------------------------------------------
1 | target
--------------------------------------------------------------------------------
/src/test/resources/test16.package/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 |
--------------------------------------------------------------------------------
/src/main/resources/META-INF/services/io.ballerina.projects.plugins.CompilerPlugin:
--------------------------------------------------------------------------------
1 | org.ballerinax.datamapper.DataMapperCompilerPlugin
2 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-datamapper/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/src/test/resources/test1/Ballerina.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | org= "ballerinax"
3 | name= "test1"
4 | version= "0.1.0"
5 |
6 | [build-options]
7 | observabilityIncluded=true
8 |
--------------------------------------------------------------------------------
/src/test/resources/test10/Ballerina.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | org= "ballerinax"
3 | name= "test10"
4 | version= "0.1.0"
5 |
6 | [build-options]
7 | observabilityIncluded=true
8 |
--------------------------------------------------------------------------------
/src/test/resources/test11/Ballerina.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | org= "ballerinax"
3 | name= "test11"
4 | version= "0.1.0"
5 |
6 | [build-options]
7 | observabilityIncluded=true
8 |
--------------------------------------------------------------------------------
/src/test/resources/test12/Ballerina.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | org= "ballerinax"
3 | name= "test12"
4 | version= "0.1.0"
5 |
6 | [build-options]
7 | observabilityIncluded=true
8 |
--------------------------------------------------------------------------------
/src/test/resources/test13/Ballerina.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | org= "ballerinax"
3 | name= "test13"
4 | version= "0.1.0"
5 |
6 | [build-options]
7 | observabilityIncluded=true
8 |
--------------------------------------------------------------------------------
/src/test/resources/test15/Ballerina.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | org= "ballerinax"
3 | name= "test15"
4 | version= "0.1.0"
5 |
6 | [build-options]
7 | observabilityIncluded=true
8 |
--------------------------------------------------------------------------------
/src/test/resources/test17/Ballerina.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | org= "ballerinax"
3 | name= "test17"
4 | version= "0.1.0"
5 |
6 | [build-options]
7 | observabilityIncluded=true
8 |
--------------------------------------------------------------------------------
/src/test/resources/test2/Ballerina.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | org= "ballerinax"
3 | name= "test2"
4 | version= "0.1.0"
5 |
6 | [build-options]
7 | observabilityIncluded=true
8 |
--------------------------------------------------------------------------------
/src/test/resources/test3/Ballerina.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | org= "ballerinax"
3 | name= "test3"
4 | version= "0.1.0"
5 |
6 | [build-options]
7 | observabilityIncluded=true
8 |
--------------------------------------------------------------------------------
/src/test/resources/test4/Ballerina.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | org= "ballerinax"
3 | name= "test4"
4 | version= "0.1.0"
5 |
6 | [build-options]
7 | observabilityIncluded=true
8 |
--------------------------------------------------------------------------------
/src/test/resources/test5/Ballerina.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | org= "ballerinax"
3 | name= "test5"
4 | version= "0.1.0"
5 |
6 | [build-options]
7 | observabilityIncluded=true
8 |
--------------------------------------------------------------------------------
/src/test/resources/test6/Ballerina.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | org= "ballerinax"
3 | name= "test6"
4 | version= "0.1.0"
5 |
6 | [build-options]
7 | observabilityIncluded=true
8 |
--------------------------------------------------------------------------------
/src/test/resources/test7/Ballerina.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | org= "ballerinax"
3 | name= "test7"
4 | version= "0.1.0"
5 |
6 | [build-options]
7 | observabilityIncluded=true
8 |
--------------------------------------------------------------------------------
/src/test/resources/test8/Ballerina.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | org= "ballerinax"
3 | name= "test8"
4 | version= "0.1.0"
5 |
6 | [build-options]
7 | observabilityIncluded=true
8 |
--------------------------------------------------------------------------------
/src/test/resources/test9/Ballerina.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | org= "ballerinax"
3 | name= "test9"
4 | version= "0.1.0"
5 |
6 | [build-options]
7 | observabilityIncluded=true
8 |
--------------------------------------------------------------------------------
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # See: https://help.github.com/articles/about-codeowners/
2 |
3 | # These owners will be the default owners for everything in the repo.
4 | * @keizer619
5 |
--------------------------------------------------------------------------------
/src/test/resources/test16.package/Ballerina.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | org= "ballerinax"
3 | name= "test16.package"
4 | version= "0.1.0"
5 |
6 | [build-options]
7 | observabilityIncluded=true
8 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/src/test/resources/test6/modules/module_test6/resources/Creator_data.json:
--------------------------------------------------------------------------------
1 | {
2 | "ballerinax/test6.module_test6:0.1.0:Creator": [
3 | {
4 | "login2": "github-jira",
5 | "resourcePath": "/github-jira",
6 | "url": "https://github.com/github-jira",
7 | "avatarUrl3": "https://avatars1.githubusercontent.com/u/63409295?v=4"
8 | }
9 | ]
10 | }
--------------------------------------------------------------------------------
/src/test/resources/test17/modules/module_test17/resources/Issue_data.json:
--------------------------------------------------------------------------------
1 | {
2 | "ballerinax/test17.module_test17:0.1.0:Creator": [
3 | {
4 | "login": "github-jira",
5 | "resourcePath": "/github-jira",
6 | "url": "https://github.com/github-jira",
7 | "avatarUrl": "https://avatars1.githubusercontent.com/u/63409295?v=4"
8 | }
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/src/test/resources/test17/modules/module_test17/resources/Issue2_data.json:
--------------------------------------------------------------------------------
1 | {
2 | "ballerinax/test17.module_test17:0.1.0:Creator2": [
3 | {
4 | "login": "github-jira",
5 | "resourcePath": "/github-jira",
6 | "url": "https://github.com/github-jira",
7 | "avatarUrl": "https://avatars1.githubusercontent.com/u/63409295?v=4"
8 | }
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/spotbugs-exclude.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/test/resources/test12/modules/module_test12/resources/menu_data.json:
--------------------------------------------------------------------------------
1 | {
2 | "menu": {
3 | "id": "file",
4 | "value": "File",
5 | "popup": {
6 | "menuitem": [
7 | {
8 | "value": "New",
9 | "onclick": "CreateNewDoc()"
10 | },
11 | {
12 | "value": "Open",
13 | "onclick": "OpenDoc()"
14 | },
15 | {
16 | "value": "Close",
17 | "onclick": "CloseDoc()"
18 | }
19 | ]
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.caching=true
2 | org.gradle.jvmargs='-Dfile.encoding=UTF-8'
3 | group=org.ballerinax.datamapper
4 | version=2.2.1-SNAPSHOT
5 | systemProp.org.gradle.internal.publish.checksums.insecure=true
6 | ballerinaLangVersion=2201.8.0-20230908-135700-74a59dff
7 | stdlibIoVersion=1.6.0-20230911-134800-de06e28
8 |
9 | puppycrawlCheckstyleVersion=10.12.0
10 | githubSpotbugsVersion=5.0.14
11 | downloadVersion=5.4.0
12 | researchgateReleaseVersion=2.8.0
13 |
14 | observeVersion=1.2.0-20230911-133500-b3d8db3
15 | observeInternalVersion=1.2.0-20230911-141700-4c0454a
16 |
--------------------------------------------------------------------------------
/src/test/resources/test5/modules/module_test5/resources/Creator_data.json:
--------------------------------------------------------------------------------
1 | {
2 | "ballerinax/test5.module_test5:0.1.0:Creator": [
3 | {
4 | "login": "github-jira",
5 | "resourcePath": "/github-jira",
6 | "url": "https://github.com/github-jira",
7 | "avatarUrl": "https://avatars1.githubusercontent.com/u/63409295?v=4"
8 | },
9 | {
10 | "login": "github-jira",
11 | "resourcePath": "/github-jira",
12 | "url": "https://github.com/github-jira",
13 | "avatarUrl": "https://avatars1.githubusercontent.com/u/63409295?v=5"
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/src/test/resources/test15/resources/Issue_data.json:
--------------------------------------------------------------------------------
1 | {
2 | "ballerinax/test15:0.1.0:Issue": [
3 | {
4 | "id": "MDU6SXNzdWU2MDAwMzQwOTc=",
5 | "bodyText": "Test5",
6 | "closed": "false",
7 | "closedAt": "",
8 | "createdAt": "2020-04-15T05:36:03Z",
9 | "author": null,
10 | "labels": [],
11 | "number": "5",
12 | "state": "OPEN",
13 | "title": "Test5",
14 | "updatedAt": "2020-04-15T05:36:03Z",
15 | "url": "https://github.com/github-jira/demo-github/issues/5",
16 | "assignees": []
17 | }
18 | ]
19 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.ear
17 | *.zip
18 | *.tar.gz
19 | *.rar
20 |
21 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
22 | hs_err_pid*
23 |
24 | # Gradle
25 | build
26 | .gradle/
27 | !gradle/wrapper/gradle-wrapper.jar
28 |
29 | # Maven
30 | target
31 | dependency-reduced-pom.xml
32 |
33 | # IDEA Files
34 | .idea/
35 | *.iml
36 | *.ipr
37 | *.iws
38 |
39 | # MacOS
40 | *.DS_Store
41 |
42 | #Ballerina
43 | *.balx
44 | *Ballerina.lock
45 |
--------------------------------------------------------------------------------
/src/test/resources/test9/modules/module_test9/resources/Issue_data.json:
--------------------------------------------------------------------------------
1 | {
2 | "ballerinax/test9.module_test9:0.1.0:Issue": [
3 | {
4 | : "MDU6SXNzdWU2MDAwMzEyNDY=",
5 | "bodyText": "Test3",
6 | "closed": "false",
7 | "closedAt": "",
8 | "createdAt": "2020-04-15T05:27:33Z",
9 | "author": null,
10 | "labels": [],
11 | "number": "3",
12 | "state": "OPEN",
13 | "title": "Test3",
14 | "updatedAt": "2020-04-15T05:30:47Z",
15 | "url": "https://github.com/github-jira/demo-github/issues/3",
16 | "assignees": []
17 |
18 | ]
19 | }
--------------------------------------------------------------------------------
/src/test/resources/test16.package/resources/Issue_data.json:
--------------------------------------------------------------------------------
1 | {
2 | "ballerinax/test16.package:0.1.0:Issue": [
3 | {
4 | "id2": "MDU6SXNzdWU2MDAwMzQwOTc=",
5 | "bodyText": "Test5",
6 | "closed": "false",
7 | "closedAt": "",
8 | "createdAt": "2020-04-15T05:36:03Z",
9 | "author": null,
10 | "labels": [],
11 | "number": "5",
12 | "state": "OPEN",
13 | "title": "Test5",
14 | "updatedAt": "2020-04-15T05:36:03Z",
15 | "url": "https://github.com/github-jira/demo-github/issues/5",
16 | "assignees": []
17 | }
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/src/test/resources/test1/modules/module_test1/resources/Issue_data.json:
--------------------------------------------------------------------------------
1 | {
2 | "ballerinax/test1.module_test1:0.1.0:Issue": [
3 | {
4 | "id": "MDU6SXNzdWU2MDAwMzQwOTc=",
5 | "bodyText": "Test5",
6 | "closed": "false",
7 | "closedAt": "",
8 | "createdAt": "2020-04-15T05:36:03Z",
9 | "author": null,
10 | "labels": [],
11 | "number": "5",
12 | "state": "OPEN",
13 | "title": "Test5",
14 | "updatedAt": "2020-04-15T05:36:03Z",
15 | "url": "https://github.com/github-jira/demo-github/issues/5",
16 | "assignees": []
17 | }
18 | ]
19 | }
--------------------------------------------------------------------------------
/src/test/resources/test5/modules/module_test5/resources/Issue_data.json:
--------------------------------------------------------------------------------
1 | {
2 | "ballerinax/test5.module_test5:0.1.0:Issue": [
3 | {
4 | "id": "MDU6SXNzdWU2MDAwMzEyNDY=",
5 | "bodyText": "Test3",
6 | "closed": "false",
7 | "closedAt": "",
8 | "createdAt": "2020-04-15T05:27:33Z",
9 | "author": null,
10 | "labels": [],
11 | "number": "3",
12 | "state": "OPEN",
13 | "title": "Test3",
14 | "updatedAt": "2020-04-15T05:30:47Z",
15 | "url": "https://github.com/github-jira/demo-github/issues/3",
16 | "assignees": []
17 | }
18 | ]
19 | }
--------------------------------------------------------------------------------
/src/test/resources/test6/modules/module_test6/resources/Issue_data.json:
--------------------------------------------------------------------------------
1 | {
2 | "ballerinax/test6.module_test6:0.1.0:Issue": [
3 | {
4 | "id": "MDU6SXNzdWU2MDAwMzEyNDY=",
5 | "bodyText": "Test3",
6 | "closed": "false",
7 | "closedAt": "",
8 | "createdAt": "2020-04-15T05:27:33Z",
9 | "author": null,
10 | "labels": [],
11 | "number": "3",
12 | "state": "OPEN",
13 | "title": "Test3",
14 | "updatedAt": "2020-04-15T05:30:47Z",
15 | "url": "https://github.com/github-jira/demo-github/issues/3",
16 | "assignees": []
17 | }
18 | ]
19 | }
--------------------------------------------------------------------------------
/src/test/resources/test7/modules/module_test7/resources/Issue_data.json:
--------------------------------------------------------------------------------
1 | {
2 | "ballerinax/test7.module_test7:0.1.0:Issue": [
3 | {
4 | "id": "MDU6SXNzdWU2MDAwMzEyNDY=",
5 | "bodyText": "Test3",
6 | "closed": "false",
7 | "closedAt": "",
8 | "createdAt": "2020-04-15T05:27:33Z",
9 | "author": null,
10 | "labels": [],
11 | "number": "3",
12 | "state": "OPEN",
13 | "title": "Test3",
14 | "updatedAt": "2020-04-15T05:30:47Z",
15 | "url": "https://github.com/github-jira/demo-github/issues/3",
16 | "assignees": []
17 | }
18 | ]
19 | }
--------------------------------------------------------------------------------
/src/test/resources/test11/modules/module_test11/resources/Issue_data.json:
--------------------------------------------------------------------------------
1 | {
2 | "ballerinax/test11.module_test11:0.1.0:Issue": [
3 | {
4 | "id": "MDU6SXNzdWU2MDAwMzQwOTc=",
5 | "bodyText": "Test5",
6 | "closed": "false",
7 | "closedAt": "",
8 | "createdAt": "2020-04-15T05:36:03Z",
9 | "author": null,
10 | "labels": [],
11 | "number": "5",
12 | "state": "OPEN",
13 | "title": "Test5",
14 | "updatedAt": "2020-04-15T05:36:03Z",
15 | "url": "https://github.com/github-jira/demo-github/issues/5",
16 | "assignees": []
17 | }
18 | ]
19 | }
--------------------------------------------------------------------------------
/src/test/resources/test12/modules/module_test12/resources/Issue_data.json:
--------------------------------------------------------------------------------
1 | {
2 | "ballerinax/test12.module_test12:0.1.0:Issue": [
3 | {
4 | "id": "MDU6SXNzdWU2MDAwMzQwOTc=",
5 | "bodyText": "Test5",
6 | "closed": "false",
7 | "closedAt": "",
8 | "createdAt": "2020-04-15T05:36:03Z",
9 | "author": null,
10 | "labels": [],
11 | "number": "5",
12 | "state": "OPEN",
13 | "title": "Test5",
14 | "updatedAt": "2020-04-15T05:36:03Z",
15 | "url": "https://github.com/github-jira/demo-github/issues/5",
16 | "assignees": []
17 | }
18 | ]
19 | }
--------------------------------------------------------------------------------
/src/test/resources/test15/modules/module_test15/resources/Issue_data.json:
--------------------------------------------------------------------------------
1 | {
2 | "ballerinax/test15.module_test15:0.1.0:Issue": [
3 | {
4 | "id": "MDU6SXNzdWU2MDAwMzQwOTc=",
5 | "bodyText": "Test5",
6 | "closed": "false",
7 | "closedAt": "",
8 | "createdAt": "2020-04-15T05:36:03Z",
9 | "author": null,
10 | "labels": [],
11 | "number": "5",
12 | "state": "OPEN",
13 | "title": "Test5",
14 | "updatedAt": "2020-04-15T05:36:03Z",
15 | "url": "https://github.com/github-jira/demo-github/issues/5",
16 | "assignees": []
17 | }
18 | ]
19 | }
--------------------------------------------------------------------------------
/src/test/resources/test16.package/modules/module_test16/resources/Issue_data.json:
--------------------------------------------------------------------------------
1 | {
2 | "ballerinax/test16.package.module_test16:0.1.0:Issue": [
3 | {
4 | "id2": "MDU6SXNzdWU2MDAwMzQwOTc=",
5 | "bodyText2": "Test5",
6 | "closed11": "false",
7 | "closedAt": "",
8 | "createdAt": "2020-04-15T05:36:03Z",
9 | "author": null,
10 | "labels": [],
11 | "number": "5",
12 | "state": "OPEN",
13 | "title": "Test5",
14 | "updatedAt": "2020-04-15T05:36:03Z",
15 | "url": "https://github.com/github-jira/demo-github/issues/5",
16 | "assignees": []
17 | }
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/src/test/resources/test4/modules/module_test4/resources/Issue_data.json:
--------------------------------------------------------------------------------
1 | {
2 | "ballerinax/test4.module_test4:0.1.0:Issue": [
3 | {
4 | "id": "MDU6SXNzdWU2MDAwMzQwOTc=",
5 | "bodyText": "Test5",
6 | "closed": "false",
7 | "closedAt": "",
8 | "createdAt": "2020-04-15T05:36:03Z",
9 | "author": {
10 | "login": "github-jira",
11 | "resourcePath": "/github-jira",
12 | "url": "https://github.com/github-jira",
13 | "avatarUrl": "https://avatars1.githubusercontent.com/u/63409295?v=4"
14 | },
15 | "labels": [],
16 | "number": "5",
17 | "title": "Test5",
18 | "updatedAt": "2020-04-15T05:36:03Z",
19 | "url": "https://github.com/github-jira/demo-github/issues/5"
20 | }
21 | ]
22 | }
--------------------------------------------------------------------------------
/src/test/resources/test1/main.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public function main() {
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/resources/test10/main.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public function main() {
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/resources/test11/main.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public function main() {
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/resources/test12/main.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public function main() {
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/resources/test13/main.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public function main() {
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/resources/test14/main.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public function main() {
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/resources/test15/main.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public function main() {
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/resources/test17/main.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public function main() {
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/resources/test2/main.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public function main() {
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/resources/test3/main.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public function main() {
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/resources/test4/main.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public function main() {
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/resources/test5/main.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public function main() {
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/resources/test6/main.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public function main() {
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/resources/test7/main.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public function main() {
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/resources/test8/main.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public function main() {
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/resources/test9/main.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public function main() {
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/resources/test16.package/main.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public function main() {
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/resources/test3/modules/module_test3/resources/Issue_data.json:
--------------------------------------------------------------------------------
1 | {
2 | "ballerinax/test3.module_test3:0.1.0:Issue": [
3 | {
4 | "id": "MDU6SXNzdWU2MDAwMzQwOTc=",
5 | "bodyText": "Test5",
6 | "closed": "false",
7 | "closedAt": "",
8 | "createdAt": "2020-04-15T05:36:03Z",
9 | "author": {
10 | "login": "github-jira",
11 | "resourcePath": "/github-jira",
12 | "url": "https://github.com/github-jira",
13 | "avatarUrl": "https://avatars1.githubusercontent.com/u/63409295?v=4"
14 | },
15 | "labels": [],
16 | "number": "5",
17 | "title": "Test5",
18 | "updatedAt": "2020-04-15T05:36:03Z",
19 | "url": "https://github.com/github-jira/demo-github/issues/5",
20 | "assignees": []
21 | }
22 | ]
23 | }
--------------------------------------------------------------------------------
/issue_template.md:
--------------------------------------------------------------------------------
1 | **Description:**
2 |
3 |
4 | **Suggested Labels:**
5 |
6 |
7 | **Suggested Assignees:**
8 |
9 |
10 | **Affected Product Version:**
11 |
12 | **OS, DB, other environment details and versions:**
13 |
14 | **Steps to reproduce:**
15 |
16 |
17 | **Related Issues:**
18 |
--------------------------------------------------------------------------------
/src/test/resources/test15/connector_endpoint.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public client class Client {
18 | remote function createIssue() returns Issue|error {
19 | return {};
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/resources/test16.package/connector_endpoint.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public client class Client {
18 | remote function createIssue() returns Issue|error {
19 | return {};
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/resources/test1/modules/module_test1/connector_endpoint.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public client class Client {
18 | remote function createIssue() returns Issue|error {
19 | return {};
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/resources/test11/modules/module_test11/connector_endpoint.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public client class Client {
18 | remote function createIssue() returns string {
19 | return "";
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/resources/test12/modules/module_test12/connector_endpoint.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public client class Client {
18 | remote function createIssue() returns string {
19 | return "";
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/resources/test2/modules/module_test2/connector_endpoint.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public client class Client {
18 | remote function createIssue() returns Issue|error {
19 | return {};
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/resources/test3/modules/module_test3/connector_endpoint.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public client class Client {
18 | remote function createIssue() returns Issue|error {
19 | return {};
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/resources/test4/modules/module_test4/connector_endpoint.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public client class Client {
18 | remote function createIssue() returns Issue|error {
19 | return {};
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/resources/test5/modules/module_test5/connector_endpoint.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public client class Client {
18 | remote function createIssue() returns Issue|error {
19 | return {};
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/resources/test6/modules/module_test6/connector_endpoint.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public client class Client {
18 | remote function createIssue() returns Issue|error {
19 | return {};
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/resources/test7/modules/module_test7/connector_endpoint.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public client class Client {
18 | remote function createIssue() returns Issue|error {
19 | return {};
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/resources/test9/modules/module_test9/connector_endpoint.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public client class Client {
18 | remote function createIssue() returns Issue|error {
19 | return {};
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/resources/test10/modules/module_test10/connector_endpoint.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public client class Client {
18 | remote function createIssue() returns Issue|error {
19 | return {};
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/resources/test15/modules/module_test15/connector_endpoint.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public client class Client {
18 | remote function createIssue() returns Issue|error {
19 | return {};
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/resources/test17/modules/module_test17/connector_endpoint.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public client class Client {
18 | remote function createIssue() returns Issue|error {
19 | return {};
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/resources/test16.package/modules/module_test16/connector_endpoint.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public client class Client {
18 | remote function createIssue() returns Issue|error {
19 | return {};
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/.github/workflows/pull-request.yml:
--------------------------------------------------------------------------------
1 | name: PR build
2 |
3 | on:
4 | pull_request:
5 | push:
6 | branches-ignore:
7 | - master
8 | - "automated/dependency_version_update"
9 | - "automated/dependency_version_update_tmp"
10 | jobs:
11 | build:
12 | name: Build on Ubuntu
13 | runs-on: ubuntu-latest
14 |
15 | steps:
16 | - name: Checkout Repository
17 | uses: actions/checkout@v2
18 | - name: Set up JDK 17
19 | uses: actions/setup-java@v2
20 | with:
21 | distribution: 'adopt'
22 | java-version: '17.0.7'
23 | - name: Grant execute permission for gradlew
24 | run: chmod +x gradlew
25 | - name: Build with Gradle
26 | env:
27 | packageUser: ${{ github.actor }}
28 | packagePAT: ${{ secrets.GITHUB_TOKEN }}
29 | run: ./gradlew build
30 | - name: Generate Codecov Report
31 | uses: codecov/codecov-action@v2
32 |
--------------------------------------------------------------------------------
/src/test/resources/test18/main.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | type Product record {|
18 | int id?;
19 | string name;
20 | |};
21 |
22 | function sample(ClientClass cl) returns error? {
23 | int x = cl->query();
24 | }
25 |
26 | client class ClientClass {
27 | remote isolated function query() returns int => 1;
28 | }
29 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | plugins {
19 | id "com.gradle.enterprise" version "3.13.2"
20 | }
21 |
22 | rootProject.name = 'datamapper-extension'
23 | include(':build-config:checkstyle')
24 |
25 | gradleEnterprise {
26 | buildScan {
27 | termsOfServiceUrl = 'https://gradle.com/terms-of-service'
28 | termsOfServiceAgree = 'yes'
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/org/ballerinax/datamapper/exceptions/DataMapperException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.ballerinax.datamapper.exceptions;
20 |
21 | /**
22 | * Data Mapper Compiler Plugin's Exception class.
23 | */
24 | public class DataMapperException extends RuntimeException {
25 | public DataMapperException(Throwable throwable) {
26 | super(throwable);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/resources/test13/modules/module_test13/connector_endpoint.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public client class '\ \/\:\@\[\`\{\~_Connector {
18 | boolean action2Invoked = false;
19 |
20 | public function init(string param1, string param2, int param3) {
21 |
22 | }
23 |
24 | remote function '\ \/\:\@\[\`\{\~_Action() returns string {
25 | string 'sample_String_2 = "this ";
26 | return 'sample_String_2 ;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/resources/testng.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/test/resources/test10/modules/module_test10/resources/Issue_data.json:
--------------------------------------------------------------------------------
1 | {
2 | "ballerinax/test10.module_test10:0.1.0:Issue": [
3 | {
4 | "id": "MDU6SXNzdWU2MDAwMzQwOTc=",
5 | "bodyText": "Test5",
6 | "closed": "false",
7 | "closedAt": "",
8 | "createdAt": "2020-04-15T05:36:03Z",
9 | "author": null,
10 | "labels": [
11 | {
12 | "id": "label_id1",
13 | "name": "label_name1",
14 | "description": "label_description1",
15 | "color": "label_color1"
16 | },
17 | {
18 | "id": "label_id2",
19 | "name": "label_name2",
20 | "description": "label_description2",
21 | "color": "label_color2"
22 | }
23 | ],
24 | "number": "5",
25 | "state": "OPEN",
26 | "title": "Test5",
27 | "updatedAt": "2020-04-15T05:36:03Z",
28 | "url": "https://github.com/github-jira/demo-github/issues/5",
29 | "assignees": []
30 | }
31 | ]
32 | }
--------------------------------------------------------------------------------
/src/main/resources/datamapper.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | #
4 | # WSO2 Inc. licenses this file to you under the Apache License,
5 | # Version 2.0 (the "License"); you may not use this file except
6 | # in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 | #
18 |
19 | # ------------------------------------------
20 | # Data Mapper Compiler Plugin Error Messages
21 | # ------------------------------------------
22 |
23 | error.invalid.attribute.name=\
24 | type ''{0}'' does not have an attribute named ''{1}''
25 |
26 | error.invalid.attribute.count=\
27 | invalid attribute count: expected ''{0}'', found ''{1}''
28 |
29 | error.invalid.json.content=\
30 | invalid JSON content: ''{0}''
31 |
32 | error.invalid.json.token=\
33 | unexpected JSON token value ''{0}''
34 |
--------------------------------------------------------------------------------
/src/test/resources/test12/modules/module_test12/connector_types.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public type Assignee record {|
18 | string id = "";
19 | string login = "";
20 | string email = "";
21 | string? bio = "";
22 | string? url = "";
23 | |};
24 |
25 | public type Creator record {|
26 | string login = "";
27 | string? resourcePath = "";
28 | string? url = "";
29 | string? avatarUrl = "";
30 | |};
31 |
32 | public type Label record {|
33 | string id = "";
34 | string name = "";
35 | string? description = "";
36 | string? color = "";
37 | |};
38 |
--------------------------------------------------------------------------------
/src/main/java/org/ballerinax/datamapper/DataMapperCompilerPlugin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.ballerinax.datamapper;
20 |
21 | import io.ballerina.projects.plugins.CompilerPlugin;
22 | import io.ballerina.projects.plugins.CompilerPluginContext;
23 |
24 | /**
25 | * DataMapper Compiler plugin.
26 | *
27 | * @since 1.0.0
28 | */
29 | public class DataMapperCompilerPlugin extends CompilerPlugin {
30 | @Override
31 | public void init(CompilerPluginContext pluginContext) {
32 | pluginContext.addCodeAnalyzer(new DataMapperCodeAnalyzer());
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/ballerinax/datamapper/DataMapperCodeAnalyzer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.ballerinax.datamapper;
19 |
20 | import io.ballerina.projects.plugins.CodeAnalysisContext;
21 | import io.ballerina.projects.plugins.CodeAnalyzer;
22 |
23 | /**
24 | * A {@code CodeAnalyzer} implementation that registers a sample data validator.
25 | */
26 | public class DataMapperCodeAnalyzer extends CodeAnalyzer {
27 | @Override
28 | public void init(CodeAnalysisContext analysisContext) {
29 | analysisContext.addCompilationAnalysisTask(new SampleDataAnalysisTask());
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/.github/workflows/build-master.yml:
--------------------------------------------------------------------------------
1 | name: Build
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | workflow_dispatch:
8 |
9 | jobs:
10 | build:
11 | name: Build on Ubuntu
12 | runs-on: ubuntu-latest
13 |
14 | steps:
15 | - name: Checkout Repository
16 | uses: actions/checkout@v2
17 | - name: Set up JDK 17
18 | uses: actions/setup-java@v2
19 | with:
20 | distribution: 'adopt'
21 | java-version: '17.0.7'
22 | - name: Change to Timestamped Version
23 | run: |
24 | startTime=$(TZ="Asia/Kolkata" date +'%Y%m%d-%H%M00')
25 | latestCommit=$(git log -n 1 --pretty=format:"%h")
26 | VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | rev | cut --complement -d- -f1 | rev)
27 | updatedVersion=$VERSION-$startTime-$latestCommit
28 | echo $updatedVersion
29 | sed -i "s/version=\(.*\)/version=$updatedVersion/g" gradle.properties
30 | - name: Grant execute permission for gradlew
31 | run: chmod +x gradlew
32 | - name: Build and Publish with Gradle
33 | env:
34 | packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
35 | packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }}
36 | run: ./gradlew publish
37 | - name: Generate Codecov Report
38 | uses: codecov/codecov-action@v2
--------------------------------------------------------------------------------
/src/main/java/org/ballerinax/datamapper/FunctionRecord.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.ballerinax.datamapper;
20 |
21 | import java.util.ArrayList;
22 | import java.util.HashMap;
23 | import java.util.List;
24 |
25 | class FunctionRecord {
26 | private HashMap> parameters;
27 | private List returnTypes;
28 |
29 | public FunctionRecord() {
30 | parameters = new HashMap<>();
31 | returnTypes = new ArrayList<>();
32 | }
33 |
34 | public HashMap> getParameters() {
35 | return parameters;
36 | }
37 |
38 | public void addParameter(String name, List type) {
39 | this.parameters.put(name, type);
40 | }
41 |
42 | public List getReturnTypes() {
43 | return returnTypes;
44 | }
45 |
46 | public void addReturnType(String returnTypeName) {
47 | this.returnTypes.add(returnTypeName);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/test/resources/test15/connector_types.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public type Issue record {|
18 | string id = "";
19 | string? bodyText = "";
20 | string? closed = "";
21 | string? closedAt = "";
22 | string createdAt = "";
23 | Creator author = {};
24 | Label[] labels = [];
25 | int number = 0;
26 | string state = "";
27 | string title = "";
28 | string? updatedAt = "";
29 | string url = "";
30 | Assignee[] assignees = [];
31 | |};
32 |
33 | public type Assignee record {|
34 | string id = "";
35 | string login = "";
36 | string email = "";
37 | string? bio = "";
38 | string? url = "";
39 | |};
40 |
41 | public type Creator record {|
42 | string login = "";
43 | string? resourcePath = "";
44 | string? url = "";
45 | string? avatarUrl = "";
46 | |};
47 |
48 | public type Label record {|
49 | string id = "";
50 | string name = "";
51 | string? description = "";
52 | string? color = "";
53 | |};
54 |
--------------------------------------------------------------------------------
/src/test/resources/test16.package/connector_types.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public type Issue record {|
18 | string id = "";
19 | string? bodyText = "";
20 | string? closed = "";
21 | string? closedAt = "";
22 | string createdAt = "";
23 | Creator author = {};
24 | Label[] labels = [];
25 | int number = 0;
26 | string state = "";
27 | string title = "";
28 | string? updatedAt = "";
29 | string url = "";
30 | Assignee[] assignees = [];
31 | |};
32 |
33 | public type Assignee record {|
34 | string id = "";
35 | string login = "";
36 | string email = "";
37 | string? bio = "";
38 | string? url = "";
39 | |};
40 |
41 | public type Creator record {|
42 | string login = "";
43 | string? resourcePath = "";
44 | string? url = "";
45 | string? avatarUrl = "";
46 | |};
47 |
48 | public type Label record {|
49 | string id = "";
50 | string name = "";
51 | string? description = "";
52 | string? color = "";
53 | |};
54 |
--------------------------------------------------------------------------------
/src/test/resources/test1/modules/module_test1/connector_types.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public type Issue record {|
18 | string id = "";
19 | string? bodyText = "";
20 | string? closed = "";
21 | string? closedAt = "";
22 | string createdAt = "";
23 | Creator author = {};
24 | Label[] labels = [];
25 | int number = 0;
26 | string state = "";
27 | string title = "";
28 | string? updatedAt = "";
29 | string url = "";
30 | Assignee[] assignees = [];
31 | |};
32 |
33 | public type Assignee record {|
34 | string id = "";
35 | string login = "";
36 | string email = "";
37 | string? bio = "";
38 | string? url = "";
39 | |};
40 |
41 | public type Creator record {|
42 | string login = "";
43 | string? resourcePath = "";
44 | string? url = "";
45 | string? avatarUrl = "";
46 | |};
47 |
48 | public type Label record {|
49 | string id = "";
50 | string name = "";
51 | string? description = "";
52 | string? color = "";
53 | |};
54 |
--------------------------------------------------------------------------------
/src/test/resources/test10/modules/module_test10/connector_types.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public type Issue record {|
18 | string id = "";
19 | string? bodyText = "";
20 | string? closed = "";
21 | string? closedAt = "";
22 | string createdAt = "";
23 | Creator author = {};
24 | Label[] labels = [];
25 | int number = 0;
26 | string state = "";
27 | string title = "";
28 | string? updatedAt = "";
29 | string url = "";
30 | Assignee[] assignees = [];
31 | |};
32 |
33 | public type Assignee record {|
34 | string id = "";
35 | string login = "";
36 | string email = "";
37 | string? bio = "";
38 | string? url = "";
39 | |};
40 |
41 | public type Creator record {|
42 | string login = "";
43 | string? resourcePath = "";
44 | string? url = "";
45 | string? avatarUrl = "";
46 | |};
47 |
48 | public type Label record {|
49 | string id = "";
50 | string name = "";
51 | string? description = "";
52 | string? color = "";
53 | |};
54 |
--------------------------------------------------------------------------------
/src/test/resources/test11/modules/module_test11/connector_types.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public type Issue record {|
18 | string id = "";
19 | string? bodyText = "";
20 | string? closed = "";
21 | string? closedAt = "";
22 | string createdAt = "";
23 | Creator author = {};
24 | Label[] labels = [];
25 | int number = 0;
26 | string state = "";
27 | string title = "";
28 | string? updatedAt = "";
29 | string url = "";
30 | Assignee[] assignees = [];
31 | |};
32 |
33 | public type Assignee record {|
34 | string id = "";
35 | string login = "";
36 | string email = "";
37 | string? bio = "";
38 | string? url = "";
39 | |};
40 |
41 | public type Creator record {|
42 | string login = "";
43 | string? resourcePath = "";
44 | string? url = "";
45 | string? avatarUrl = "";
46 | |};
47 |
48 | public type Label record {|
49 | string id = "";
50 | string name = "";
51 | string? description = "";
52 | string? color = "";
53 | |};
54 |
--------------------------------------------------------------------------------
/src/test/resources/test15/modules/module_test15/connector_types.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public type Issue record {|
18 | string id = "";
19 | string? bodyText = "";
20 | string? closed = "";
21 | string? closedAt = "";
22 | string createdAt = "";
23 | Creator author = {};
24 | Label[] labels = [];
25 | int number = 0;
26 | string state = "";
27 | string title = "";
28 | string? updatedAt = "";
29 | string url = "";
30 | Assignee[] assignees = [];
31 | |};
32 |
33 | public type Assignee record {|
34 | string id = "";
35 | string login = "";
36 | string email = "";
37 | string? bio = "";
38 | string? url = "";
39 | |};
40 |
41 | public type Creator record {|
42 | string login = "";
43 | string? resourcePath = "";
44 | string? url = "";
45 | string? avatarUrl = "";
46 | |};
47 |
48 | public type Label record {|
49 | string id = "";
50 | string name = "";
51 | string? description = "";
52 | string? color = "";
53 | |};
54 |
--------------------------------------------------------------------------------
/src/test/resources/test17/modules/module_test17/connector_types.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public type Issue record {|
18 | string id = "";
19 | string? bodyText = "";
20 | string? closed = "";
21 | string? closedAt = "";
22 | string createdAt = "";
23 | Creator author = {};
24 | Label[] labels = [];
25 | int number = 0;
26 | string state = "";
27 | string title = "";
28 | string? updatedAt = "";
29 | string url = "";
30 | Assignee[] assignees = [];
31 | |};
32 |
33 | public type Assignee record {|
34 | string id = "";
35 | string login = "";
36 | string email = "";
37 | string? bio = "";
38 | string? url = "";
39 | |};
40 |
41 | public type Creator record {|
42 | string login = "";
43 | string? resourcePath = "";
44 | string? url = "";
45 | string? avatarUrl = "";
46 | |};
47 |
48 | public type Label record {|
49 | string id = "";
50 | string name = "";
51 | string? description = "";
52 | string? color = "";
53 | |};
54 |
--------------------------------------------------------------------------------
/src/test/resources/test2/modules/module_test2/connector_types.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public type Issue record {|
18 | string id = "";
19 | string? bodyText = "";
20 | string? closed = "";
21 | string? closedAt = "";
22 | string createdAt = "";
23 | Creator author = {};
24 | Label[] labels = [];
25 | int number = 0;
26 | string state = "";
27 | string title = "";
28 | string? updatedAt = "";
29 | string url = "";
30 | Assignee[] assignees = [];
31 | |};
32 |
33 | public type Assignee record {|
34 | string id = "";
35 | string login = "";
36 | string email = "";
37 | string? bio = "";
38 | string? url = "";
39 | |};
40 |
41 | public type Creator record {|
42 | string login = "";
43 | string? resourcePath = "";
44 | string? url = "";
45 | string? avatarUrl = "";
46 | |};
47 |
48 | public type Label record {|
49 | string id = "";
50 | string name = "";
51 | string? description = "";
52 | string? color = "";
53 | |};
54 |
--------------------------------------------------------------------------------
/src/test/resources/test3/modules/module_test3/connector_types.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public type Issue record {|
18 | string id = "";
19 | string? bodyText = "";
20 | string? closed = "";
21 | string? closedAt = "";
22 | string createdAt = "";
23 | Creator author = {};
24 | Label[] labels = [];
25 | int number = 0;
26 | string state = "";
27 | string title = "";
28 | string? updatedAt = "";
29 | string url = "";
30 | Assignee[] assignees = [];
31 | |};
32 |
33 | public type Assignee record {|
34 | string id = "";
35 | string login = "";
36 | string email = "";
37 | string? bio = "";
38 | string? url = "";
39 | |};
40 |
41 | public type Creator record {|
42 | string login = "";
43 | string? resourcePath = "";
44 | string? url = "";
45 | string? avatarUrl = "";
46 | |};
47 |
48 | public type Label record {|
49 | string id = "";
50 | string name = "";
51 | string? description = "";
52 | string? color = "";
53 | |};
54 |
--------------------------------------------------------------------------------
/src/test/resources/test4/modules/module_test4/connector_types.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public type Issue record {|
18 | string id = "";
19 | string? bodyText = "";
20 | string? closed = "";
21 | string? closedAt = "";
22 | string createdAt = "";
23 | Creator author = {};
24 | Label[] labels = [];
25 | int number = 0;
26 | string state = "";
27 | string title = "";
28 | string? updatedAt = "";
29 | string url = "";
30 | Assignee[] assignees = [];
31 | |};
32 |
33 | public type Assignee record {|
34 | string id = "";
35 | string login = "";
36 | string email = "";
37 | string? bio = "";
38 | string? url = "";
39 | |};
40 |
41 | public type Creator record {|
42 | string login = "";
43 | string? resourcePath = "";
44 | string? url = "";
45 | string? avatarUrl = "";
46 | |};
47 |
48 | public type Label record {|
49 | string id = "";
50 | string name = "";
51 | string? description = "";
52 | string? color = "";
53 | |};
54 |
--------------------------------------------------------------------------------
/src/test/resources/test5/modules/module_test5/connector_types.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public type Issue record {|
18 | string id = "";
19 | string? bodyText = "";
20 | string? closed = "";
21 | string? closedAt = "";
22 | string createdAt = "";
23 | Creator author = {};
24 | Label[] labels = [];
25 | int number = 0;
26 | string state = "";
27 | string title = "";
28 | string? updatedAt = "";
29 | string url = "";
30 | Assignee[] assignees = [];
31 | |};
32 |
33 | public type Assignee record {|
34 | string id = "";
35 | string login = "";
36 | string email = "";
37 | string? bio = "";
38 | string? url = "";
39 | |};
40 |
41 | public type Creator record {|
42 | string login = "";
43 | string? resourcePath = "";
44 | string? url = "";
45 | string? avatarUrl = "";
46 | |};
47 |
48 | public type Label record {|
49 | string id = "";
50 | string name = "";
51 | string? description = "";
52 | string? color = "";
53 | |};
54 |
--------------------------------------------------------------------------------
/src/test/resources/test6/modules/module_test6/connector_types.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public type Issue record {|
18 | string id = "";
19 | string? bodyText = "";
20 | string? closed = "";
21 | string? closedAt = "";
22 | string createdAt = "";
23 | Creator author = {};
24 | Label[] labels = [];
25 | int number = 0;
26 | string state = "";
27 | string title = "";
28 | string? updatedAt = "";
29 | string url = "";
30 | Assignee[] assignees = [];
31 | |};
32 |
33 | public type Assignee record {|
34 | string id = "";
35 | string login = "";
36 | string email = "";
37 | string? bio = "";
38 | string? url = "";
39 | |};
40 |
41 | public type Creator record {|
42 | string login = "";
43 | string? resourcePath = "";
44 | string? url = "";
45 | string? avatarUrl = "";
46 | |};
47 |
48 | public type Label record {|
49 | string id = "";
50 | string name = "";
51 | string? description = "";
52 | string? color = "";
53 | |};
54 |
--------------------------------------------------------------------------------
/src/test/resources/test7/modules/module_test7/connector_types.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public type Issue record {|
18 | string id = "";
19 | string? bodyText = "";
20 | string? closed = "";
21 | string? closedAt = "";
22 | string createdAt = "";
23 | Creator author = {};
24 | Label[] labels = [];
25 | int number = 0;
26 | string state = "";
27 | string title = "";
28 | string? updatedAt = "";
29 | string url = "";
30 | Assignee[] assignees = [];
31 | |};
32 |
33 | public type Assignee record {|
34 | string id = "";
35 | string login = "";
36 | string email = "";
37 | string? bio = "";
38 | string? url = "";
39 | |};
40 |
41 | public type Creator record {|
42 | string login = "";
43 | string? resourcePath = "";
44 | string? url = "";
45 | string? avatarUrl = "";
46 | |};
47 |
48 | public type Label record {|
49 | string id = "";
50 | string name = "";
51 | string? description = "";
52 | string? color = "";
53 | |};
54 |
--------------------------------------------------------------------------------
/src/test/resources/test9/modules/module_test9/connector_types.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public type Issue record {|
18 | string id = "";
19 | string? bodyText = "";
20 | string? closed = "";
21 | string? closedAt = "";
22 | string createdAt = "";
23 | Creator author = {};
24 | Label[] labels = [];
25 | int number = 0;
26 | string state = "";
27 | string title = "";
28 | string? updatedAt = "";
29 | string url = "";
30 | Assignee[] assignees = [];
31 | |};
32 |
33 | public type Assignee record {|
34 | string id = "";
35 | string login = "";
36 | string email = "";
37 | string? bio = "";
38 | string? url = "";
39 | |};
40 |
41 | public type Creator record {|
42 | string login = "";
43 | string? resourcePath = "";
44 | string? url = "";
45 | string? avatarUrl = "";
46 | |};
47 |
48 | public type Label record {|
49 | string id = "";
50 | string name = "";
51 | string? description = "";
52 | string? color = "";
53 | |};
54 |
--------------------------------------------------------------------------------
/src/test/resources/test16.package/modules/module_test16/connector_types.bal:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
2 | //
3 | // WSO2 Inc. licenses this file to you under the Apache License,
4 | // Version 2.0 (the "License"); you may not use this file except
5 | // in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing,
11 | // software distributed under the License is distributed on an
12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 | // KIND, either express or implied. See the License for the
14 | // specific language governing permissions and limitations
15 | // under the License.
16 |
17 | public type Issue record {|
18 | string id = "";
19 | string? bodyText = "";
20 | string? closed = "";
21 | string? closedAt = "";
22 | string createdAt = "";
23 | Creator author = {};
24 | Label[] labels = [];
25 | int number = 0;
26 | string state = "";
27 | string title = "";
28 | string? updatedAt = "";
29 | string url = "";
30 | Assignee[] assignees = [];
31 | |};
32 |
33 | public type Assignee record {|
34 | string id = "";
35 | string login = "";
36 | string email = "";
37 | string? bio = "";
38 | string? url = "";
39 | |};
40 |
41 | public type Creator record {|
42 | string login = "";
43 | string? resourcePath = "";
44 | string? url = "";
45 | string? avatarUrl = "";
46 | |};
47 |
48 | public type Label record {|
49 | string id = "";
50 | string name = "";
51 | string? description = "";
52 | string? color = "";
53 | |};
54 |
--------------------------------------------------------------------------------
/src/main/java/org/ballerinax/datamapper/util/Utils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.ballerinax.datamapper.util;
20 |
21 | import java.io.File;
22 | import java.io.IOException;
23 | import java.nio.charset.StandardCharsets;
24 | import java.nio.file.Files;
25 | import java.nio.file.Path;
26 | import java.nio.file.StandardOpenOption;
27 |
28 | /**
29 | * Utilities class.
30 | */
31 | public class Utils {
32 | public static void writeToFile(String content, Path targetFilePath) throws IOException {
33 | File newFile = targetFilePath.toFile();
34 |
35 | if (newFile.exists()) {
36 | Files.write(targetFilePath, content.getBytes(StandardCharsets.UTF_8), StandardOpenOption.TRUNCATE_EXISTING);
37 | return;
38 | }
39 |
40 | if (newFile.getParentFile().mkdirs()) {
41 | Files.write(targetFilePath, content.getBytes(StandardCharsets.UTF_8));
42 | return;
43 | }
44 | Files.write(targetFilePath, content.getBytes(StandardCharsets.UTF_8));
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/test/resources/test2/modules/module_test2/resources/Issue_data.json:
--------------------------------------------------------------------------------
1 | {
2 | "ballerinax/test2.module_test2:0.1.0:Issue": [
3 | {
4 | "id2": "MDU6SXNzdWU2MDAwMzQwOTc=",
5 | "bodyText": "Test5",
6 | "closed": "false",
7 | "closedAt": "",
8 | "createdAt": "2020-04-15T05:36:03Z",
9 | "author": {
10 | "login": "github-jira",
11 | "resourcePath5": "/github-jira",
12 | "url": "https://github.com/github-jira",
13 | "avatarUrl": "https://avatars1.githubusercontent.com/u/63409295?v=4"
14 | },
15 | "labels": [],
16 | "number": "5",
17 | "state": "OPEN",
18 | "title": "Test5",
19 | "updatedAt": "2020-04-15T05:36:03Z",
20 | "url": "https://github.com/github-jira/demo-github/issues/5",
21 | "assignees": []
22 | },
23 | {
24 | "id": "MDU6SXNzdWU2MDAwMzEyNDY=",
25 | "bodyText3": "Test3",
26 | "closed": "false",
27 | "closedAt": "",
28 | "createdAt": "2020-04-15T05:27:33Z",
29 | "author": {
30 | "login": "github-jira2",
31 | "resourcePath": "/github-jira2",
32 | "url": "https://github.com/github-jira",
33 | "avatarUrl": "https://avatars1.githubusercontent.com/u/63409295?v=4"
34 | },
35 | "labels": [],
36 | "number": "3",
37 | "state": "OPEN",
38 | "title": "Test3",
39 | "updatedAt": "2020-04-15T05:30:47Z",
40 | "url": "https://github.com/github-jira/demo-github/issues/3",
41 | "assignees": []
42 | }
43 | ]
44 | }
--------------------------------------------------------------------------------
/src/test/resources/logging.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | #
4 | # WSO2 Inc. licenses this file to you under the Apache License,
5 | # Version 2.0 (the "License"); you may not use this file except
6 | # in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 | #
18 |
19 | ####################### HANDLERS #######################
20 | # Configurations for console logging
21 | java.util.logging.ConsoleHandler.level=ALL
22 | java.util.logging.ConsoleHandler.formatter=org.ballerinalang.logging.formatters.BallerinaLogFormatter
23 | org.ballerinalang.logging.formatters.BallerinaLogFormatter.format=%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS,%1$tL %2$s [%3$s] - %4$s %n
24 |
25 | org.ballerinalang.test.utils.TestLogHandler.level=SEVERE
26 | org.ballerinalang.test.utils.TestLogHandler.formatter=org.ballerinalang.logging.formatters.DefaultLogFormatter
27 | org.ballerinalang.logging.formatters.DefaultLogFormatter.format=[%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS,%1$tL] %2$s [%3$s] - %4$s %5$s %n
28 |
29 | ####################### LOGGERS #######################
30 | # Ballerina user level root logger
31 | ballerina.handlers=java.util.logging.ConsoleHandler
32 | ballerina.level=ALL
33 | ballerina.useParentHandlers=false
34 |
35 | # JUL root logger
36 | .handlers=java.util.logging.ConsoleHandler
37 | .level=SEVERE
38 |
39 | com.zaxxer.hikari.level=SEVERE
40 | org.quartz.level=SEVERE
--------------------------------------------------------------------------------
/src/main/java/org/ballerinax/datamapper/diagnostic/DiagnosticErrorCode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.ballerinax.datamapper.diagnostic;
20 |
21 | import io.ballerina.tools.diagnostics.DiagnosticCode;
22 | import io.ballerina.tools.diagnostics.DiagnosticSeverity;
23 |
24 | /**
25 | * Diagnostic Error Codes for Compiler Extension.
26 | */
27 | public enum DiagnosticErrorCode implements DiagnosticCode {
28 | ERROR_INVALID_ATTRIBUTE_NAME("DME0001", "invalid.attribute.name"),
29 | ERROR_INVALID_ATTRIBUTE_COUNT("DME0002", "invalid.attribute.count"),
30 | ERROR_INVALID_JSON_CONTENT("DME0003", "invalid.json.content"),
31 | ERROR_INVALID_JSON_TOKEN("DME0004", "invalid.json.token");
32 |
33 | private String diagnosticId;
34 | private String messageKey;
35 |
36 | DiagnosticErrorCode(String diagnosticId, String messageKey) {
37 | this.diagnosticId = diagnosticId;
38 | this.messageKey = messageKey;
39 | }
40 |
41 | @Override
42 | public DiagnosticSeverity severity() {
43 | return DiagnosticSeverity.ERROR;
44 | }
45 |
46 | @Override
47 | public String diagnosticId() {
48 | return this.diagnosticId;
49 | }
50 |
51 | @Override
52 | public String messageKey() {
53 | return this.messageKey;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/org/ballerinax/datamapper/diagnostic/DataMapperDiagnosticLog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.ballerinax.datamapper.diagnostic;
20 |
21 | import io.ballerina.tools.diagnostics.Diagnostic;
22 | import io.ballerina.tools.diagnostics.DiagnosticCode;
23 | import io.ballerina.tools.diagnostics.DiagnosticFactory;
24 | import io.ballerina.tools.diagnostics.DiagnosticInfo;
25 | import io.ballerina.tools.diagnostics.Location;
26 |
27 | import java.text.MessageFormat;
28 | import java.util.ArrayList;
29 | import java.util.List;
30 | import java.util.Locale;
31 | import java.util.ResourceBundle;
32 |
33 | /**
34 | * Diagnostic log for Data Mapper Compiler Extension.
35 | */
36 | public class DataMapperDiagnosticLog {
37 |
38 | private static final ResourceBundle MESSAGES = ResourceBundle.getBundle("datamapper", Locale.getDefault());
39 | private static final String ERROR_PREFIX = "error";
40 |
41 | public List getDataMapperPluginDiagnostic() {
42 | return dataMapperPluginDiagnostic;
43 | }
44 |
45 | private List dataMapperPluginDiagnostic;
46 |
47 | public DataMapperDiagnosticLog() {
48 | this.dataMapperPluginDiagnostic = new ArrayList<>();
49 | }
50 |
51 | public void addDiagnostics(Location position, DiagnosticErrorCode diagnosticErrorCode, Object... args) {
52 | String msg = formatMessage(ERROR_PREFIX, diagnosticErrorCode, args);
53 | DiagnosticInfo diagnosticInfo = new DiagnosticInfo(
54 | diagnosticErrorCode.diagnosticId(), msg,
55 | diagnosticErrorCode.severity());
56 |
57 | dataMapperPluginDiagnostic.add(DiagnosticFactory.createDiagnostic(diagnosticInfo, position));
58 | }
59 |
60 | private String formatMessage(String prefix, DiagnosticCode code, Object[] args) {
61 | String msgKey = MESSAGES.getString(prefix + "." + code.messageKey());
62 | return MessageFormat.format(msgKey, args);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/pull_request_template.md:
--------------------------------------------------------------------------------
1 | ## Purpose
2 | > Describe the problems, issues, or needs driving this feature/fix and include links to related issues in the following format: Resolves issue1, issue2, etc.
3 |
4 | ## Goals
5 | > Describe the solutions that this feature/fix will introduce to resolve the problems described above
6 |
7 | ## Approach
8 | > Describe how you are implementing the solutions. Include an animated GIF or screenshot if the change affects the UI (email documentation@wso2.com to review all UI text). Include a link to a Markdown file or Google doc if the feature write-up is too long to paste here.
9 |
10 | ## User stories
11 | > Summary of user stories addressed by this change>
12 |
13 | ## Release note
14 | > Brief description of the new feature or bug fix as it will appear in the release notes
15 |
16 | ## Documentation
17 | > Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter “N/A” plus brief explanation of why there’s no doc impact
18 |
19 | ## Training
20 | > Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable
21 |
22 | ## Certification
23 | > Type “Sent” when you have provided new/updated certification questions, plus four answers for each question (correct answer highlighted in bold), based on this change. Certification questions/answers should be sent to certification@wso2.com and NOT pasted in this PR. If there is no impact on certification exams, type “N/A” and explain why.
24 |
25 | ## Marketing
26 | > Link to drafts of marketing content that will describe and promote this feature, including product page changes, technical articles, blog posts, videos, etc., if applicable
27 |
28 | ## Automation tests
29 | - Unit tests
30 | > Code coverage information
31 | - Integration tests
32 | > Details about the test cases and coverage
33 |
34 | ## Security checks
35 | - Followed secure coding standards in http://wso2.com/technical-reports/wso2-secure-engineering-guidelines? yes/no
36 | - Ran FindSecurityBugs plugin and verified report? yes/no
37 | - Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets? yes/no
38 |
39 | ## Samples
40 | > Provide high-level details about the samples related to this feature
41 |
42 | ## Related PRs
43 | > List any other related PRs
44 |
45 | ## Migrations (if applicable)
46 | > Describe migration steps and platforms on which migration has been tested
47 |
48 | ## Test environment
49 | > List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested
50 |
51 | ## Learning
52 | > Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem.
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | @rem This is normally unused
30 | set APP_BASE_NAME=%~n0
31 | set APP_HOME=%DIRNAME%
32 |
33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35 |
36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38 |
39 | @rem Find java.exe
40 | if defined JAVA_HOME goto findJavaFromJavaHome
41 |
42 | set JAVA_EXE=java.exe
43 | %JAVA_EXE% -version >NUL 2>&1
44 | if %ERRORLEVEL% equ 0 goto execute
45 |
46 | echo.
47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48 | echo.
49 | echo Please set the JAVA_HOME variable in your environment to match the
50 | echo location of your Java installation.
51 |
52 | goto fail
53 |
54 | :findJavaFromJavaHome
55 | set JAVA_HOME=%JAVA_HOME:"=%
56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57 |
58 | if exist "%JAVA_EXE%" goto execute
59 |
60 | echo.
61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62 | echo.
63 | echo Please set the JAVA_HOME variable in your environment to match the
64 | echo location of your Java installation.
65 |
66 | goto fail
67 |
68 | :execute
69 | @rem Setup the command line
70 |
71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72 |
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if %ERRORLEVEL% equ 0 goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | set EXIT_CODE=%ERRORLEVEL%
85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87 | exit /b %EXIT_CODE%
88 |
89 | :mainEnd
90 | if "%OS%"=="Windows_NT" endlocal
91 |
92 | :omega
93 |
--------------------------------------------------------------------------------
/.github/workflows/publish-release.yml:
--------------------------------------------------------------------------------
1 | name: Publish release
2 |
3 | on:
4 | workflow_dispatch:
5 |
6 | jobs:
7 | publish-release:
8 | runs-on: ubuntu-latest
9 | if: github.repository_owner == 'ballerina-platform'
10 | steps:
11 | - name: Checkout Repository
12 | uses: actions/checkout@v2
13 | - name: Set up JDK 17
14 | uses: actions/setup-java@v2
15 | with:
16 | distribution: 'adopt'
17 | java-version: '17.0.7'
18 | - name: Set version env variable
19 | run: echo "VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | rev | cut --complement -d- -f1 | rev)" >> $GITHUB_ENV
20 | - name: Pre release depenency version update
21 | env:
22 | GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
23 | run: |
24 | echo "Version: ${VERSION}"
25 | git config user.name ${{ secrets.BALLERINA_BOT_USERNAME }}
26 | git config user.email ${{ secrets.BALLERINA_BOT_EMAIL }}
27 | git checkout -b release-${VERSION}
28 | sed -i 's/ballerinaLangVersion=\(.*\)-SNAPSHOT/ballerinaLangVersion=\1/g' gradle.properties
29 | sed -i 's/ballerinaLangVersion=\(.*\)-[0-9]\{8\}-[0-9]\{6\}-.*$/ballerinaLangVersion=\1/g' gradle.properties
30 | sed -i 's/observe\(.*\)=\(.*\)-SNAPSHOT/observe\1=\2/g' gradle.properties
31 | sed -i 's/observe\(.*\)=\(.*\)-[0-9]\{8\}-[0-9]\{6\}-.*$/observe\1=\2/g' gradle.properties
32 | sed -i 's/stdlib\(.*\)=\(.*\)-SNAPSHOT/stdlib\1=\2/g' gradle.properties
33 | sed -i 's/stdlib\(.*\)=\(.*\)-[0-9]\{8\}-[0-9]\{6\}-.*$/stdlib\1=\2/g' gradle.properties
34 | git add gradle.properties
35 | git commit -m "Move dependencies to stable version" || echo "No changes to commit"
36 | - name: Grant execute permission for gradlew
37 | run: chmod +x gradlew
38 | - name: Publish artifact
39 | env:
40 | GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
41 | BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_ACCESS_TOKEN }}
42 | packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
43 | packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }}
44 | run: |
45 | ./gradlew release -Prelease.useAutomaticVersion=true
46 | ./gradlew -Pversion=${VERSION} publish -x test
47 | - name: Create Github release from the release tag
48 | run: |
49 | curl --request POST 'https://api.github.com/repos/ballerina-platform/module-ballerinax-datamapper/releases' \
50 | --header 'Accept: application/vnd.github.v3+json' \
51 | --header 'Authorization: Bearer ${{ secrets.BALLERINA_BOT_TOKEN }}' \
52 | --header 'Content-Type: application/json' \
53 | --data-raw '{
54 | "tag_name": "v'"$VERSION"'",
55 | "name": "module-ballerinax-datamapper-v'"$VERSION"'"
56 | }'
57 | - name: Post release PR
58 | env:
59 | GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
60 | run: |
61 | curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
62 | bin/hub pull-request -m "[Automated] Sync master after "$VERSION" release"
63 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://github.com/ballerina-platform/module-ballerinax-datamapper/actions?query=workflow%3ABuild)
2 | [](https://github.com/ballerina-platform/module-ballerinax-datamapper/actions?query=workflow%3A%22Daily+build%22)
3 | [](https://codecov.io/gh/ballerina-platform/module-ballerinax-datamapper)
4 |
5 | # Ballerina Data Mapper Extension
6 | The Ballerina Data Mapper extension is a compiler extension, which extracts an abstract representation of Ballerina connector actions and the associated types.
7 | This compiler extension gets executed when compiling a Ballerina connector project. The extension generates two types of files by default. Note that
8 | these two types of files get automatically extracted from connectors. Hence, the developer does not need to write them.
9 |
10 | ## Functions File
11 | These files are named as ``_functions.json`` in which the `CLIENT_NAME` corresponds to the connector client name.
12 | When there are ``n`` number of clients existing in a connector, a ``n`` number of functions files will get created. Functions files get created only if there
13 | are client objects with remote function calls. These files can be used to identify the list of connector actions available in a
14 | particular connector as well as to identify what types of records are used as input parameters and return types.
15 |
16 | ## Schema File
17 | These files are named as ``_schema.json`` in which the `RECORD_NAME` corresponds to a record type defined
18 | within the connector module. In order for a schema file to be generated for a record type defined within a connector module, the
19 | record has to be one of the following,
20 |
21 | 1. An input parameter or a return type from a connector action.
22 | 2. A record type referred by a record, which falls into the first category.
23 |
24 | In addition to the above two types of JSON file categories, which get automatically extracted from a connector by default,
25 | the connector developer can also specify sample data in the `_data.json` files. Note that the use
26 | of the term schema here does not correspond to [JSON Schema](https://json-schema.org/learn/miscellaneous-examples.html).
27 |
28 | ## Data File
29 | Data files have to follow the structure given below.
30 |
31 | ```
32 | {
33 | "/::": [
34 | ,
35 | ,
36 | ,
37 | ...,
38 |
39 | ]
40 | }
41 | ```
42 | The `` should have a structure as follows in which the JSON
43 | instance has `M` number of attributes.
44 |
45 | ```
46 | {
47 | "" : "",
48 | "" : "",
49 | "" : "",
50 | ...,
51 | "" : ""
52 | }
53 | ```
54 |
55 | An `` can be a simple literal (string/numeric value),
56 | ``, an array, or `null`.
57 |
58 | Unlike functions files and schema files, which automatically get extracted
59 | from the Ballerina Abstract Syntax Tree (AST), data files are user-specified JSON files.
60 | Hence, the Data Mapper compiler extension conducts a validation of the content of the data JSON files.
61 | The validation process checks whether the data JSON file's attribute names are equivalent to the
62 | attribute names used in their corresponding types. Furthermore, it checks whether the same number
63 | of attributes exist between the record type and its corresponding data JSON file. In addition to these
64 | validations, the compiler extension also extracts sample data nested within a particular data JSON
65 | to separate top-level data JSON files.
66 |
67 | The extracted JSON files get written to the resources directory within the connector module's folder. However, the functions and schema JSON files are not required to be committed to a
68 | Github repository since they get generated automatically from the connector's Ballerina code. However,
69 | the data files need to be version controlled.
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/gradle/javaProject.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "java"
2 | apply plugin: "com.github.spotbugs"
3 | apply plugin: "checkstyle"
4 | apply plugin: 'maven-publish'
5 | apply plugin: 'jacoco'
6 |
7 | tasks.withType(JavaCompile) {
8 | options.encoding = 'UTF-8'
9 | }
10 |
11 | sourceCompatibility = JavaVersion.VERSION_17
12 |
13 | configurations {
14 | bDistributionDir
15 | balTools
16 | jacocoRuntime
17 | }
18 |
19 | dependencies {
20 | jacocoRuntime "org.jacoco:org.jacoco.agent:0.8.10:runtime"
21 |
22 | implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.15.2'
23 | implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.15.2'
24 | implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.15.2'
25 | implementation group: 'org.ballerinalang', name: 'ballerina-lang', version: "${ballerinaLangVersion}"
26 | implementation group: 'org.ballerinalang', name: 'ballerina-test-utils', version: "${ballerinaLangVersion}"
27 | implementation group: 'org.ballerinalang', name: 'ballerina-tools-api', version: "${ballerinaLangVersion}"
28 | implementation group: 'org.ballerinalang', name: 'ballerina-parser', version: "${ballerinaLangVersion}"
29 | testImplementation 'org.testng:testng:7.6.1'
30 |
31 | checkstyle project(":build-config:checkstyle")
32 | checkstyle "com.puppycrawl.tools:checkstyle:${puppycrawlCheckstyleVersion}"
33 | balTools("org.ballerinalang:jballerina-tools:${ballerinaLangVersion}") {
34 | transitive = false
35 | }
36 | }
37 |
38 | def bDistribution = file("$project.buildDir/extracted-distribution/jballerina-tools-${ballerinaLangVersion}")
39 | def packageOrg = "ballerina"
40 |
41 | task unzip {
42 | doLast {
43 | configurations.balTools.resolvedConfiguration.resolvedArtifacts.each { artifact ->
44 | copy {
45 | from project.zipTree(artifact.getFile())
46 | into new File(project.buildDir, "extracted-distribution/")
47 | }
48 | }
49 | }
50 | outputs.dir bDistribution
51 | }
52 |
53 | task unpackStdLibs() {
54 | dependsOn unzip
55 | doLast {
56 | configurations.ballerinaStdLibs.resolvedConfiguration.resolvedArtifacts.each { artifact ->
57 | copy {
58 | from project.zipTree(artifact.getFile())
59 | into new File("${project.buildDir}/extracted-distribution", artifact.name + "-zip")
60 | }
61 | }
62 | }
63 | }
64 |
65 | task copyStdlibs(type: Copy) {
66 | dependsOn unpackStdLibs
67 | into bDistribution
68 | duplicatesStrategy = 'include'
69 |
70 | /* Standard Libraries */
71 | configurations.ballerinaStdLibs.resolvedConfiguration.resolvedArtifacts.each { artifact ->
72 | def artifactExtractedPath = "${project.buildDir}/extracted-distribution/" + artifact.name + "-zip"
73 | into("bir-cache/") {
74 | from "${artifactExtractedPath}/caches/bir"
75 | }
76 | into("bre/lib/") {
77 | from "${artifactExtractedPath}/libs"
78 | }
79 | into("docs/") {
80 | from "${artifactExtractedPath}/docs"
81 | }
82 | // pack to new cache
83 | into("cache/bir/") {
84 | from "${artifactExtractedPath}/caches/bir"
85 | }
86 | into("cache/bala/") {
87 | from "${artifactExtractedPath}/caches/bala"
88 | }
89 | into("cache/jar/") {
90 | from "${artifactExtractedPath}/caches/jar"
91 | }
92 | into("repo/bala") {
93 | from "${artifactExtractedPath}/bala/"
94 | }
95 | }
96 | }
97 |
98 | task copyLib(type: Copy) {
99 | dependsOn unzip
100 | dependsOn jar
101 | into("${bDistribution}/bre/lib/")
102 | from "${project.buildDir}/libs"
103 | }
104 |
105 | test {
106 | dependsOn copyStdlibs
107 | dependsOn copyLib
108 | systemProperty "java.util.logging.config.file", "src/test/resources/logging.properties"
109 | systemProperty "ballerina.home", "$bDistribution.absolutePath"
110 |
111 | useTestNG() {
112 | suites 'src/test/resources/testng.xml'
113 | }
114 |
115 | afterSuite { suite, result ->
116 | result.exception?.printStackTrace()
117 | }
118 |
119 | testLogging {
120 | // this will only change --warn flag behaviour
121 | warn {
122 | events = ["failed", "skipped"]
123 | exceptionFormat "full"
124 | }
125 | }
126 | finalizedBy jacocoTestReport
127 | }
128 |
129 | jacocoTestReport {
130 | dependsOn test
131 | reports {
132 | xml.required = true
133 | }
134 | }
135 |
136 | spotbugsMain {
137 | ignoreFailures = true
138 | effort = "max"
139 | reportLevel = "low"
140 | reportsDir = file("$project.buildDir/reports/spotbugs")
141 | def excludeFile = file("spotbugs-exclude.xml")
142 | if (excludeFile.exists()) {
143 | it.excludeFilter = excludeFile
144 | }
145 | reports {
146 | text.enabled = true
147 | }
148 | }
149 |
150 | spotbugsTest {
151 | enabled = false
152 | }
153 |
154 | task validateSpotbugs() {
155 | doLast {
156 | if (spotbugsMain.reports.size() > 0 &&
157 | spotbugsMain.reports[0].destination.exists() &&
158 | spotbugsMain.reports[0].destination.text.readLines().size() > 0) {
159 | spotbugsMain.reports[0].destination?.eachLine {
160 | println 'Failure: ' + it
161 | }
162 | throw new GradleException("Spotbugs rule violations were found.");
163 | }
164 | }
165 | }
166 |
167 | checkstyle {
168 | toolVersion '10.12.0'
169 | configFile rootProject.file("build-config/checkstyle/build/checkstyle.xml")
170 | configProperties = ["suppressionFile" : rootProject.file("build-config/checkstyle/build/suppressions.xml")]
171 | }
172 |
173 | publishing {
174 | publications {
175 | mavenJava(MavenPublication) {
176 | groupId project.group
177 | artifactId project.name
178 | version = project.version
179 | from components.java
180 | }
181 | }
182 | }
183 |
184 | spotbugsMain.finalizedBy validateSpotbugs
185 | checkstyleMain.dependsOn(":build-config:checkstyle:downloadMultipleFiles")
186 |
--------------------------------------------------------------------------------
/src/main/java/org/ballerinax/datamapper/DataMapperNodeVisitor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.ballerinax.datamapper;
20 |
21 | import com.fasterxml.jackson.core.JsonProcessingException;
22 | import com.fasterxml.jackson.databind.ObjectMapper;
23 | import io.ballerina.compiler.api.SemanticModel;
24 | import io.ballerina.compiler.api.impl.symbols.BallerinaClassSymbol;
25 | import io.ballerina.compiler.api.symbols.MethodSymbol;
26 | import io.ballerina.compiler.api.symbols.ParameterSymbol;
27 | import io.ballerina.compiler.api.symbols.Qualifier;
28 | import io.ballerina.compiler.api.symbols.RecordFieldSymbol;
29 | import io.ballerina.compiler.api.symbols.RecordTypeSymbol;
30 | import io.ballerina.compiler.api.symbols.Symbol;
31 | import io.ballerina.compiler.api.symbols.TypeDefinitionSymbol;
32 | import io.ballerina.compiler.api.symbols.TypeDescKind;
33 | import io.ballerina.compiler.api.symbols.TypeSymbol;
34 | import io.ballerina.compiler.api.symbols.UnionTypeSymbol;
35 | import io.ballerina.compiler.syntax.tree.ClassDefinitionNode;
36 | import io.ballerina.compiler.syntax.tree.NodeList;
37 | import io.ballerina.compiler.syntax.tree.NodeVisitor;
38 | import io.ballerina.compiler.syntax.tree.SyntaxKind;
39 | import io.ballerina.compiler.syntax.tree.Token;
40 | import io.ballerina.compiler.syntax.tree.TypeDefinitionNode;
41 | import org.ballerinax.datamapper.exceptions.DataMapperException;
42 |
43 | import java.util.ArrayList;
44 | import java.util.Collection;
45 | import java.util.HashMap;
46 | import java.util.Iterator;
47 | import java.util.List;
48 | import java.util.Map;
49 | import java.util.Optional;
50 |
51 | /**
52 | * Visitor to extract Record Type Structure information.
53 | */
54 | public class DataMapperNodeVisitor extends NodeVisitor {
55 | private final HashMap recordTypes;
56 | private SemanticModel model;
57 |
58 | public DataMapperNodeVisitor(SemanticModel model) {
59 | this.recordTypes = new HashMap<>();
60 | this.model = model;
61 | }
62 |
63 | public HashMap getRecordTypes() {
64 | return recordTypes;
65 | }
66 |
67 | private String getFieldTypes(Map fieldSymbolMap) {
68 | Iterator iterator = fieldSymbolMap.keySet().iterator();
69 | Map fieldSymbols = new HashMap<>();
70 | String serialized;
71 | while (iterator.hasNext()) {
72 | String fieldName = iterator.next();
73 | String fieldType = fieldSymbolMap.get(fieldName).typeDescriptor().signature();
74 | fieldSymbols.put(fieldName, fieldType);
75 | }
76 | try {
77 | serialized = new ObjectMapper().writeValueAsString(fieldSymbols);
78 | } catch (JsonProcessingException e) {
79 | throw new DataMapperException(e);
80 | }
81 | return serialized;
82 | }
83 |
84 | @Override
85 | public void visit(TypeDefinitionNode typeDefinitionNode) {
86 | if (typeDefinitionNode.typeDescriptor().kind() == SyntaxKind.RECORD_TYPE_DESC) {
87 | Optional recordSymbolOpt = this.model.symbol(typeDefinitionNode);
88 | if (recordSymbolOpt.isPresent()) {
89 | Symbol recordSymbol = recordSymbolOpt.get();
90 | Optional recordNameOpt = recordSymbol.getName();
91 | if (recordNameOpt.isPresent()) {
92 | String recordName = recordNameOpt.get();
93 | String recordSignature = recordSymbol.getModule().get().id().toString();
94 | recordName = recordSignature + ":" + recordName;
95 | Map fieldSymbolMap = ((RecordTypeSymbol) ((TypeDefinitionSymbol)
96 | recordSymbol).typeDescriptor()).fieldDescriptors();
97 | String serialized = getFieldTypes(fieldSymbolMap);
98 | serialized = "{\"" + recordName + "\":" + serialized + "}";
99 | this.recordTypes.put(recordName, serialized);
100 | }
101 | }
102 | }
103 | }
104 |
105 | @Override
106 | public void visit(ClassDefinitionNode classDefinitionNode) {
107 | NodeList classTypeQualifiers = classDefinitionNode.classTypeQualifiers();
108 | for (Token classTypeQualifier : classTypeQualifiers) {
109 | if (classTypeQualifier.text().equals("client")) {
110 | Optional classSymbolOpt = model.symbol(classDefinitionNode);
111 | if (classSymbolOpt.isPresent()) {
112 | Symbol classSymbol = classSymbolOpt.get();
113 | if (classSymbol.getName().isEmpty()) {
114 | continue;
115 | }
116 | Collection methods = ((BallerinaClassSymbol) classSymbol).methods().values();
117 | for (MethodSymbol method : methods) {
118 | if (!method.qualifiers().contains(Qualifier.REMOTE)) {
119 | continue;
120 | }
121 | List paraType = new ArrayList<>();
122 | FunctionRecord functionRecord = new FunctionRecord();
123 | if (method.typeDescriptor().params().isPresent()) {
124 | for (ParameterSymbol parameter : method.typeDescriptor().params().get()) {
125 | if (parameter.getName().isPresent()) {
126 | String parameterName = parameter.getName().get();
127 | if (parameter.typeDescriptor().typeKind() == TypeDescKind.UNION) {
128 | List paraList = ((UnionTypeSymbol) parameter.typeDescriptor()).
129 | memberTypeDescriptors();
130 | for (TypeSymbol typeSymbol : paraList) {
131 | if (typeSymbol.typeKind() == TypeDescKind.ERROR ||
132 | typeSymbol.typeKind() == TypeDescKind.NIL) {
133 | continue;
134 | } else {
135 | paraType.add(typeSymbol.signature());
136 | }
137 | }
138 | } else {
139 | paraType.add(parameter.typeDescriptor().signature());
140 | }
141 | functionRecord.addParameter(parameterName, paraType);
142 | paraType = new ArrayList<>();
143 | }
144 | }
145 | }
146 | TypeSymbol returnTypeSymbol = method.typeDescriptor().returnTypeDescriptor().get();
147 | if (returnTypeSymbol.typeKind() == TypeDescKind.UNION) {
148 | List returnList = ((UnionTypeSymbol) returnTypeSymbol).
149 | memberTypeDescriptors();
150 | for (TypeSymbol typeSymbol : returnList) {
151 | if (typeSymbol.typeKind() == TypeDescKind.ERROR) {
152 | continue;
153 | } else {
154 | functionRecord.addReturnType(typeSymbol.signature());
155 | }
156 | }
157 | } else {
158 | functionRecord.addReturnType(returnTypeSymbol.signature());
159 | }
160 | }
161 | }
162 | }
163 | }
164 | }
165 | }
166 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | # This is normally unused
84 | # shellcheck disable=SC2034
85 | APP_BASE_NAME=${0##*/}
86 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
87 |
88 | # Use the maximum available, or set MAX_FD != -1 to use that value.
89 | MAX_FD=maximum
90 |
91 | warn () {
92 | echo "$*"
93 | } >&2
94 |
95 | die () {
96 | echo
97 | echo "$*"
98 | echo
99 | exit 1
100 | } >&2
101 |
102 | # OS specific support (must be 'true' or 'false').
103 | cygwin=false
104 | msys=false
105 | darwin=false
106 | nonstop=false
107 | case "$( uname )" in #(
108 | CYGWIN* ) cygwin=true ;; #(
109 | Darwin* ) darwin=true ;; #(
110 | MSYS* | MINGW* ) msys=true ;; #(
111 | NONSTOP* ) nonstop=true ;;
112 | esac
113 |
114 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
115 |
116 |
117 | # Determine the Java command to use to start the JVM.
118 | if [ -n "$JAVA_HOME" ] ; then
119 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
120 | # IBM's JDK on AIX uses strange locations for the executables
121 | JAVACMD=$JAVA_HOME/jre/sh/java
122 | else
123 | JAVACMD=$JAVA_HOME/bin/java
124 | fi
125 | if [ ! -x "$JAVACMD" ] ; then
126 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
127 |
128 | Please set the JAVA_HOME variable in your environment to match the
129 | location of your Java installation."
130 | fi
131 | else
132 | JAVACMD=java
133 | if ! command -v java >/dev/null 2>&1
134 | then
135 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
136 |
137 | Please set the JAVA_HOME variable in your environment to match the
138 | location of your Java installation."
139 | fi
140 | fi
141 |
142 | # Increase the maximum file descriptors if we can.
143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144 | case $MAX_FD in #(
145 | max*)
146 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147 | # shellcheck disable=SC3045
148 | MAX_FD=$( ulimit -H -n ) ||
149 | warn "Could not query maximum file descriptor limit"
150 | esac
151 | case $MAX_FD in #(
152 | '' | soft) :;; #(
153 | *)
154 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155 | # shellcheck disable=SC3045
156 | ulimit -n "$MAX_FD" ||
157 | warn "Could not set maximum file descriptor limit to $MAX_FD"
158 | esac
159 | fi
160 |
161 | # Collect all arguments for the java command, stacking in reverse order:
162 | # * args from the command line
163 | # * the main class name
164 | # * -classpath
165 | # * -D...appname settings
166 | # * --module-path (only if needed)
167 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
168 |
169 | # For Cygwin or MSYS, switch paths to Windows format before running java
170 | if "$cygwin" || "$msys" ; then
171 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
172 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
173 |
174 | JAVACMD=$( cygpath --unix "$JAVACMD" )
175 |
176 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
177 | for arg do
178 | if
179 | case $arg in #(
180 | -*) false ;; # don't mess with options #(
181 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
182 | [ -e "$t" ] ;; #(
183 | *) false ;;
184 | esac
185 | then
186 | arg=$( cygpath --path --ignore --mixed "$arg" )
187 | fi
188 | # Roll the args list around exactly as many times as the number of
189 | # args, so each arg winds up back in the position where it started, but
190 | # possibly modified.
191 | #
192 | # NB: a `for` loop captures its iteration list before it begins, so
193 | # changing the positional parameters here affects neither the number of
194 | # iterations, nor the values presented in `arg`.
195 | shift # remove old arg
196 | set -- "$@" "$arg" # push replacement arg
197 | done
198 | fi
199 |
200 |
201 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
202 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
203 |
204 | # Collect all arguments for the java command;
205 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
206 | # shell script including quotes and variable substitutions, so put them in
207 | # double quotes to make sure that they get re-expanded; and
208 | # * put everything else in single quotes, so that it's not re-expanded.
209 |
210 | set -- \
211 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
212 | -classpath "$CLASSPATH" \
213 | org.gradle.wrapper.GradleWrapperMain \
214 | "$@"
215 |
216 | # Stop when "xargs" is not available.
217 | if ! command -v xargs >/dev/null 2>&1
218 | then
219 | die "xargs is not available"
220 | fi
221 |
222 | # Use "xargs" to parse quoted args.
223 | #
224 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
225 | #
226 | # In Bash we could simply go:
227 | #
228 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
229 | # set -- "${ARGS[@]}" "$@"
230 | #
231 | # but POSIX shell has neither arrays nor command substitution, so instead we
232 | # post-process each arg (as a line of input to sed) to backslash-escape any
233 | # character that might be a shell metacharacter, then use eval to reverse
234 | # that process (while maintaining the separation between arguments), and wrap
235 | # the whole thing up as a single "set" statement.
236 | #
237 | # This will of course break if any of these variables contains a newline or
238 | # an unmatched quote.
239 | #
240 |
241 | eval "set -- $(
242 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
243 | xargs -n1 |
244 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
245 | tr '\n' ' '
246 | )" '"$@"'
247 |
248 | exec "$JAVACMD" "$@"
249 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/src/test/java/org/ballerinax/datamapper/DataMapperPluginTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.ballerinax.datamapper;
20 |
21 | import io.ballerina.tools.diagnostics.Diagnostic;
22 | import io.ballerina.tools.diagnostics.DiagnosticSeverity;
23 | import org.ballerinalang.test.BAssertUtil;
24 | import org.ballerinalang.test.BCompileUtil;
25 | import org.ballerinalang.test.CompileResult;
26 | import org.testng.Assert;
27 | import org.testng.Reporter;
28 | import org.testng.annotations.AfterClass;
29 | import org.testng.annotations.Test;
30 |
31 | import java.io.File;
32 | import java.io.IOException;
33 | import java.nio.file.Files;
34 | import java.nio.file.Path;
35 | import java.nio.file.Paths;
36 |
37 | /**
38 | * Test cases for data mapper compiler plugin.
39 | */
40 | public class DataMapperPluginTest {
41 | @Test
42 | public void testHappyPath() {
43 | CompileResult result = BCompileUtil.compile("test1/modules/module_test1");
44 | Assert.assertEquals(result.getErrorCount(), 0);
45 | }
46 |
47 | @Test
48 | public void testErrorNegativeThreeFieldsWithDifferentNames() {
49 | CompileResult result = BCompileUtil.compile("test2/modules/module_test2");
50 | File jsonFile = new File("src/test/resources/test2/modules/module_test2/resources/Creator_data.json");
51 | Assert.assertEquals(jsonFile.exists(), true);
52 | Assert.assertEquals(result.getErrorCount(), 3);
53 | int i = 0;
54 | int j = 0;
55 | Diagnostic[] diagnostics = result.getDiagnostics();
56 | int[] diagnosticIndex = new int[result.getErrorCount()];
57 |
58 | for (Diagnostic diag : diagnostics) {
59 | if (diag.diagnosticInfo().severity() == DiagnosticSeverity.ERROR) {
60 | diagnosticIndex[j] = i;
61 | j++;
62 | }
63 | i++;
64 | }
65 | j = 0;
66 | BAssertUtil.validateError(result, diagnosticIndex[j++],
67 | "type ballerinax/test2.module_test2:0.1.0:Issue does not have an attribute named id2",
68 | 4, 13);
69 | BAssertUtil.validateError(result, diagnosticIndex[j++],
70 | "type ballerinax/test2.module_test2:0.1.0:Creator does not have an attribute " +
71 | "named resourcePath5", 11, 17);
72 | BAssertUtil.validateError(result, diagnosticIndex[j],
73 | "type ballerinax/test2.module_test2:0.1.0:Issue does not have an attribute " +
74 | "named bodyText3", 25, 13);
75 | }
76 |
77 | @Test
78 | public void testErrorNegativeMissingOneField() {
79 | CompileResult result = BCompileUtil.compile("test3/modules/module_test3");
80 | File jsonFile = new File("src/test/resources/test3/modules/module_test3/resources/Creator_data.json");
81 | Assert.assertEquals(jsonFile.exists(), true);
82 | Assert.assertEquals(result.getErrorCount(), 1);
83 |
84 | int i = 0;
85 | Diagnostic[] diagnostics = result.getDiagnostics();
86 | int diagnosticIndex = 0;
87 |
88 | for (Diagnostic diag : diagnostics) {
89 | if (diag.diagnosticInfo().severity() == DiagnosticSeverity.ERROR) {
90 | diagnosticIndex = i;
91 | }
92 | i++;
93 | }
94 |
95 | BAssertUtil.validateError(result, diagnosticIndex,
96 | "invalid attribute count: expected 13, found 12", 9, 18);
97 | }
98 |
99 | @Test
100 | public void testErrorNegativeMissingTwoFields() {
101 | CompileResult result = BCompileUtil.compile("test4/modules/module_test4");
102 | Assert.assertEquals(result.getErrorCount(), 1);
103 |
104 | int i = 0;
105 | Diagnostic[] diagnostics = result.getDiagnostics();
106 | int diagnosticIndex = 0;
107 |
108 | for (Diagnostic diag : diagnostics) {
109 | if (diag.diagnosticInfo().severity() == DiagnosticSeverity.ERROR) {
110 | diagnosticIndex = i;
111 | }
112 | i++;
113 | }
114 |
115 | BAssertUtil.validateError(result, diagnosticIndex,
116 | "invalid attribute count: expected 13, found 11", 9, 18);
117 | }
118 |
119 | @Test
120 | public void testHappyPathMultipleRecords() {
121 | CompileResult result = BCompileUtil.compile("test5/modules/module_test5");
122 | Assert.assertEquals(result.getErrorCount(), 0);
123 | }
124 |
125 | @Test
126 | public void testErrorNegativeMultipleRecordsTwoFieldsDifferentNames() {
127 | CompileResult result = BCompileUtil.compile("test6/modules/module_test6");
128 | Assert.assertEquals(result.getErrorCount(), 2);
129 |
130 | int i = 0;
131 | int j = 0;
132 | Diagnostic[] diagnostics = result.getDiagnostics();
133 | int[] diagnosticIndex = new int[result.getErrorCount()];
134 |
135 | for (Diagnostic diag : diagnostics) {
136 | if (diag.diagnosticInfo().severity() == DiagnosticSeverity.ERROR) {
137 | diagnosticIndex[j] = i;
138 | j++;
139 | }
140 | i++;
141 | }
142 | j = 0;
143 |
144 | BAssertUtil.validateError(result, diagnosticIndex[j++],
145 | "type ballerinax/test6.module_test6:0.1.0:Creator does not have an attribute " +
146 | "named login2", 4, 13);
147 | BAssertUtil.validateError(result, diagnosticIndex[j],
148 | "type ballerinax/test6.module_test6:0.1.0:Creator does not have an attribute " +
149 | "named avatarUrl3", 7, 13);
150 | }
151 |
152 | @Test
153 | public void testHappyPathMultipleRecordsMissingNestedRecord() {
154 | CompileResult result = BCompileUtil.compile("test7/modules/module_test7");
155 | Assert.assertEquals(result.getErrorCount(), 0);
156 | }
157 |
158 | @Test
159 | public void testHappyPathDefaultModuleBuildProject() {
160 | CompileResult result = BCompileUtil.compile("test8/main.bal");
161 | Assert.assertEquals(result.getErrorCount(), 0);
162 | }
163 |
164 | @Test
165 | public void testErrorNegativeMalformedDataJSON() {
166 | CompileResult result = BCompileUtil.compile("test9/modules/module_test9");
167 | Assert.assertEquals(result.getErrorCount(), 1);
168 |
169 | int i = 0;
170 | Diagnostic[] diagnostics = result.getDiagnostics();
171 | int diagnosticIndex = 0;
172 |
173 | for (Diagnostic diag : diagnostics) {
174 | if (diag.diagnosticInfo().severity() == DiagnosticSeverity.ERROR) {
175 | diagnosticIndex = i;
176 | }
177 | i++;
178 | }
179 |
180 | BAssertUtil.validateError(result, diagnosticIndex,
181 | "invalid JSON content: Unexpected character (: (code 58)): was " +
182 | "expecting double-quote to start field name\n" +
183 | " at [Source: (InputStreamReader); line: 4, column: 14]",
184 | 4, 14);
185 | }
186 |
187 | @Test
188 | public void testHappyPathWithPropertyHavingArray() {
189 | CompileResult result = BCompileUtil.compile("test10/modules/module_test10");
190 | Assert.assertEquals(result.getErrorCount(), 0);
191 | }
192 |
193 | @Test
194 | public void testFunctionWithNoAssociatedRecordTypes() {
195 | CompileResult result = BCompileUtil.compile("test11/modules/module_test11");
196 | Assert.assertEquals(result.getErrorCount(), 0);
197 | }
198 |
199 | @Test
200 | public void testDataJSONsWrittenWithoutReferenceToAnyConnectorTypes() {
201 | CompileResult result = BCompileUtil.compile("test12/modules/module_test12");
202 | Assert.assertEquals(result.getErrorCount(), 0);
203 | }
204 |
205 | @Test
206 | public void testHappyPathClientsWithOddClassAndFunctionNames() {
207 | CompileResult result = BCompileUtil.compile("test13/modules/module_test13");
208 | Assert.assertEquals(result.getErrorCount(), 0);
209 | }
210 |
211 | @Test
212 | public void testHappyPathSingleSourceFile() {
213 | CompileResult result = BCompileUtil.compile("test14/main.bal");
214 | Assert.assertEquals(result.getErrorCount(), 0);
215 | }
216 |
217 |
218 | @Test
219 | public void testHappyPathDefaultModuleClient() {
220 | CompileResult result = BCompileUtil.compile("test15/modules/module_test15");
221 | Assert.assertEquals(result.getErrorCount(), 0);
222 | }
223 |
224 | @Test
225 | public void testConnectorNamesWithDot() {
226 | CompileResult result = BCompileUtil.compile("test16.package/modules/module_test16");
227 | Assert.assertEquals(result.getErrorCount(), 4);
228 |
229 | int i = 0;
230 | int j = 0;
231 | Diagnostic[] diagnostics = result.getDiagnostics();
232 | int[] diagnosticIndex = new int[result.getErrorCount()];
233 |
234 | for (Diagnostic diag : diagnostics) {
235 | if (diag.diagnosticInfo().severity() == DiagnosticSeverity.ERROR) {
236 | diagnosticIndex[j] = i;
237 | j++;
238 | }
239 | i++;
240 | }
241 | j = 0;
242 | BAssertUtil.validateError(result, diagnosticIndex[j++],
243 | "type ballerinax/test16.package:0.1.0:Issue does not have an attribute named id2",
244 | 4, 13);
245 | BAssertUtil.validateError(result, diagnosticIndex[j++],
246 | "type ballerinax/test16.package.module_test16:0.1.0:Issue does not have an attribute " +
247 | "named id2", 4, 13);
248 | BAssertUtil.validateError(result, diagnosticIndex[j++],
249 | "type ballerinax/test16.package.module_test16:0.1.0:Issue does not have an attribute " +
250 | "named bodyText2", 5, 13);
251 | BAssertUtil.validateError(result, diagnosticIndex[j],
252 | "type ballerinax/test16.package.module_test16:0.1.0:Issue does not have an attribute " +
253 | "named closed11", 6, 13);
254 |
255 | }
256 |
257 | @Test
258 | public void testDataJSONContainsValidSchemaInvalidFileName() {
259 | CompileResult result = BCompileUtil.compile("test17/modules/module_test17");
260 | Assert.assertEquals(result.getErrorCount(), 0);
261 | }
262 |
263 | @Test
264 | public void testHappyPathSingleSourceFileWithClient() {
265 | CompileResult result = BCompileUtil.compile("test18/main.bal");
266 | Assert.assertEquals(result.getErrorCount(), 0);
267 | }
268 |
269 | public static boolean deleteDirectory(Path directoryPath) {
270 | File directory = new File(String.valueOf(directoryPath));
271 | if (directory.isDirectory()) {
272 | File[] files = directory.listFiles();
273 | if (files != null) {
274 | for (File f : files) {
275 | boolean success = deleteDirectory(f.toPath());
276 | if (!success) {
277 | return false;
278 | }
279 | }
280 | }
281 | }
282 | return directory.delete();
283 | }
284 |
285 | @AfterClass
286 | public void tearDown() throws IOException {
287 | //Cleanup the test projects if they already have generated json files
288 | try {
289 | String path = "src/test/resources/test1/target/";
290 | deleteDirectory(Path.of(path));
291 |
292 | path = "src/test/resources/test2/modules/module_test2/resources/";
293 | Files.deleteIfExists(Paths.get(path + "Creator_data.json"));
294 |
295 | path = "src/test/resources/test2/target/";
296 | deleteDirectory(Path.of(path));
297 |
298 | path = "src/test/resources/test3/modules/module_test3/resources/";
299 | Files.deleteIfExists(Paths.get(path + "Creator_data.json"));
300 |
301 | path = "src/test/resources/test3/target/";
302 | deleteDirectory(Path.of(path));
303 |
304 | path = "src/test/resources/test4/modules/module_test4/resources/";
305 | Files.deleteIfExists(Paths.get(path + "Creator_data.json"));
306 |
307 | path = "src/test/resources/test4/target/";
308 | deleteDirectory(Path.of(path));
309 |
310 | path = "src/test/resources/test5/target/";
311 | deleteDirectory(Path.of(path));
312 |
313 | path = "src/test/resources/test6/target/";
314 | deleteDirectory(Path.of(path));
315 |
316 | path = "src/test/resources/test7/target/";
317 | deleteDirectory(Path.of(path));
318 |
319 | path = "src/test/resources/test8/target/";
320 | deleteDirectory(Path.of(path));
321 |
322 | path = "src/test/resources/test9/target/";
323 | deleteDirectory(Path.of(path));
324 |
325 | path = "src/test/resources/test10/modules/module_test10/resources/";
326 | Files.deleteIfExists(Paths.get(path + "Label_data.json"));
327 |
328 | path = "src/test/resources/test10/target/";
329 | deleteDirectory(Path.of(path));
330 |
331 | path = "src/test/resources/test11/target/";
332 | deleteDirectory(Path.of(path));
333 |
334 | path = "src/test/resources/test12/target/";
335 | deleteDirectory(Path.of(path));
336 |
337 | path = "src/test/resources/test13/target/";
338 | deleteDirectory(Path.of(path));
339 |
340 | path = "src/test/resources/test14/target/";
341 | deleteDirectory(Path.of(path));
342 |
343 | path = "src/test/resources/test15/target/";
344 | deleteDirectory(Path.of(path));
345 |
346 | path = "src/test/resources/test16.package/target/";
347 | deleteDirectory(Path.of(path));
348 |
349 | path = "src/test/resources/test17/target/";
350 | deleteDirectory(Path.of(path));
351 |
352 | path = "src/test/resources/test18/target/";
353 | deleteDirectory(Path.of(path));
354 |
355 | } catch (IOException e) {
356 | Reporter.log("Error : " + e.getMessage(), true);
357 | throw e;
358 | }
359 | }
360 | }
361 |
--------------------------------------------------------------------------------
/src/main/java/org/ballerinax/datamapper/SampleDataAnalysisTask.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.ballerinax.datamapper;
19 |
20 | import com.fasterxml.jackson.core.JsonFactory;
21 | import com.fasterxml.jackson.core.JsonLocation;
22 | import com.fasterxml.jackson.core.JsonParser;
23 | import com.fasterxml.jackson.core.JsonToken;
24 | import com.fasterxml.jackson.databind.JsonNode;
25 | import com.fasterxml.jackson.databind.ObjectMapper;
26 | import com.fasterxml.jackson.databind.node.ObjectNode;
27 | import io.ballerina.compiler.api.SemanticModel;
28 | import io.ballerina.compiler.api.impl.symbols.BallerinaClassSymbol;
29 | import io.ballerina.compiler.api.symbols.Qualifier;
30 | import io.ballerina.compiler.api.symbols.Symbol;
31 | import io.ballerina.compiler.api.symbols.SymbolKind;
32 | import io.ballerina.compiler.syntax.tree.SyntaxTree;
33 | import io.ballerina.projects.DocumentId;
34 | import io.ballerina.projects.Module;
35 | import io.ballerina.projects.ModuleId;
36 | import io.ballerina.projects.Package;
37 | import io.ballerina.projects.PackageCompilation;
38 | import io.ballerina.projects.Project;
39 | import io.ballerina.projects.plugins.AnalysisTask;
40 | import io.ballerina.projects.plugins.CompilationAnalysisContext;
41 | import io.ballerina.tools.diagnostics.Diagnostic;
42 | import io.ballerina.tools.diagnostics.Location;
43 | import org.ballerinax.datamapper.diagnostic.DataMapperDiagnosticLog;
44 | import org.ballerinax.datamapper.diagnostic.DiagnosticErrorCode;
45 | import org.ballerinax.datamapper.exceptions.DataMapperException;
46 | import org.ballerinax.datamapper.util.Utils;
47 | import org.wso2.ballerinalang.compiler.diagnostic.BLangDiagnosticLocation;
48 |
49 | import java.io.File;
50 | import java.io.FileInputStream;
51 | import java.io.IOException;
52 | import java.io.InputStream;
53 | import java.io.InputStreamReader;
54 | import java.io.Reader;
55 | import java.nio.file.Files;
56 | import java.nio.file.NoSuchFileException;
57 | import java.nio.file.Path;
58 | import java.nio.file.Paths;
59 | import java.util.ArrayList;
60 | import java.util.Collection;
61 | import java.util.Collections;
62 | import java.util.HashMap;
63 | import java.util.HashSet;
64 | import java.util.Iterator;
65 | import java.util.List;
66 | import java.util.Map;
67 | import java.util.Set;
68 | import java.util.Stack;
69 | import java.util.stream.Collectors;
70 | import java.util.stream.Stream;
71 |
72 | /**
73 | * An {@code AnalysisTask} that is triggered for data mapper.
74 | */
75 | public class SampleDataAnalysisTask implements AnalysisTask {
76 |
77 | private DataMapperDiagnosticLog dataMapperLog;
78 | private final HashMap> sampleDataMap;
79 | private final HashMap typeInformationMap;
80 | public StringBuilder functions;
81 | private Location nodePosition;
82 | private JsonParser parser;
83 | private String currentTypeStructure;
84 | private String projectDirectory;
85 | private String packageName;
86 |
87 | public SampleDataAnalysisTask() {
88 | this.sampleDataMap = new HashMap<>();
89 | this.functions = new StringBuilder();
90 | this.typeInformationMap = new HashMap<>();
91 | }
92 |
93 | @Override
94 | public void perform(CompilationAnalysisContext compilationAnalysisContext) {
95 | Project project = compilationAnalysisContext.currentPackage().project();
96 | this.dataMapperLog = new DataMapperDiagnosticLog();
97 | projectDirectory = project.sourceRoot().toString();
98 | Package currentPackage = project.currentPackage();
99 | Collection moduleIds = currentPackage.moduleIds();
100 | PackageCompilation compilation = compilationAnalysisContext.compilation();
101 | boolean clientFlag = checkForClient(compilation, moduleIds, currentPackage);
102 |
103 | if (clientFlag) {
104 | packageName = currentPackage.packageName().toString();
105 | for (ModuleId moduleId : moduleIds) {
106 | Module module = currentPackage.module(moduleId);
107 | SemanticModel semanticModel = compilation.getSemanticModel(moduleId);
108 | DataMapperNodeVisitor nodeVisitor = new DataMapperNodeVisitor(semanticModel);
109 | for (DocumentId documentId : module.documentIds()) {
110 | SyntaxTree syntaxTree = module.document(documentId).syntaxTree();
111 | syntaxTree.rootNode().accept(nodeVisitor);
112 | if (!nodeVisitor.getRecordTypes().isEmpty()) {
113 | typeInformationMap.putAll(nodeVisitor.getRecordTypes());
114 | }
115 | }
116 | }
117 | }
118 | Set listOfModuleNames = new HashSet<>();
119 | for (Map.Entry entry : this.typeInformationMap.entrySet()) {
120 | String key = entry.getKey();
121 | String moduleName;
122 | moduleName = key.substring(key.indexOf("/") + 1);
123 | moduleName = moduleName.substring(0, moduleName.indexOf(":"));
124 | listOfModuleNames.add(moduleName);
125 | }
126 |
127 | for (String moduleName : listOfModuleNames) {
128 | processSampleDataFiles(moduleName);
129 | }
130 | for (Diagnostic diagnostic : this.dataMapperLog.getDataMapperPluginDiagnostic()) {
131 | compilationAnalysisContext.reportDiagnostic(diagnostic);
132 | }
133 | }
134 |
135 | private void processSampleDataFiles(String moduleName) {
136 | Path issueDataFilePath;
137 | if (moduleName.contains(".") && !moduleName.equals(packageName)) {
138 | moduleName = moduleName.replace(packageName + ".", "");
139 | issueDataFilePath = Paths.get(projectDirectory, "modules", moduleName, "resources");
140 | } else {
141 | issueDataFilePath = Paths.get(projectDirectory, "resources");
142 | }
143 | List listOfSampleDataJSONFiles;
144 |
145 | try {
146 | Stream files = Files.walk(issueDataFilePath);
147 | listOfSampleDataJSONFiles = files.map(x -> x.toString())
148 | .filter(f -> f.endsWith("_data.json")).collect(Collectors.toList());
149 |
150 | Collections.sort(listOfSampleDataJSONFiles);
151 |
152 | for (String path : listOfSampleDataJSONFiles) {
153 | try {
154 | readDataArray(path);
155 | } catch (IOException e) {
156 | JsonLocation location = parser.getCurrentLocation();
157 | Location position = new BLangDiagnosticLocation(path,
158 | location.getLineNr() - 1, location.getLineNr() - 1,
159 | location.getColumnNr() - 1, location.getColumnNr() - 1);
160 | dataMapperLog.addDiagnostics(position, DiagnosticErrorCode.ERROR_INVALID_JSON_CONTENT,
161 | getCustomizedErrorMessage(e));
162 | }
163 | }
164 |
165 | for (Map.Entry> entry : this.sampleDataMap.entrySet()) {
166 | String key = entry.getKey();
167 |
168 | if (entry.getValue().size() == 0) {
169 | continue;
170 | }
171 | Path targetStructureFilePath = null;
172 | StringBuilder sb = new StringBuilder();
173 |
174 | String moduleDirectoryName = key.substring(key.indexOf("/") + 1);
175 | moduleDirectoryName = moduleDirectoryName.substring(0, moduleDirectoryName.indexOf(":"));
176 | String structureFileName = key.substring(key.lastIndexOf(":") + 1) + "_data.json";
177 | if (moduleDirectoryName.contains(".") && !moduleDirectoryName.equals(packageName)) {
178 | moduleDirectoryName = moduleDirectoryName.replace(packageName + ".", "");
179 | targetStructureFilePath = Paths.get(projectDirectory, "modules", moduleDirectoryName,
180 | "resources", structureFileName);
181 | } else {
182 | targetStructureFilePath = Paths.get(projectDirectory, "resources", structureFileName);
183 | }
184 | File targetFile = new File(String.valueOf(targetStructureFilePath));
185 |
186 | if (targetFile.exists()) {
187 | continue;
188 | }
189 |
190 | sb.append("{\"");
191 | sb.append(key);
192 | sb.append("\":[");
193 |
194 | for (Iterator iterator = entry.getValue().iterator(); iterator.hasNext(); ) {
195 | JsonNode jsonObject = iterator.next();
196 | sb.append(jsonObject.get(key).toString());
197 | if (iterator.hasNext()) {
198 | sb.append(",");
199 | }
200 | }
201 |
202 | sb.append("]}");
203 | Utils.writeToFile(sb.toString(), targetStructureFilePath);
204 | }
205 | } catch (NoSuchFileException e) {
206 | // safe to ignore
207 | } catch (IOException e) {
208 | throw new DataMapperException(e);
209 | }
210 | }
211 |
212 | private void readDataArray(String path) throws IOException {
213 | JsonFactory factory = new JsonFactory();
214 | InputStream inputStream = new FileInputStream(path);
215 | Reader fileReader = new InputStreamReader(inputStream, "UTF-8");
216 | parser = factory.createParser(fileReader);
217 |
218 | String typeName = null;
219 | JsonNode typeRecord = null;
220 | JsonNode dataRecord = null;
221 | int expectedNumberOfAttributes = 0;
222 | int previousExpectedNumberOfAttributes = 0;
223 | int attributeCounter = 0;
224 | long counter = -1;
225 | Stack typeStack = new Stack<>();
226 | Stack attributeCounterStack = new Stack<>();
227 | Stack startLocationStack = new Stack<>();
228 | String previousTypeName = null;
229 | String previousName = null;
230 | boolean readyToMoveUpFlag = false;
231 | boolean errorFlag = false;
232 |
233 | while (!parser.isClosed() && !errorFlag) {
234 | JsonToken jsonToken = parser.nextToken();
235 | if (jsonToken == null) {
236 | break;
237 | }
238 | JsonLocation startLocation;
239 | JsonLocation endLocation;
240 |
241 | switch (jsonToken) {
242 | case START_ARRAY:
243 | break;
244 | case END_ARRAY:
245 | break;
246 | case START_OBJECT:
247 | if (readyToMoveUpFlag) {
248 | readyToMoveUpFlag = false;
249 | attributeCounter = 0;
250 | dataRecord = constructJSON(currentTypeStructure);
251 | } else {
252 | if (startLocationStack.size() != 0) {
253 | startLocationStack.pop();
254 | }
255 | startLocation = parser.getCurrentLocation();
256 | startLocationStack.push(startLocation);
257 | if (counter == -1) {
258 | counter = 1;
259 | } else {
260 | counter++;
261 | }
262 | }
263 |
264 | break;
265 | case END_OBJECT:
266 | if (readyToMoveUpFlag) {
267 | counter--;
268 | }
269 |
270 | if ((expectedNumberOfAttributes != attributeCounter) && (counter != 1)) {
271 | endLocation = parser.getCurrentLocation();
272 | startLocation = startLocationStack.pop();
273 | Location position = new BLangDiagnosticLocation(path,
274 | startLocation.getLineNr() - 1, endLocation.getLineNr() - 1,
275 | startLocation.getColumnNr() - 1, endLocation.getColumnNr() - 1);
276 | dataMapperLog.addDiagnostics(position, DiagnosticErrorCode.ERROR_INVALID_ATTRIBUTE_COUNT,
277 | expectedNumberOfAttributes, attributeCounter);
278 | } else {
279 | if (!typeStack.isEmpty()) {
280 | ArrayList lst = sampleDataMap.getOrDefault(typeName, new ArrayList());
281 | lst.add(dataRecord);
282 | sampleDataMap.put(typeName, lst);
283 | }
284 | }
285 |
286 | readyToMoveUpFlag = true;
287 | break;
288 | case FIELD_NAME:
289 | if (readyToMoveUpFlag) {
290 | readyToMoveUpFlag = false;
291 | dataRecord = null;
292 | if (!typeStack.isEmpty()) {
293 | typeRecord = typeStack.pop();
294 | attributeCounter = attributeCounterStack.pop();
295 | typeName = previousTypeName;
296 | expectedNumberOfAttributes = previousExpectedNumberOfAttributes;
297 | currentTypeStructure = typeRecord.toString();
298 | } else {
299 | counter--;
300 | }
301 | }
302 |
303 | final String name = parser.getCurrentName();
304 | if (counter == 1) {
305 | typeName = name;
306 | String value = typeInformationMap.get(name);
307 | if (value == null) {
308 | errorFlag = true;
309 | continue;
310 | }
311 |
312 | typeRecord = constructJSON(value);
313 | currentTypeStructure = typeRecord.toString();
314 | Iterator iterator = typeRecord.get(name).fieldNames();
315 | expectedNumberOfAttributes = 0;
316 | while (iterator.hasNext()) {
317 | expectedNumberOfAttributes++;
318 | iterator.next();
319 | }
320 | } else if (counter == 2) {
321 | if (typeRecord.get(typeName).get(name) == null) {
322 | JsonLocation location = parser.getCurrentLocation();
323 | Location position = new BLangDiagnosticLocation(path,
324 | location.getLineNr() - 1, location.getLineNr() - 1,
325 | location.getColumnNr() - (name.length() + 6),
326 | location.getColumnNr() - 4);
327 | dataMapperLog.addDiagnostics(position, DiagnosticErrorCode.ERROR_INVALID_ATTRIBUTE_NAME,
328 | typeName, name);
329 | }
330 | attributeCounter++;
331 | } else {
332 | JsonNode result = typeRecord.get(typeName).get(previousName);
333 | typeStack.push(typeRecord);
334 | attributeCounterStack.push(attributeCounter);
335 | previousTypeName = typeName;
336 | attributeCounter = 1;
337 | typeName = result.asText();
338 | if (typeName.endsWith("[]")) {
339 | typeName = typeName.substring(0, typeName.length() - 2);
340 | }
341 |
342 | String value = typeInformationMap.get(typeName);
343 | typeRecord = constructJSON(value);
344 | dataRecord = constructJSON(value);
345 | currentTypeStructure = value;
346 | previousExpectedNumberOfAttributes = expectedNumberOfAttributes;
347 |
348 | Iterator iterator = typeRecord.get(typeName).fieldNames();
349 | int attributeCount = 0;
350 | while (iterator.hasNext()) {
351 | attributeCount++;
352 | iterator.next();
353 | }
354 |
355 | expectedNumberOfAttributes = attributeCount;
356 |
357 | if (!typeRecord.get(typeName).has(name)) {
358 | JsonLocation location = parser.getCurrentLocation();
359 | Location position = new BLangDiagnosticLocation(path,
360 | location.getLineNr(), location.getLineNr(),
361 | location.getColumnNr() - (name.length() + 5),
362 | location.getColumnNr() - 3);
363 | dataMapperLog.addDiagnostics(position, DiagnosticErrorCode.ERROR_INVALID_ATTRIBUTE_NAME,
364 | typeName, name);
365 | }
366 |
367 | counter--;
368 | }
369 |
370 | previousName = name;
371 |
372 | break;
373 | case VALUE_STRING:
374 | final String s = parser.getValueAsString();
375 | if (dataRecord != null && dataRecord.get(typeName).has(previousName)) {
376 | ((ObjectNode) dataRecord.get(typeName)).put(previousName, s);
377 | }
378 | break;
379 | case VALUE_NUMBER_INT:
380 | break;
381 | case VALUE_NUMBER_FLOAT:
382 | break;
383 | case VALUE_TRUE:
384 | break;
385 | case VALUE_FALSE:
386 | break;
387 | case VALUE_NULL:
388 | break;
389 | default:
390 | dataMapperLog.addDiagnostics(nodePosition, DiagnosticErrorCode.ERROR_INVALID_JSON_TOKEN,
391 | jsonToken);
392 | break;
393 | }
394 | }
395 |
396 | }
397 |
398 | public JsonNode constructJSON(String jsonData) throws IOException {
399 | ObjectMapper objectMapper = new ObjectMapper();
400 | JsonNode result = objectMapper.readTree(jsonData);
401 | return result;
402 | }
403 |
404 | private String getCustomizedErrorMessage(Exception e) {
405 | String errorMessage = null;
406 | String originalMessage = e.getMessage();
407 |
408 | if (originalMessage.contains("Source: java.io.InputStreamReader@")) {
409 | String[] arr = originalMessage.split("Source: java.io.InputStreamReader@");
410 | int index = arr[1].indexOf(";");
411 | String endString = arr[1].substring(index);
412 | errorMessage = arr[0] + "Source: java.io.InputStreamReader@OBJECTREF" + endString;
413 | } else if (originalMessage.contains("(InputStreamReader)")) {
414 | errorMessage = originalMessage;
415 | }
416 |
417 | return errorMessage;
418 | }
419 |
420 | private boolean checkForClient(PackageCompilation compilation, Collection moduleIds,
421 | Package currentPackage) {
422 | if (moduleIds.size() == 1) {
423 | ModuleId moduleId = moduleIds.iterator().next();
424 | if (moduleId.moduleName().equals(".") && currentPackage.packageName().toString().equals(".")) {
425 | return false;
426 | }
427 | }
428 | for (ModuleId moduleId : moduleIds) {
429 | SemanticModel semanticModel = compilation.getSemanticModel(moduleId);
430 | for (Symbol moduleSymbol : semanticModel.moduleSymbols()) {
431 | if (moduleSymbol.kind() == SymbolKind.CLASS) {
432 | List qualifiers = ((BallerinaClassSymbol) moduleSymbol).qualifiers();
433 | if (qualifiers.contains(Qualifier.CLIENT)) {
434 | return true;
435 | }
436 | }
437 | }
438 | }
439 | return false;
440 | }
441 |
442 | }
443 |
--------------------------------------------------------------------------------