Skip to content

Commit

Permalink
fixed files form Mockito #17
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Mar 7, 2017
1 parent e694538 commit b354c14
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ public class MockSettingsImpl implements MockSettings {
private Object spiedInstance;
private Answer<Object> defaultAnswer;
private MockName mockName;
private boolean serializable;

public MockSettings serializable() {
return this.extraInterfaces(java.io.Serializable.class);
this.serializable = true;
return this;
}

public MockSettings extraInterfaces(Class<?>... extraInterfaces) {
Expand Down Expand Up @@ -71,7 +73,7 @@ public Answer<Object> getDefaultAnswer() {
}

public boolean isSerializable() {
return extraInterfaces != null && java.util.Arrays.asList(extraInterfaces).contains(java.io.Serializable.class);
return serializable;
}

public void initiateMockName(Class classToMock) {
Expand Down
5 changes: 5 additions & 0 deletions projects/Mockito/17/org/mockito/internal/util/MockUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.mockito.internal.creation.jmock.ClassImposterizer;
import org.mockito.internal.util.reflection.LenientCopyTool;

import java.io.Serializable;

@SuppressWarnings("unchecked")
public class MockUtil {
Expand All @@ -42,7 +43,11 @@ public <T> T createMock(Class<T> classToMock, MockSettingsImpl settings) {
Class<?>[] interfaces = settings.getExtraInterfaces();

Class<?>[] ancillaryTypes;
if (settings.isSerializable()) {
ancillaryTypes = interfaces == null ? new Class<?>[] {Serializable.class} : new ArrayUtils().concat(interfaces, Serializable.class);
} else {
ancillaryTypes = interfaces == null ? new Class<?>[0] : interfaces;
}

Object spiedInstance = settings.getSpiedInstance();

Expand Down

0 comments on commit b354c14

Please sign in to comment.