-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to GET lineage from Fusion Object.
- Loading branch information
Showing
7 changed files
with
213 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
...jpmorganchase/fusion/parsing/GsonAPIResponseParserDataDictionaryAttributeLineageTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package io.github.jpmorganchase.fusion.parsing; | ||
|
||
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.Catalog; | ||
import io.github.jpmorganchase.fusion.model.DataDictionaryAttribute; | ||
import io.github.jpmorganchase.fusion.model.DataDictionaryAttributeLineage; | ||
import org.hamcrest.Matchers; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mockito; | ||
|
||
import java.net.URL; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.*; | ||
|
||
public class GsonAPIResponseParserDataDictionaryAttributeLineageTest { | ||
|
||
private static final String singleDataDictionaryAttributeLineageJson = | ||
loadTestResource("single-dd-attribute-lineage-response.json"); | ||
|
||
private final DataDictionaryAttributeLineage lineage = DataDictionaryAttributeLineage.builder() | ||
.identifier("DR0001") | ||
.description("Derived Attribute Description") | ||
.title("Derived Attribute Title") | ||
.linkedEntity("lineage/") | ||
.catalogIdentifier(apiContext.getDefaultCatalog()) | ||
.applicationId(Application.builder().sealId("12345").build()) | ||
.apiManager(apiContext.getApiManager()) | ||
.rootUrl(apiContext.getRootUrl()) | ||
.catalogIdentifier("derived") | ||
.catalog(Catalog.builder() | ||
.identifier("derived") | ||
.description("Derived Catalog Description") | ||
.title("Derived Catalog Title") | ||
.linkedEntity("derived/") | ||
.build()) | ||
.varArgs(new HashMap<>()) | ||
.baseCatalogIdentifier("base") | ||
.baseIdentifier("BA0001") | ||
.build(); | ||
|
||
|
||
private static final APIContext apiContext = APIContext.builder() | ||
.apiManager(Mockito.mock(APIManager.class)) | ||
.rootUrl("http://foobar/api/v1/") | ||
.defaultCatalog("foobar") | ||
.build(); | ||
|
||
private static final APIResponseParser responseParser = new GsonAPIResponseParser(apiContext); | ||
|
||
@Test | ||
public void singleDataDictionaryAttributeResourceIsParsedCorrectly() { | ||
DataDictionaryAttributeLineage l = | ||
responseParser.parseDataDictionaryAttributeLineageResponse(singleDataDictionaryAttributeLineageJson, "base", "BA0001"); | ||
assertThat(l, is(notNullValue())); | ||
|
||
assertThat(l, is(equalTo(lineage))); | ||
} | ||
|
||
|
||
private static String loadTestResource(String resourceName) { | ||
URL url = GsonAPIResponseParser.class.getResource(resourceName); | ||
try { | ||
Path path = Paths.get(url.toURI()); | ||
return new String(Files.readAllBytes(path), StandardCharsets.UTF_8); | ||
} catch (Exception e) { | ||
throw new RuntimeException("Failed to load test data", e); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/test/resources/__files/data-dictionary-lineage/lineage-BA0001-get-response.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"@context": { | ||
"@vocab": "https://www.w3.org/ns/dcat3.jsonld", | ||
"@base": "https://fusion-api.jpmorgan.com/fusion/v1/catalogs/base/attributes/BA001/lineage" | ||
}, | ||
"@id": "lineage/", | ||
"description": "Derived Attribute Description", | ||
"identifier": "DR0001", | ||
"title": "Derived Attribute Title", | ||
"applicationId": { | ||
"id": "12345", | ||
"idType": "SEAL" | ||
}, | ||
"catalog": { | ||
"@id": "derived/", | ||
"description": "Derived Catalog Description", | ||
"identifier": "derived", | ||
"title": "Derived Catalog Title" | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...esources/io/github/jpmorganchase/fusion/parsing/single-dd-attribute-lineage-response.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"@context": { | ||
"@vocab": "https://www.w3.org/ns/dcat3.jsonld", | ||
"@base": "https://fusion-api.jpmorgan.com/fusion/v1/catalogs/base/attributes/BA001/lineage" | ||
}, | ||
"@id": "lineage/", | ||
"description": "Derived Attribute Description", | ||
"identifier": "DR0001", | ||
"title": "Derived Attribute Title", | ||
"applicationId": { | ||
"id": "12345", | ||
"idType": "SEAL" | ||
}, | ||
"catalog": { | ||
"@id": "derived/", | ||
"description": "Derived Catalog Description", | ||
"identifier": "derived", | ||
"title": "Derived Catalog Title" | ||
} | ||
} |