Skip to content

Commit

Permalink
Fix opendj-server-legacy unit tests. WrenSecurity#71
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelhoral committed Feb 7, 2023
1 parent 0ae27d4 commit 7b54050
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.TreeSet;

import org.mockito.internal.stubbing.defaultanswers.ReturnsEmptyValues;
import org.mockito.internal.util.Primitives;
import org.mockito.invocation.InvocationOnMock;

/**
Expand Down Expand Up @@ -89,6 +90,9 @@ public Object answer(InvocationOnMock invocation) {
if (defaultValue != null) {
return defaultValue;
}
if (Number.class.isAssignableFrom(invocation.getMethod().getReturnType())) {
return null; // Prevent Mockito's default behavior of returning wrapped 0
}
return answerFromDefaultMockitoBehavior(invocation);
} catch (Exception e) {
return answerFromDefaultMockitoBehavior(invocation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ public Object answer(InvocationOnMock invocation) throws Throwable
returnedEntries.add(invocation.getArgument(0));
return null;
}
}).when(searchOp).returnEntry(any(Entry.class), any(List.class));
}).when(searchOp).returnEntry(any(Entry.class), any());
return searchOp;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,8 @@ public void testGetAllAttributes() throws Exception
"modifyTimestamp: 20070101000001Z");

List<String> expectedAttrNames = newArrayList(
"cn", "cn;lang-en-US", "sn", "sn;lang-en-US", "givenName", "givenName;lang-en-US", "creatorsName",
"createTimestamp", "modifyTimestamp", "modifiersName");
"cn", "cn;lang-en-US", "givenName", "givenName;lang-en-US", "sn", "sn;lang-en-US", "creatorsName",
"createTimestamp", "modifiersName", "modifyTimestamp");

Iterator<Attribute> allAttrsIt = e.getAllAttributes().iterator();
Iterator<String> expectedAttrNameIt = expectedAttrNames.iterator();
Expand Down

0 comments on commit 7b54050

Please sign in to comment.