Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/main/java/de/danielbechler/diff/Instances.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ public boolean areEqual()

public boolean areMethodResultsEqual(String method) {
try {
if(base == null && working == null){
return true;
}
if(base == null && working != null || base != null && working == null){
return false;
}
Object baseMethodResult = base.getClass().getMethod(method).invoke(base);
Object workingMethodResult = working.getClass().getMethod(method).invoke(working);
if(baseMethodResult == null){
Expand Down
13 changes: 13 additions & 0 deletions src/test/java/de/danielbechler/diff/InstancesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,19 @@ public void testMethodResultEqualIsEqual() throws Exception
assertThat(instances.areMethodResultsEqual("getValue")).isTrue();
}

@Test
public void testMethodResultEqualOneNull() throws Exception
{
final Method readMethod = getClass().getDeclaredMethod("getTestValue");
final PropertyAccessor accessor = new PropertyAccessor("testValue", readMethod, null);

ObjectWithString working = new ObjectWithString("string");
ObjectWithString base = null;

final Instances instances = new Instances(accessor, working, base, null);
assertThat(instances.areMethodResultsEqual("getValue")).isFalse();
}

@Test
public void testMethodResultEqualInvalidMethod() throws Exception
{
Expand Down