From 883f3e5774baf47a44390a3cce89ed1aa7991299 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Thu, 26 Sep 2024 11:03:22 +1000 Subject: [PATCH] chore: add JSON parser test for Windows #1827 --- .../core/support/json/JsonParserTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 core/support/src/test/java/au/com/dius/pact/core/support/json/JsonParserTest.java diff --git a/core/support/src/test/java/au/com/dius/pact/core/support/json/JsonParserTest.java b/core/support/src/test/java/au/com/dius/pact/core/support/json/JsonParserTest.java new file mode 100644 index 000000000..a010cce44 --- /dev/null +++ b/core/support/src/test/java/au/com/dius/pact/core/support/json/JsonParserTest.java @@ -0,0 +1,25 @@ +package au.com.dius.pact.core.support.json; + +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.Map; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +public class JsonParserTest { + @Test + void canParseRawVersionSelectors() { + String jsonStr = "[{\"mainBranch\": true}, {\"deployedOrReleased\": true}, {\"matchingBranch\": true}]"; + JsonValue jsonValue = JsonParser.parseString(jsonStr); + + JsonValue json = new JsonValue.Array(List.of( + new JsonValue.Object(Map.of("mainBranch", JsonValue.True.INSTANCE)), + new JsonValue.Object(Map.of("deployedOrReleased", JsonValue.True.INSTANCE)), + new JsonValue.Object(Map.of("matchingBranch", JsonValue.True.INSTANCE)) + )); + assertThat(jsonValue, is(equalTo(json))); + } +}