Skip to content

Commit b11aed7

Browse files
committed
Replace home-made JsonMatchers with JsonUnit lib
1 parent e4b9ec7 commit b11aed7

57 files changed

Lines changed: 214 additions & 285 deletions

Some content is hidden

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

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<jackson.version>2.8.4</jackson.version>
4747
<spring.version>4.3.1.RELEASE</spring.version>
4848
<jadler.version>1.1.1</jadler.version>
49-
<json-unit.version>1.5.3</json-unit.version>
49+
<json-unit.version>1.23.0</json-unit.version>
5050
<maven.build.timestamp.format>yyyy</maven.build.timestamp.format>
5151
<currentYear>${maven.build.timestamp}</currentYear>
5252
</properties>

src/test/java/com/gooddata/JsonMatchers.java

Lines changed: 0 additions & 115 deletions
This file was deleted.

src/test/java/com/gooddata/account/AccountTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
import org.testng.annotations.Test;
99

10-
import static com.gooddata.JsonMatchers.serializesToJson;
10+
import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
11+
import static net.javacrumbs.jsonunit.core.util.ResourceUtils.resource;
1112
import static com.gooddata.util.ResourceUtils.readObjectFromResource;
1213
import static org.hamcrest.CoreMatchers.is;
1314
import static org.hamcrest.CoreMatchers.notNullValue;
@@ -37,13 +38,13 @@ public void testDeserialize() throws Exception {
3738
@Test
3839
public void testSerialization() {
3940
final Account account = new Account(FIRST_NAME, LAST_NAME, null);
40-
assertThat(account, serializesToJson("/account/account-input.json"));
41+
assertThat(account, jsonEquals(resource("account/account-input.json")));
4142
}
4243

4344
@Test
4445
public void testSerializationOfCreateAccount() {
4546
final Account account = new Account(MAIL, "password", FIRST_NAME, LAST_NAME);
46-
assertThat(account, serializesToJson("/account/create-account.json"));
47+
assertThat(account, jsonEquals(resource("account/create-account.json")));
4748
}
4849

4950
@Test

src/test/java/com/gooddata/collections/PagingTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
import java.io.InputStream;
1212

13-
import static com.gooddata.JsonMatchers.serializesToJson;
13+
import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
14+
import static net.javacrumbs.jsonunit.core.util.ResourceUtils.resource;
1415
import static com.gooddata.util.ResourceUtils.readObjectFromResource;
1516
import static org.hamcrest.CoreMatchers.notNullValue;
1617
import static org.hamcrest.CoreMatchers.nullValue;
@@ -48,7 +49,7 @@ public void testDeserializationWithNextOnly() throws Exception {
4849
@Test
4950
public void testSerialization() throws Exception {
5051
final Paging paging = new Paging("/nextUri?offset=17");
51-
assertThat(paging, serializesToJson("/collections/paging_only_next.json"));
52+
assertThat(paging, jsonEquals(resource("collections/paging_only_next.json")));
5253
}
5354

5455
}

src/test/java/com/gooddata/connector/ConnectorServiceIT.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,22 @@
99
import com.gooddata.GoodDataException;
1010
import com.gooddata.gdc.UriResponse;
1111
import com.gooddata.project.Project;
12-
import org.hamcrest.Matchers;
1312
import org.testng.annotations.BeforeMethod;
1413
import org.testng.annotations.Test;
1514

16-
import static com.gooddata.JsonMatchers.serializesToJson;
15+
import java.util.Collection;
16+
1717
import static com.gooddata.connector.Status.Code.ERROR;
1818
import static com.gooddata.connector.Status.Code.SYNCHRONIZED;
1919
import static com.gooddata.util.ResourceUtils.*;
2020
import static java.util.Collections.singletonMap;
2121
import static net.jadler.Jadler.onRequest;
22-
import static org.hamcrest.CoreMatchers.hasItem;
23-
import static org.hamcrest.CoreMatchers.is;
24-
import static org.hamcrest.CoreMatchers.notNullValue;
22+
import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
23+
import static net.javacrumbs.jsonunit.core.util.ResourceUtils.resource;
24+
import static org.hamcrest.CoreMatchers.*;
2525
import static org.hamcrest.MatcherAssert.assertThat;
2626
import static org.hamcrest.Matchers.emptyCollectionOf;
2727

28-
import java.util.Collection;
29-
3028
public class ConnectorServiceIT extends AbstractGoodDataIT {
3129
private Project project;
3230
private ConnectorService connectors;
@@ -206,7 +204,7 @@ public void shouldGetZendesk4Settings() throws Exception {
206204
.withBody(readFromResource("/connector/settings-zendesk4.json"));
207205

208206
final Zendesk4Settings zendesk4Settings = connectors.getZendesk4Settings(project);
209-
assertThat(zendesk4Settings, serializesToJson("/connector/settings-zendesk4.json"));
207+
assertThat(zendesk4Settings, jsonEquals(resource("connector/settings-zendesk4.json")));
210208
}
211209

212210
@Test(expectedExceptions = ConnectorException.class)
@@ -238,7 +236,7 @@ public void shouldGetCoupaSettings() throws Exception {
238236
.withBody(readFromResource("/connector/settings-coupa.json"));
239237

240238
final CoupaSettings coupaSettings = connectors.getCoupaSettings(project);
241-
assertThat(coupaSettings, serializesToJson("/connector/settings-coupa.json"));
239+
assertThat(coupaSettings, jsonEquals(resource("connector/settings-coupa.json")));
242240
}
243241

244242
@Test
@@ -336,6 +334,6 @@ public void shouldGetPardotSettings() throws Exception {
336334
.withBody(readFromResource("/connector/settings-pardot.json"));
337335

338336
final PardotSettings pardotSettings = connectors.getPardotSettings(project);
339-
assertThat(pardotSettings, serializesToJson("/connector/settings-pardot.json"));
337+
assertThat(pardotSettings, jsonEquals(resource("connector/settings-pardot.json")));
340338
}
341339
}

src/test/java/com/gooddata/connector/CoupaInstanceTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
*/
66
package com.gooddata.connector;
77

8-
import static com.gooddata.JsonMatchers.serializesToJson;
98
import static com.gooddata.util.ResourceUtils.readObjectFromResource;
9+
import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
10+
import static net.javacrumbs.jsonunit.core.util.ResourceUtils.resource;
1011
import static org.hamcrest.CoreMatchers.is;
1112
import static org.hamcrest.MatcherAssert.assertThat;
1213

@@ -19,7 +20,7 @@ public void shouldSerialize() throws Exception {
1920
final CoupaInstance instance =
2021
new CoupaInstance("instance 01", "https://gooddata-demo.coupacloud.com/api", "apikey123");
2122

22-
assertThat(instance, serializesToJson("/connector/coupa_instance.json"));
23+
assertThat(instance, jsonEquals(resource("connector/coupa_instance.json")));
2324
}
2425

2526
@Test

src/test/java/com/gooddata/connector/CoupaProcessExecutionTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
*/
66
package com.gooddata.connector;
77

8-
import static com.gooddata.JsonMatchers.serializesToJson;
8+
import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
9+
import static net.javacrumbs.jsonunit.core.util.ResourceUtils.resource;
910
import static org.hamcrest.MatcherAssert.assertThat;
1011

1112
import org.joda.time.LocalDate;
@@ -17,22 +18,22 @@ public class CoupaProcessExecutionTest {
1718
public void shouldSerialize() throws Exception {
1819
final CoupaProcessExecution execution = new CoupaProcessExecution();
1920

20-
assertThat(execution, serializesToJson("/connector/process-execution-empty.json"));
21+
assertThat(execution, jsonEquals(resource("connector/process-execution-empty.json")));
2122
}
2223

2324
@Test
2425
public void shouldSerializeIncremental() throws Exception {
2526
final CoupaProcessExecution execution = new CoupaProcessExecution();
2627
execution.setIncremental(true);
2728

28-
assertThat(execution, serializesToJson("/connector/process-execution-incremental.json"));
29+
assertThat(execution, jsonEquals(resource("connector/process-execution-incremental.json")));
2930
}
3031

3132
@Test
3233
public void shouldSerializeDownloadDataFrom() throws Exception {
3334
final CoupaProcessExecution execution = new CoupaProcessExecution();
3435
execution.setDownloadDataFrom(new LocalDate(2018, 1, 25));
3536

36-
assertThat(execution, serializesToJson("/connector/process-execution-coupa-downloadDate.json"));
37+
assertThat(execution, jsonEquals(resource("connector/process-execution-coupa-downloadDate.json")));
3738
}
3839
}

src/test/java/com/gooddata/connector/CoupaSettingsTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@
55
*/
66
package com.gooddata.connector;
77

8-
import static com.gooddata.JsonMatchers.serializesToJson;
8+
import org.testng.annotations.Test;
9+
910
import static com.gooddata.util.ResourceUtils.readObjectFromResource;
11+
import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
12+
import static net.javacrumbs.jsonunit.core.util.ResourceUtils.resource;
1013
import static org.hamcrest.CoreMatchers.is;
1114
import static org.hamcrest.MatcherAssert.assertThat;
1215

13-
import org.testng.annotations.Test;
14-
1516
public class CoupaSettingsTest {
1617

1718
@Test
1819
public void shouldSerialize() throws Exception {
1920
final CoupaSettings settings = new CoupaSettings("UTC");
20-
assertThat(settings, serializesToJson("/connector/settings-coupa.json"));
21+
assertThat(settings, jsonEquals(resource("connector/settings-coupa.json")));
2122
}
2223

2324
@Test

src/test/java/com/gooddata/connector/IntegrationTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
import org.testng.annotations.Test;
99

10-
import static com.gooddata.JsonMatchers.serializesToJson;
10+
import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
11+
import static net.javacrumbs.jsonunit.core.util.ResourceUtils.resource;
1112
import static com.gooddata.util.ResourceUtils.readObjectFromResource;
1213
import static org.hamcrest.MatcherAssert.assertThat;
1314
import static org.hamcrest.Matchers.is;
@@ -32,7 +33,7 @@ public void shouldDeserialize() throws Exception {
3233
@Test
3334
public void shouldSerialize() throws Exception {
3435
final Integration integration = new Integration("template");
35-
assertThat(integration, serializesToJson("/connector/integration-in.json"));
36+
assertThat(integration, jsonEquals(resource("connector/integration-in.json")));
3637
}
3738

3839
@Test

src/test/java/com/gooddata/connector/PardotProcessExecutionTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
*/
66
package com.gooddata.connector;
77

8-
import static com.gooddata.JsonMatchers.serializesToJson;
8+
import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
9+
import static net.javacrumbs.jsonunit.core.util.ResourceUtils.resource;
910
import static org.hamcrest.MatcherAssert.assertThat;
1011

1112
import org.joda.time.LocalDate;
@@ -17,23 +18,23 @@ public class PardotProcessExecutionTest {
1718
public void shouldSerialize() throws Exception {
1819
final PardotProcessExecution execution = new PardotProcessExecution();
1920

20-
assertThat(execution, serializesToJson("/connector/process-execution-empty.json"));
21+
assertThat(execution, jsonEquals(resource("connector/process-execution-empty.json")));
2122
}
2223

2324
@Test
2425
public void shouldSerializeIncremental() throws Exception {
2526
final PardotProcessExecution execution = new PardotProcessExecution();
2627
execution.setIncremental(true);
2728

28-
assertThat(execution, serializesToJson("/connector/process-execution-incremental.json"));
29+
assertThat(execution, jsonEquals(resource("connector/process-execution-incremental.json")));
2930
}
3031

3132
@Test
3233
public void shouldSerializeDownloadDataFrom() throws Exception {
3334
final PardotProcessExecution execution = new PardotProcessExecution();
3435
execution.setChangesFrom(new LocalDate(2018, 1, 25));
3536

36-
assertThat(execution, serializesToJson("/connector/process-execution-pardot-changesFrom.json"));
37+
assertThat(execution, jsonEquals(resource("connector/process-execution-pardot-changesFrom.json")));
3738
}
3839

3940
}

0 commit comments

Comments
 (0)