|
20 | 20 | import org.junit.Test;
|
21 | 21 | import static org.junit.Assert.assertEquals;
|
22 | 22 | import static org.junit.Assert.assertNotNull;
|
| 23 | +import static org.junit.Assert.assertNotEquals; |
| 24 | + |
| 25 | + |
23 | 26 |
|
24 | 27 | public class SelfDescribingJsonTest {
|
25 | 28 |
|
@@ -67,4 +70,64 @@ public void testMakeSdjWithSdj() {
|
67 | 70 | assertNotNull(sdj);
|
68 | 71 | assertEquals(expected, sdjString);
|
69 | 72 | }
|
| 73 | + |
| 74 | + @Test |
| 75 | + public void testEqualityOfTwoInstances_withSchemaNameOnly() { |
| 76 | + SelfDescribingJson a = new SelfDescribingJson("schema"); |
| 77 | + SelfDescribingJson b = new SelfDescribingJson("schema"); |
| 78 | + assertEquals(a, b); |
| 79 | + } |
| 80 | + |
| 81 | + @Test |
| 82 | + public void testEqualityOfTwoInstances_withTrackerPayload() { |
| 83 | + TrackerPayload nestedData = new TrackerPayload(); |
| 84 | + nestedData.add("key", "value"); |
| 85 | + SelfDescribingJson a = new SelfDescribingJson("schema", nestedData); |
| 86 | + SelfDescribingJson b = new SelfDescribingJson("schema", nestedData); |
| 87 | + assertEquals(a, b); |
| 88 | + } |
| 89 | + |
| 90 | + @Test |
| 91 | + public void testEqualityOfTwoInstances_withNestedEvent() { |
| 92 | + TrackerPayload nestedData = new TrackerPayload(); |
| 93 | + nestedData.add("key", "value"); |
| 94 | + SelfDescribingJson nestedEvent = new SelfDescribingJson("nested_event", nestedData); |
| 95 | + SelfDescribingJson a = new SelfDescribingJson("schema", nestedEvent); |
| 96 | + SelfDescribingJson b = new SelfDescribingJson("schema", nestedEvent); |
| 97 | + assertEquals(a, b); |
| 98 | + } |
| 99 | + |
| 100 | + @Test |
| 101 | + public void testNegativeEqualityOfTwoInstances_withSchemaNameOnly() { |
| 102 | + SelfDescribingJson a = new SelfDescribingJson("schema-one"); |
| 103 | + SelfDescribingJson b = new SelfDescribingJson("schema-two"); |
| 104 | + assertNotEquals(a, b); |
| 105 | + } |
| 106 | + |
| 107 | + @Test |
| 108 | + public void testNegativeEqualityOfTwoInstances_withTrackerPayload() { |
| 109 | + TrackerPayload nestedDataOne = new TrackerPayload(); |
| 110 | + nestedDataOne.add("key", "value-one"); |
| 111 | + TrackerPayload nestedDataTwo = new TrackerPayload(); |
| 112 | + nestedDataTwo.add("key", "value-two"); |
| 113 | + SelfDescribingJson a = new SelfDescribingJson("schema", nestedDataOne); |
| 114 | + SelfDescribingJson b = new SelfDescribingJson("schema", nestedDataTwo); |
| 115 | + assertNotEquals(a, b); |
| 116 | + } |
| 117 | + |
| 118 | + @Test |
| 119 | + public void testNegativeEqualityOfTwoInstances_withNestedEvent() { |
| 120 | + TrackerPayload nestedDataOne = new TrackerPayload(); |
| 121 | + nestedDataOne.add("key", "value-one"); |
| 122 | + SelfDescribingJson nestedEventOne = new SelfDescribingJson("nested_event", nestedDataOne); |
| 123 | + |
| 124 | + TrackerPayload nestedDataTwo = new TrackerPayload(); |
| 125 | + nestedDataTwo.add("key", "value-two"); |
| 126 | + SelfDescribingJson nestedEventTwo = new SelfDescribingJson("nested_event", nestedDataTwo); |
| 127 | + |
| 128 | + |
| 129 | + SelfDescribingJson a = new SelfDescribingJson("schema", nestedEventOne); |
| 130 | + SelfDescribingJson b = new SelfDescribingJson("schema", nestedEventTwo); |
| 131 | + assertNotEquals(a, b); |
| 132 | + } |
70 | 133 | }
|
0 commit comments