Skip to content

Commit 1c5c891

Browse files
authored
Merge pull request #95 from jpmorganchase/release
Merge of develop into main following 0.0.14 release.
2 parents 5564446 + 593863e commit 1c5c891

132 files changed

Lines changed: 6328 additions & 149 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The Fusion SDK is published to Maven Central and can be retrieved from there usi
2020
<dependency>
2121
<groupId>io.github.jpmorganchase.fusion</groupId>
2222
<artifactId>fusion-sdk</artifactId>
23-
<version>0.0.13</version>
23+
<version>0.0.14</version>
2424
</dependency>
2525
```
2626

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<groupId>io.github.jpmorganchase.fusion</groupId>
77
<artifactId>fusion-sdk</artifactId>
88
<packaging>jar</packaging>
9-
<version>0.0.13</version>
9+
<version>0.0.14</version>
1010

1111
<name>fusion-sdk</name>
1212
<description>A Java SDK for the Fusion platform API</description>
Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
package io.github.jpmorganchase.fusion.packaging;
2+
3+
import com.github.tomakehurst.wiremock.client.WireMock;
4+
import com.github.tomakehurst.wiremock.junit5.WireMockExtension;
5+
import io.github.jpmorganchase.fusion.model.Attribute;
6+
import io.github.jpmorganchase.fusion.test.TestUtils;
7+
import org.junit.jupiter.api.Assertions;
8+
import org.junit.jupiter.api.Test;
9+
import org.junit.jupiter.api.extension.ExtendWith;
10+
11+
import java.util.Map;
12+
13+
import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson;
14+
15+
@ExtendWith(WireMockExtension.class)
16+
public class AttributeOperationsIT extends BaseOperationsIT {
17+
18+
@Test
19+
public void testCreateAttribute() {
20+
21+
// Given
22+
wireMockRule.stubFor(WireMock.post(WireMock.urlEqualTo("/catalogs/common/datasets/SD0001/attributes/name"))
23+
.withRequestBody(equalToJson(TestUtils.loadJsonForIt("attribute/attribute-name-create-request.json")))
24+
.withHeader("Content-Type", WireMock.equalTo("application/json"))
25+
.willReturn(WireMock.aResponse()
26+
.withHeader("Content-Type", "application/json")
27+
.withStatus(200)));
28+
29+
Attribute a = getSdk().builders().attribute()
30+
.datasetIdentifier("SD0001")
31+
.identifier("name")
32+
.title("Name")
33+
.description("The name")
34+
.index(0)
35+
.key(true)
36+
.isCriticalDataElement(true)
37+
.varArg("source", "Source System 1")
38+
.varArg("term", "bizterm1")
39+
.varArg("dataType", "String")
40+
.varArg("sourceFieldId", "src_name")
41+
.build();
42+
43+
// When & Then
44+
Assertions.assertDoesNotThrow(a::create);
45+
46+
}
47+
48+
@Test
49+
public void testCreateAttributeWithoutVarArgs() {
50+
51+
// Given
52+
wireMockRule.stubFor(WireMock.post(WireMock.urlEqualTo("/catalogs/common/datasets/SD0001/attributes/alternate"))
53+
.withRequestBody(equalToJson(TestUtils.loadJsonForIt("attribute/attribute-alternate-create-request.json")))
54+
.withHeader("Content-Type", WireMock.equalTo("application/json"))
55+
.willReturn(WireMock.aResponse()
56+
.withHeader("Content-Type", "application/json")
57+
.withStatus(200)));
58+
59+
Attribute a = getSdk().builders().attribute()
60+
.datasetIdentifier("SD0001")
61+
.identifier("alternate")
62+
.title("Alternate")
63+
.description("The alternate")
64+
.index(0)
65+
.key(true)
66+
.build();
67+
68+
// When & Then
69+
Assertions.assertDoesNotThrow(a::create);
70+
71+
}
72+
73+
@Test
74+
public void testCreateAttributeWithCatalogOverride() {
75+
76+
// Given
77+
wireMockRule.stubFor(WireMock.post(WireMock.urlEqualTo("/catalogs/foobar/datasets/SD0001/attributes/name"))
78+
.withRequestBody(equalToJson(TestUtils.loadJsonForIt("attribute/attribute-name-create-request.json")))
79+
.withHeader("Content-Type", WireMock.equalTo("application/json"))
80+
.willReturn(WireMock.aResponse()
81+
.withHeader("Content-Type", "application/json")
82+
.withStatus(200)));
83+
84+
Attribute a = getSdk().builders().attribute()
85+
.datasetIdentifier("SD0001")
86+
.identifier("name")
87+
.title("Name")
88+
.description("The name")
89+
.index(0)
90+
.key(true)
91+
.varArg("source", "Source System 1")
92+
.varArg("term", "bizterm1")
93+
.varArg("dataType", "String")
94+
.varArg("sourceFieldId", "src_name")
95+
.catalogIdentifier("foobar")
96+
.isCriticalDataElement(true)
97+
.build();
98+
99+
// When & Then
100+
Assertions.assertDoesNotThrow(a::create);
101+
}
102+
103+
@Test
104+
public void testUpdateAttribute() {
105+
106+
// Given
107+
wireMockRule.stubFor(WireMock.put(WireMock.urlEqualTo("/catalogs/common/datasets/SD0001/attributes/name"))
108+
.withRequestBody(equalToJson(TestUtils.loadJsonForIt("attribute/attribute-name-update-request.json")))
109+
.withHeader("Content-Type", WireMock.equalTo("application/json"))
110+
.willReturn(WireMock.aResponse()
111+
.withHeader("Content-Type", "application/json")
112+
.withStatus(200)));
113+
114+
Attribute a = getSdk().builders().attribute()
115+
.datasetIdentifier("SD0001")
116+
.identifier("name")
117+
.title("Name")
118+
.description("The name updated")
119+
.index(0)
120+
.key(true)
121+
.varArg("source", "Source System 1")
122+
.varArg("term", "bizterm1")
123+
.varArg("dataType", "String")
124+
.varArg("sourceFieldId", "src_name")
125+
.varArg("id", 1)
126+
.isCriticalDataElement(true)
127+
.build();
128+
129+
// When & Then
130+
Assertions.assertDoesNotThrow(a::update);
131+
}
132+
133+
@Test
134+
public void testUpdateAttributeWithCatalogOverride() {
135+
136+
// Given
137+
wireMockRule.stubFor(WireMock.put(WireMock.urlEqualTo("/catalogs/foobar/datasets/SD0001/attributes/name"))
138+
.withRequestBody(equalToJson(TestUtils.loadJsonForIt("attribute/attribute-name-update-request.json")))
139+
.withHeader("Content-Type", WireMock.equalTo("application/json"))
140+
.willReturn(WireMock.aResponse()
141+
.withHeader("Content-Type", "application/json")
142+
.withStatus(200)));
143+
144+
Attribute a = getSdk().builders().attribute()
145+
.datasetIdentifier("SD0001")
146+
.identifier("name")
147+
.title("Name")
148+
.description("The name updated")
149+
.index(0)
150+
.key(true)
151+
.varArg("source", "Source System 1")
152+
.varArg("term", "bizterm1")
153+
.varArg("dataType", "String")
154+
.varArg("sourceFieldId", "src_name")
155+
.varArg("id", 1)
156+
.catalogIdentifier("foobar")
157+
.isCriticalDataElement(true)
158+
.build();
159+
160+
// When & Then
161+
Assertions.assertDoesNotThrow(a::update);
162+
163+
}
164+
165+
@Test
166+
public void testUpdateAttributeRetrieveFromListFunction() {
167+
168+
// Given
169+
wireMockRule.stubFor(WireMock.get(WireMock.urlEqualTo("/catalogs/common/datasets/SD0001/attributes"))
170+
.willReturn(WireMock.aResponse()
171+
.withHeader("Content-Type", "application/json")
172+
.withStatus(200)
173+
.withBodyFile("attribute/multiple-attribute-response.json")));
174+
175+
wireMockRule.stubFor(WireMock.put(WireMock.urlEqualTo("/catalogs/common/datasets/SD0001/attributes/name"))
176+
.withRequestBody(equalToJson(TestUtils.loadJsonForIt("attribute/attribute-name-update-request.json")))
177+
.withHeader("Content-Type", WireMock.equalTo("application/json"))
178+
.willReturn(WireMock.aResponse()
179+
.withHeader("Content-Type", "application/json")
180+
.withStatus(200)));
181+
182+
Map<String, Attribute> attributes = getSdk().listAttributes("SD0001");
183+
Attribute original = attributes.get("name");
184+
185+
Attribute a = original.toBuilder()
186+
.description("The name updated")
187+
.build();
188+
189+
// When & Then
190+
Assertions.assertDoesNotThrow(a::update);
191+
}
192+
193+
@Test
194+
public void testDeleteAttribute() {
195+
196+
// Given
197+
wireMockRule.stubFor(WireMock.delete(WireMock.urlEqualTo("/catalogs/common/datasets/SD0001/attributes/name"))
198+
.willReturn(WireMock.aResponse()
199+
.withHeader("Content-Type", "application/json")
200+
.withStatus(200)));
201+
202+
Attribute a = getSdk().builders().attribute()
203+
.datasetIdentifier("SD0001")
204+
.identifier("name")
205+
.build();
206+
207+
// When & Then
208+
Assertions.assertDoesNotThrow(a::delete);
209+
}
210+
211+
@Test
212+
public void testDeleteAttributeWithCatalogOverride() {
213+
214+
// Given
215+
wireMockRule.stubFor(WireMock.delete(WireMock.urlEqualTo("/catalogs/foobar/datasets/SD0001/attributes/name"))
216+
.willReturn(WireMock.aResponse()
217+
.withHeader("Content-Type", "application/json")
218+
.withStatus(200)));
219+
220+
Attribute a = getSdk().builders().attribute()
221+
.catalogIdentifier("foobar")
222+
.datasetIdentifier("SD0001")
223+
.identifier("name")
224+
.build();
225+
226+
// When & Then
227+
Assertions.assertDoesNotThrow(a::delete);
228+
}
229+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package io.github.jpmorganchase.fusion.packaging;
2+
3+
import com.github.tomakehurst.wiremock.client.WireMock;
4+
import io.github.jpmorganchase.fusion.model.Attribute;
5+
import io.github.jpmorganchase.fusion.model.Attributes;
6+
import io.github.jpmorganchase.fusion.test.TestUtils;
7+
import org.junit.jupiter.api.Assertions;
8+
import org.junit.jupiter.api.Test;
9+
10+
import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson;
11+
12+
public class AttributesOperationsIT extends BaseOperationsIT {
13+
14+
@Test
15+
public void testCreateAttributes() {
16+
// Given
17+
wireMockRule.stubFor(WireMock.put(WireMock.urlEqualTo("/catalogs/common/datasets/dataset1/attributes"))
18+
.withRequestBody(equalToJson(TestUtils.loadJsonForIt("attribute/attributes-bulk-update-request.json")))
19+
.withHeader("Content-Type", WireMock.equalTo("application/json"))
20+
.willReturn(WireMock.aResponse()
21+
.withHeader("Content-Type", "application/json")
22+
.withStatus(200)));
23+
24+
Attribute attr1 = getSdk().builders().attribute()
25+
.identifier("AT0001")
26+
.title("Attribute 1")
27+
.description("Description of Attribute 1")
28+
.datasetIdentifier("dataset1")
29+
.index(0)
30+
.build();
31+
32+
Attribute attr2 = getSdk().builders().attribute()
33+
.identifier("AT0002")
34+
.title("Attribute 2")
35+
.description("Description of Attribute 2")
36+
.datasetIdentifier("dataset1")
37+
.index(1)
38+
.build();
39+
40+
Attributes attributes = getSdk().builders().attributes()
41+
.attribute(attr1)
42+
.attribute(attr2)
43+
.catalogIdentifier("common")
44+
.datasetIdentifier("dataset1")
45+
.build();
46+
47+
// When & Then
48+
Assertions.assertDoesNotThrow(attributes::create);
49+
}
50+
51+
52+
@Test
53+
public void testUpdateAttributes() {
54+
// Given
55+
wireMockRule.stubFor(WireMock.put(WireMock.urlEqualTo("/catalogs/common/datasets/dataset1/attributes"))
56+
.withRequestBody(equalToJson(TestUtils.loadJsonForIt("attribute/attributes-bulk-update-request.json")))
57+
.withHeader("Content-Type", WireMock.equalTo("application/json"))
58+
.willReturn(WireMock.aResponse()
59+
.withHeader("Content-Type", "application/json")
60+
.withStatus(200)));
61+
62+
Attribute attr1 = getSdk().builders().attribute()
63+
.identifier("AT0001")
64+
.title("Attribute 1")
65+
.description("Description of Attribute 1")
66+
.datasetIdentifier("dataset1")
67+
.index(0)
68+
.build();
69+
70+
Attribute attr2 = getSdk().builders().attribute()
71+
.identifier("AT0002")
72+
.title("Attribute 2")
73+
.description("Description of Attribute 2")
74+
.datasetIdentifier("dataset1")
75+
.index(1)
76+
.build();
77+
78+
Attributes attributes = getSdk().builders().attributes()
79+
.attribute(attr1)
80+
.attribute(attr2)
81+
.catalogIdentifier("common")
82+
.datasetIdentifier("dataset1")
83+
.build();
84+
85+
86+
// When & Then
87+
Assertions.assertDoesNotThrow(attributes::update);
88+
}
89+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package io.github.jpmorganchase.fusion.packaging;
2+
3+
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
4+
import com.github.tomakehurst.wiremock.junit5.WireMockExtension;
5+
import io.github.jpmorganchase.fusion.Fusion;
6+
import io.github.jpmorganchase.fusion.FusionConfiguration;
7+
import lombok.Getter;
8+
import org.junit.jupiter.api.BeforeEach;
9+
import org.junit.jupiter.api.extension.ExtendWith;
10+
import org.junit.jupiter.api.extension.RegisterExtension;
11+
import org.slf4j.Logger;
12+
import org.slf4j.LoggerFactory;
13+
14+
import java.lang.invoke.MethodHandles;
15+
16+
@ExtendWith(WireMockExtension.class)
17+
public class BaseOperationsIT {
18+
19+
private static final Logger logger =
20+
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
21+
22+
@RegisterExtension
23+
public static WireMockExtension wireMockRule = WireMockExtension.newInstance().options(WireMockConfiguration.wireMockConfig().dynamicPort()).build();
24+
25+
@Getter
26+
private Fusion sdk;
27+
28+
@BeforeEach
29+
public void setUp() {
30+
int port = wireMockRule.getRuntimeInfo().getHttpPort();
31+
logger.debug("Wiremock is configured to port {}", port);
32+
33+
sdk = Fusion.builder()
34+
.bearerToken("my-token")
35+
.configuration(FusionConfiguration.builder()
36+
.rootURL("http://localhost:" + port + "/")
37+
.build()).build();
38+
}
39+
40+
}

0 commit comments

Comments
 (0)