diff options
author | Vegard Sjonfjell <vegardsjo@gmail.com> | 2016-10-05 16:15:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-05 16:15:12 +0200 |
commit | 988a165429ef19b388e684faa712ffd9096cc559 (patch) | |
tree | de22221e7f90ac2e3cdccc802acef6bb5bc4f082 /testutil/src | |
parent | 6b809b6c8399440475a852bd7fe50fd1671b7212 (diff) | |
parent | 64b6777b0306c013a3b38807615c9c57515bdeb5 (diff) |
Merge pull request #795 from yahoo/voffeloff/constant-tensor-validation
Voffeloff/constant tensor validation
Diffstat (limited to 'testutil/src')
-rw-r--r-- | testutil/src/main/java/com/yahoo/test/json/JsonTestHelper.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/testutil/src/main/java/com/yahoo/test/json/JsonTestHelper.java b/testutil/src/main/java/com/yahoo/test/json/JsonTestHelper.java new file mode 100644 index 00000000000..a8e8e562b2d --- /dev/null +++ b/testutil/src/main/java/com/yahoo/test/json/JsonTestHelper.java @@ -0,0 +1,29 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.test.json; + +import com.google.common.base.Joiner; +import org.hamcrest.MatcherAssert; + +import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; + +/** + * @author Vegard Sjonfjell + */ +public class JsonTestHelper { + + /** + * Convenience method to input JSON without escaping double quotes and newlines + * Each parameter represents a line of JSON encoded data + * The lines are joined with newline and single quotes are replaced with double quotes + */ + public static String inputJson(String... lines) { + return Joiner.on("\n").join(lines).replaceAll("'", "\""); + } + + /** + * Structurally compare two JSON encoded strings + */ + public static void assertJsonEquals(String inputJson, String expectedJson) { + MatcherAssert.assertThat(inputJson, sameJSONAs(expectedJson)); + } +} |