From b354c14b57e4998938e7fca61b06811c59b6462a Mon Sep 17 00:00:00 2001 From: tdurieux Date: Tue, 7 Mar 2017 13:27:50 +0100 Subject: [PATCH] fixed files form Mockito #17 --- .../17/org/mockito/internal/creation/MockSettingsImpl.java | 6 ++++-- projects/Mockito/17/org/mockito/internal/util/MockUtil.java | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/projects/Mockito/17/org/mockito/internal/creation/MockSettingsImpl.java b/projects/Mockito/17/org/mockito/internal/creation/MockSettingsImpl.java index bf2cf3b..5285d90 100644 --- a/projects/Mockito/17/org/mockito/internal/creation/MockSettingsImpl.java +++ b/projects/Mockito/17/org/mockito/internal/creation/MockSettingsImpl.java @@ -17,9 +17,11 @@ public class MockSettingsImpl implements MockSettings { private Object spiedInstance; private Answer 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) { @@ -71,7 +73,7 @@ public Answer getDefaultAnswer() { } public boolean isSerializable() { - return extraInterfaces != null && java.util.Arrays.asList(extraInterfaces).contains(java.io.Serializable.class); + return serializable; } public void initiateMockName(Class classToMock) { diff --git a/projects/Mockito/17/org/mockito/internal/util/MockUtil.java b/projects/Mockito/17/org/mockito/internal/util/MockUtil.java index d2d042f..b8ed8b4 100644 --- a/projects/Mockito/17/org/mockito/internal/util/MockUtil.java +++ b/projects/Mockito/17/org/mockito/internal/util/MockUtil.java @@ -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 { @@ -42,7 +43,11 @@ public T createMock(Class 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();