Permalink
Browse files

Remove MocksControl.MockType that stayed there (#951)

  • Loading branch information...
henri-tremblay authored and thekingnothing committed Oct 28, 2018
1 parent 3539f2f commit 3e8460372f2401e59b9be48dea41a3bde94c2941
@@ -90,23 +90,23 @@ public Object invoke(Object proxy, Method method, Object[] arguments) throws Thr
return invocationHandler.invoke(mockInstance == null ? proxy : mockInstance, method, arguments);
}
public MocksControl.MockType getMockType() {
public MockType getMockType() {
final MocksControl control = invocationHandler.getControl();
if (WhiteboxImpl.getFieldsOfType(control, MocksControl.MockType.class).isEmpty()) {
if (WhiteboxImpl.getFieldsOfType(control, MockType.class).isEmpty()) {
// EasyMock is of version 3.2+
final MockType mockType = WhiteboxImpl.getInternalState(control, MockType.class);
switch (mockType) {
case DEFAULT:
return MocksControl.MockType.DEFAULT;
return MockType.DEFAULT;
case NICE:
return MocksControl.MockType.NICE;
return MockType.NICE;
case STRICT:
return MocksControl.MockType.STRICT;
return MockType.STRICT;
default:
throw new IllegalStateException("PowerMock doesn't seem to work with the used EasyMock version. Please report to the PowerMock mailing list");
}
} else {
return WhiteboxImpl.getInternalState(control, MocksControl.MockType.class);
return WhiteboxImpl.getInternalState(control, MockType.class);
}
}
@@ -17,6 +17,7 @@
import org.easymock.EasyMock;
import org.easymock.IExpectationSetters;
import org.easymock.MockType;
import org.easymock.internal.MocksControl;
import org.powermock.core.MockRepository;
import org.powermock.core.spi.NewInvocationControl;
@@ -51,12 +52,12 @@ public Object invoke(Class<?> type, Object[] args, Class<?>[] sig) throws Except
args = (Object[]) args[length-1];
}
try {
final MocksControl.MockType mockType = ((EasyMockMethodInvocationControl<?>) MockRepository.getInstanceMethodInvocationControl(substitute))
final MockType mockType = ((EasyMockMethodInvocationControl<?>) MockRepository.getInstanceMethodInvocationControl(substitute))
.getMockType();
Object result = substitute.performSubstitutionLogic(args);
if (result == null) {
if (mockType == MocksControl.MockType.NICE) {
if (mockType == MockType.NICE) {
result = EasyMock.createNiceMock(subsitutionType);
} else {
throw new IllegalStateException("Must replay class " + type.getName() + " to get configured expectation.");

0 comments on commit 3e84603

Please sign in to comment.