Skip to content

Commit

Permalink
Merge pull request #80 from jpmorganchase/feature/update_dataset_of_t…
Browse files Browse the repository at this point in the history
…ype_report

update dataset report
  • Loading branch information
pkarthik1901 authored Dec 2, 2024
2 parents c59d54e + cbe4118 commit 322a206
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,37 @@ public void testUpdateDatasetRetrievedFromListDatasets() {
//TODO :: Contract for response of dataset.update() needs to be decided
}

@Test
public void testUpdateDatasetOfTypeReportRetrievedFromListDatasets() {
// Given
wireMockRule.stubFor(WireMock.get(WireMock.urlEqualTo("/catalogs/common/datasets"))
.willReturn(WireMock.aResponse()
.withHeader("Content-Type", "application/json")
.withStatus(200)
.withBodyFile("dataset/multiple-dataset-response.json")));

wireMockRule.stubFor(WireMock.put(WireMock.urlEqualTo("/catalogs/common/datasets/SR0001"))
.withRequestBody(equalToJson(TestUtils.loadJsonForIt("dataset/dataset-report-SR0001-update-request.json")))
.willReturn(WireMock.aResponse()
.withHeader("Content-Type", "application/json")
.withStatus(200)
.withBodyFile("dataset/dataset-create-response.json")));

Map<String, Dataset> datasets = getSdk().listDatasets("common", "SR0001", true);
Dataset originalDataset = datasets.get("SR0001");

// When
Dataset amendedDataset = originalDataset
.toBuilder()
.description("Updated Sample report description 1")
.build();

amendedDataset.update();

// Then Verify the response
//TODO :: Contract for response of dataset.update() needs to be decided
}

@Test
public void testDeleteDataset() {
// Given
Expand Down Expand Up @@ -274,6 +305,7 @@ public void testListDatasets() {
assertThat(datasets.containsKey("SD0001"), is(equalTo(true)));
assertThat(datasets.containsKey("SD0002"), is(equalTo(true)));
assertThat(datasets.containsKey("SD0003"), is(equalTo(true)));
assertThat(datasets.containsKey("SR0001"), is(equalTo(true)));
}

@Test
Expand All @@ -292,6 +324,7 @@ public void testListDatasetsUsingIdContains() {
assertThat(datasets.containsKey("SD0001"), is(equalTo(true)));
assertThat(datasets.containsKey("SD0002"), is(equalTo(false)));
assertThat(datasets.containsKey("SD0003"), is(equalTo(false)));
assertThat(datasets.containsKey("SR0001"), is(equalTo(false)));

}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"category": [
"Category 1"
],
"createdDate": "2022-02-05",
"coverageStartDate": "2022-02-05",
"coverageEndDate": "2023-03-08",
"description": "Updated Sample report description 1",
"frequency": "Daily",
"identifier": "SR0001",
"isThirdPartyData": false,
"isInternalOnlyDataset": false,
"language": "English",
"maintainer": "Maintainer 1",
"modifiedDate": "2023-03-08",
"publisher": "Publisher 1",
"region": [
"North America"
],
"source": [
"Source System 1"
],
"subCategory": [
"Subcategory 1"
],
"title": "Sample Report 1 | North America",
"tag": [
"Tag1"
],
"isRestricted": false,
"isRawData": false,
"hasSample": false,
"@id": "SR0001/",
"type": "Report",
"report": {
"tier": "Tier 1"
}
}
38 changes: 38 additions & 0 deletions src/test/resources/__files/dataset/multiple-dataset-response.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,44 @@
"isRawData": false,
"hasSample": false,
"@id": "SD0003/"
},
{
"category": [
"Category 1"
],
"createdDate": "2022-02-05",
"coverageStartDate": "2022-02-05",
"coverageEndDate": "2023-03-08",
"description": "Sample report description 1",
"frequency": "Daily",
"identifier": "SR0001",
"isThirdPartyData": false,
"isInternalOnlyDataset": false,
"language": "English",
"maintainer": "Maintainer 1",
"modifiedDate": "2023-03-08",
"publisher": "Publisher 1",
"region": [
"North America"
],
"source": [
"Source System 1"
],
"subCategory": [
"Subcategory 1"
],
"title": "Sample Report 1 | North America",
"tag": [
"Tag1"
],
"isRestricted": false,
"isRawData": false,
"hasSample": false,
"@id": "SR0001/",
"type": "Report",
"report": {
"tier": "Tier 1"
}
}
],
"title": "Datasets"
Expand Down

0 comments on commit 322a206

Please sign in to comment.