Skip to content

Commit

Permalink
Add applicationId property to dataset (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkarthik1901 authored Dec 3, 2024
1 parent 322a206 commit e0d9376
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.jpmorganchase.fusion.packaging;

import com.github.tomakehurst.wiremock.client.WireMock;
import io.github.jpmorganchase.fusion.model.Application;
import io.github.jpmorganchase.fusion.model.Dataset;
import io.github.jpmorganchase.fusion.model.Report;
import io.github.jpmorganchase.fusion.test.TestUtils;
Expand Down Expand Up @@ -149,7 +150,7 @@ public void testCreateDatasetOfTypeReport() {
.varArg("isRestricted", Boolean.FALSE)
.varArg("isRawData", Boolean.FALSE)
.varArg("hasSample", Boolean.FALSE)
.type("Report")
.applicationId(Application.builder().sealId("12345").build())
.report(Report.builder().tier("Tier 1").build())
.build();

Expand Down
14 changes: 13 additions & 1 deletion src/main/java/io/github/jpmorganchase/fusion/model/Dataset.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.gson.annotations.SerializedName;
import io.github.jpmorganchase.fusion.api.APIManager;
import java.util.Map;
import java.util.Optional;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.ToString;
Expand All @@ -25,6 +26,7 @@ public class Dataset extends CatalogResource {
String frequency;
String type;
Report report;
Application applicationId;

@Builder(toBuilder = true)
public Dataset(
Expand All @@ -38,14 +40,16 @@ public Dataset(
String title,
String frequency,
String type,
Report report) {
Report report,
Application applicationId) {
super(identifier, varArgs, apiManager, rootUrl, catalogIdentifier);
this.description = description;
this.linkedEntity = linkedEntity;
this.title = title;
this.frequency = frequency;
this.type = type;
this.report = report;
this.applicationId = applicationId;
}

@Override
Expand All @@ -67,5 +71,13 @@ public DatasetBuilder varArgs(Map<String, Object> varArgs) {
this.varArgs = VarArgsHelper.copyMap(varArgs);
return this;
}

public DatasetBuilder report(Report report) {
Optional.ofNullable(report).ifPresent(val -> {
this.type = "Report";
this.report = val;
});
return this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public JsonElement serialize(Dataset src, Type typeOfSrc, JsonSerializationConte
jsonObject.add("identifier", context.serialize(src.getIdentifier()));
jsonObject.add("type", context.serialize(src.getType()));
jsonObject.add("report", context.serialize(src.getReport()));
jsonObject.add("applicationId", context.serialize(src.getApplicationId()));

Map<String, Object> varArgs = src.getVarArgs();
if (varArgs != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ void constructionWithBuilderCorrectlyPopulatesAllFields() {
.linkedEntity("The entity")
.title("The title")
.frequency("The frequency")
.type("The type")
.report(report)
.rootUrl("http://foobar/api/v1/")
.catalogIdentifier("foobar")
Expand All @@ -38,7 +37,7 @@ void constructionWithBuilderCorrectlyPopulatesAllFields() {
assertThat(d.getLinkedEntity(), is(equalTo("The entity")));
assertThat(d.getTitle(), is(equalTo("The title")));
assertThat(d.getFrequency(), is(equalTo("The frequency")));
assertThat(d.getType(), is(equalTo("The type")));
assertThat(d.getType(), is(equalTo("Report")));
assertThat(d.getReport(), is(equalTo(report)));
assertThat(d.getRootUrl(), is(equalTo("http://foobar/api/v1/")));
assertThat(d.getCatalogIdentifier(), is(equalTo("foobar")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import io.github.jpmorganchase.fusion.api.APIManager;
import io.github.jpmorganchase.fusion.api.context.APIContext;
import io.github.jpmorganchase.fusion.model.Application;
import io.github.jpmorganchase.fusion.model.Dataset;
import io.github.jpmorganchase.fusion.model.Report;
import java.net.URL;
Expand Down Expand Up @@ -49,7 +50,7 @@ public class GsonAPIResponseParserDatasetReportTest {
.varArg("isRestricted", Boolean.FALSE)
.varArg("isRawData", Boolean.FALSE)
.varArg("hasSample", Boolean.FALSE)
.type("Report")
.applicationId(Application.builder().sealId("12345").build())
.report(Report.builder().tier("Tier 1").build())
.build();

Expand Down Expand Up @@ -79,7 +80,7 @@ public class GsonAPIResponseParserDatasetReportTest {
.varArg("isRestricted", Boolean.FALSE)
.varArg("isRawData", Boolean.FALSE)
.varArg("hasSample", Boolean.FALSE)
.type("Report")
.applicationId(Application.builder().sealId("12345").build())
.report(Report.builder().tier("Tier 2").build())
.build();

Expand Down Expand Up @@ -109,7 +110,7 @@ public class GsonAPIResponseParserDatasetReportTest {
.varArg("isRestricted", Boolean.FALSE)
.varArg("isRawData", Boolean.FALSE)
.varArg("hasSample", Boolean.FALSE)
.type("Report")
.applicationId(Application.builder().sealId("12345").build())
.report(Report.builder().tier("Tier 3").build())
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static org.hamcrest.MatcherAssert.assertThat;

import io.github.jpmorganchase.fusion.api.APIManager;
import io.github.jpmorganchase.fusion.model.Application;
import io.github.jpmorganchase.fusion.model.Dataset;
import io.github.jpmorganchase.fusion.model.Report;
import java.net.URL;
Expand Down Expand Up @@ -44,7 +45,7 @@ public void testDatasetSerializesCorrectly() {
.varArg("isRestricted", Boolean.FALSE)
.varArg("isRawData", Boolean.FALSE)
.varArg("hasSample", Boolean.FALSE)
.type("Report")
.applicationId(Application.builder().sealId("12345").build())
.report(Report.builder().tier("Tier 1").build())
.apiManager(Mockito.mock(APIManager.class))
.rootUrl("http://foo/bar")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
"hasSample": false,
"isRestricted": false,
"type": "Report",
"applicationId": {
"id": "12345",
"idType": "SEAL"
},
"report": {
"tier": "Tier 1"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
"hasSample": false,
"@id": "SR0001/",
"type": "Report",
"applicationId": {
"id": "12345",
"idType": "SEAL"
},
"report": {
"tier": "Tier 1"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@
"hasSample": false,
"@id": "SR0001/",
"type": "Report",
"applicationId": {
"id": "12345",
"idType": "SEAL"
},
"report": {
"tier": "Tier 1"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
"hasSample": false,
"@id": "SR0001/",
"type": "Report",
"applicationId": {
"id": "12345",
"idType": "SEAL"
},
"report": {
"tier": "Tier 1"
}
Expand Down Expand Up @@ -79,6 +83,10 @@
"hasSample": false,
"@id": "SR0002/",
"type": "Report",
"applicationId": {
"id": "12345",
"idType": "SEAL"
},
"report": {
"tier": "Tier 2"
}
Expand Down Expand Up @@ -117,6 +125,10 @@
"hasSample": false,
"@id": "SR0003/",
"type": "Report",
"applicationId": {
"id": "12345",
"idType": "SEAL"
},
"report": {
"tier": "Tier 3"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
"hasSample": false,
"@id": "SR0001/",
"type": "Report",
"applicationId": {
"id": "12345",
"idType": "SEAL"
},
"report": {
"tier": "Tier 1"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"description":"Sample dataset description 1","@id":"SD0001/","title":"Sample Dataset 1 | North America","frequency":"Daily","identifier":"SD0001","type":"Report","report":{"tier":"Tier 1"},"subCategory":["Subcategory 1"],"isRawData":false,"isInternalOnlyDataset":false,"language":"English","source":["Source System 1"],"coverageEndDate":"2023-03-08","maintainer":"Maintainer 1","coverageStartDate":"2022-02-05","createdDate":"2022-02-05","isThirdPartyData":false,"modifiedDate":"2023-03-08","publisher":"Publisher 1","tag":["Tag1"],"category":["Category 1"],"region":["North America"],"hasSample":false,"isRestricted":false}
{"description":"Sample dataset description 1","@id":"SD0001/","title":"Sample Dataset 1 | North America","frequency":"Daily","identifier":"SD0001","type":"Report","report":{"tier":"Tier 1"},"applicationId":{"id":"12345","idType":"SEAL"},"subCategory":["Subcategory 1"],"isRawData":false,"isInternalOnlyDataset":false,"language":"English","source":["Source System 1"],"coverageEndDate":"2023-03-08","maintainer":"Maintainer 1","coverageStartDate":"2022-02-05","createdDate":"2022-02-05","isThirdPartyData":false,"modifiedDate":"2023-03-08","publisher":"Publisher 1","tag":["Tag1"],"category":["Category 1"],"region":["North America"],"hasSample":false,"isRestricted":false}

0 comments on commit e0d9376

Please sign in to comment.