# HG changeset patch # User dirk # Date 1316236223 -7200 # Node ID 97a113e27ed886e3510db7b16aa545a34930c447 # Parent c621a437ace5750278aecb35626147f007dc8e61 better assertions diff -r c621a437ace5 -r 97a113e27ed8 conflict-editor/src/test/java/de/codedo/conflicteditor/DocumentMatcherTestCase.java --- a/conflict-editor/src/test/java/de/codedo/conflicteditor/DocumentMatcherTestCase.java Sat Sep 17 07:05:41 2011 +0200 +++ b/conflict-editor/src/test/java/de/codedo/conflicteditor/DocumentMatcherTestCase.java Sat Sep 17 07:10:23 2011 +0200 @@ -1,12 +1,9 @@ package de.codedo.conflicteditor; -import static de.codedo.conflicteditor.matchers.ObjectEqualityMatcher.isEqualTo; import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.hasSize; -import static org.junit.Assert.assertEquals; import java.io.IOException; import java.util.List; @@ -33,12 +30,11 @@ JsonNode original = parse("{ 'key' : 'value' }"); JsonNode conflict = parse("{ 'key' : 'other-value' }"); List diffs = new DocumentMatcher(original, conflict).compare(); - assertEquals(1, diffs.size()); + assertThat(diffs, hasSize(1)); - Difference diff = diffs.get(0); - assertEquals("key", diff.key); - assertEquals("value", diff.currentValue); - assertEquals("other-value", diff.otherValue); + Difference actualDifference = diffs.get(0); + Difference expectedDifference = new Difference("key", "value", "other-value"); + assertThat(actualDifference, is(expectedDifference)); } @Test @@ -49,10 +45,9 @@ List diffs = new DocumentMatcher(original, conflict).compare(); assertThat(diffs, hasSize(1)); - Difference diff = diffs.get(0); - assertThat(diff.key, is("only-here")); - assertThat(diff.currentValue, isEqualTo("value")); - assertThat(diff.otherValue, is(nullValue())); + Difference actualDifference = diffs.get(0); + Difference expectedDifference = new Difference("only-here", "value", null); + assertThat(actualDifference, is(expectedDifference)); } @Test @@ -63,10 +58,9 @@ List diffs = new DocumentMatcher(original, conflict).compare(); assertThat(diffs, hasSize(1)); - Difference diff = diffs.get(0); - assertThat(diff.key, is("only-here")); - assertThat(diff.currentValue, is(nullValue())); - assertThat(diff.otherValue, isEqualTo("value")); + Difference actualDifference = diffs.get(0); + Difference expectedDifference = new Difference("only-here", null, "value"); + assertThat(actualDifference, is(expectedDifference)); } private JsonNode parse(String input) throws IOException