View Javadoc
1   package org.pojomatic.diff;
2   
3   import org.testng.annotations.Test;
4   import static org.testng.Assert.*;
5   
6   import java.util.Arrays;
7   import java.util.Collections;
8   
9   public class PropertyDifferencesTest {
10  
11    @Test(expectedExceptions=NullPointerException.class)
12    public void testConstructorNullPointerException() {
13      new PropertyDifferences(null);
14    }
15  
16    @Test(expectedExceptions=IllegalArgumentException.class)
17    public void testEmptyDifferences() {
18      new PropertyDifferences(Collections.<Difference>emptyList());
19    }
20  
21    @Test
22    public void testSingleDifferenceToString() {
23      PropertyDifferences propertyDifferences = new PropertyDifferences(
24          Arrays.<Difference>asList(new ValueDifference("foo", 3, 4)));
25      assertEquals(propertyDifferences.toString(), "[foo: {3} versus {4}]");
26  
27      propertyDifferences = new PropertyDifferences(
28          Arrays.<Difference>asList(new ValueDifference("foo", null, 4)));
29      assertEquals(propertyDifferences.toString(), "[foo: {null} versus {4}]");
30    }
31  
32    @Test
33    public void testMultipleDifferencesToString() {
34      assertEquals(new PropertyDifferences(Arrays.<Difference>asList(
35      new ValueDifference("foo", 3, 4), new ValueDifference("bar", "this", "that"))).toString(), "[foo: {3} versus {4}, bar: {this} versus {that}]");
36    }
37  
38    @Test
39    public void testAreEqual() {
40      PropertyDifferences propertyDifferences = new PropertyDifferences(
41          Arrays.<Difference>asList(new ValueDifference("foo", 3, 4)));
42      assertFalse(propertyDifferences.areEqual());
43    }
44  }