Skip to content

Commit

Permalink
Merge pull request #43132 from LakshanWeerasinghe/fix-#43127
Browse files Browse the repository at this point in the history
Add org name to the package metadata response
  • Loading branch information
LakshanWeerasinghe authored Jul 30, 2024
2 parents 161c08a + 513a1db commit 70d41a5
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ public CompletableFuture<PackageMetadataResponse> project(BallerinaProjectParams
if (project.isEmpty()) {
return ballerinaProject;
}
ballerinaProject.setOrgName(project.get().currentPackage().packageOrg().value());
ballerinaProject.setPath(project.get().sourceRoot().toString());
ProjectKind projectKind = project.get().kind();
if (projectKind != ProjectKind.SINGLE_FILE_PROJECT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public CompletableFuture<PackageMetadataResponse> metadata(PackageMetadataReques
if (project.isEmpty()) {
return metadata;
}
metadata.setOrgName(project.get().currentPackage().packageOrg().value());
metadata.setPath(project.get().sourceRoot().toString());
ProjectKind projectKind = project.get().kind();
if (projectKind != ProjectKind.SINGLE_FILE_PROJECT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
public class PackageMetadataResponse {

private String orgName;
private String path;
private String packageName;
private String kind;
Expand Down Expand Up @@ -47,4 +48,12 @@ public String getKind() {
public void setKind(String kind) {
this.kind = kind;
}

public String getOrgName() {
return orgName;
}

public void setOrgName(String orgName) {
this.orgName = orgName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
*/
public class MetadataTest {

private static final String ORG_NAME = "orgName";
private static final String PACKAGE_NAME = "packageName";
private static final String PATH = "path";
private static final String KIND = "kind";
Expand Down Expand Up @@ -76,11 +77,21 @@ private void compareResponse(String projectName, String response) {
Assert.assertNull(responseJsonObject.getAsJsonPrimitive(PACKAGE_NAME),
"Package MetadataTest " + PACKAGE_NAME + " fails with " + projectName + " test case.");
}
Assert.assertEquals(responseJsonObject.getAsJsonPrimitive(KIND),
expectedJsonObject.getAsJsonPrimitive(KIND),

JsonPrimitive projectKind = expectedJsonObject.getAsJsonPrimitive(KIND);
Assert.assertEquals(responseJsonObject.getAsJsonPrimitive(KIND), projectKind,
"Package MetadataTest " + KIND + " fails with " + projectName + " test case.");
Assert.assertNotNull(responseJsonObject.getAsJsonPrimitive(PATH),
"Package MetadataTest " + PATH + " fails with " + projectName + " test case.");

Assert.assertNotNull(responseJsonObject.getAsJsonPrimitive(ORG_NAME),
"Package MetadataTest " + ORG_NAME + " fails with " + projectName + " test case.");

if (projectKind != null && !"SINGLE_FILE_PROJECT".equals(projectKind.getAsString())) {
Assert.assertEquals(responseJsonObject.getAsJsonPrimitive(ORG_NAME),
expectedJsonObject.getAsJsonPrimitive(ORG_NAME),
"Package MetadataTest " + ORG_NAME + " fails with " + projectName + " test case.");
}
}

@AfterClass
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"orgName": "wso2",
"packageName": "project_functions",
"kind": "BUILD_PROJECT",
"path": "file:///"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"orgName": "bob",
"packageName": "project_services",
"kind": "BUILD_PROJECT",
"path": "file:///"
Expand Down

0 comments on commit 70d41a5

Please sign in to comment.