org.mockito.internal.util.MockUtil Java Examples

The following examples show how to use org.mockito.internal.util.MockUtil. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ValidatingPoolableLdapConnectionFactoryTest.java    From directory-ldap-api with Apache License 2.0 7 votes vote down vote up
private static final LdapConnection verify( LdapConnection connection, VerificationMode mode )
{
    if ( MockUtil.isMock( connection ) )
    {
        return org.mockito.Mockito.verify( connection, mode );
    }
    else
    {
        if ( connection instanceof Wrapper )
        {
            @SuppressWarnings("unchecked")
            LdapConnection unwrapped = ( ( Wrapper<LdapConnection> ) connection ).wrapped();
            return verify( unwrapped, mode );
        }
    }
    throw new NotAMockException( "connection is not a mock, nor a wrapper for a connection that is one" );
}
 
Example #2
Source File: Reporter.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
public void wrongTypeOfArgumentToReturn(InvocationOnMock invocation, String expectedType, Class actualType, int argumentIndex) {
    throw new WrongTypeOfReturnValue(join(
            "The argument of type '" + actualType.getSimpleName() + "' cannot be returned because the following ",
            "method should return the type '" + expectedType + "'",
            " -> " + new MockUtil().getMockName(invocation.getMock()) + "." + invocation.getMethod().getName() + "()",
            "",
            "The reason for this error can be :",
            "1. The wanted argument position is incorrect.",
            "2. The answer is used on the wrong interaction.",
            "",
            "Position of the wanted argument is " + argumentIndex + " and " + possibleArgumentTypesOf(invocation),
            "***",
            "However if you're still unsure why you're getting above error read on.",
            "Due to the nature of the syntax above problem might occur because:",
            "1. This exception *might* occur in wrongly written multi-threaded tests.",
            "   Please refer to Mockito FAQ on limitations of concurrency testing.",
            "2. A spy is stubbed using when(spy.foo()).then() syntax. It is safer to stub spies - ",
            "   - with doReturn|Throw() family of methods. More in javadocs for Mockito.spy() method.",
            ""
    ));
}
 
Example #3
Source File: DefaultUriAdapterTest.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
  WXEnvironment.sApplication = RuntimeEnvironment.application;
  WXSDKManager wxsdkManager = WXSDKManager.getInstance();
  if (!new MockUtil().isSpy(wxsdkManager)) {
    WXSDKManager spy = Mockito.spy(wxsdkManager);
    WXSDKManagerTest.setInstance(spy);
    Mockito.when(spy.getIWXHttpAdapter()).thenReturn(new IWXHttpAdapter() {
      @Override
      public void sendRequest(WXRequest request, OnHttpListener listener) {
        //do nothing.
      }
    });
  }

  adapter = new DefaultUriAdapter();
  instance = WXSDKInstanceTest.createInstance();
}
 
Example #4
Source File: DefaultUriAdapterTest.java    From weex-uikit with MIT License 6 votes vote down vote up
@Before
public void setup() {
  WXEnvironment.sApplication = RuntimeEnvironment.application;
  WXSDKManager wxsdkManager = WXSDKManager.getInstance();
  if (!new MockUtil().isSpy(wxsdkManager)) {
    WXSDKManager spy = Mockito.spy(wxsdkManager);
    WXSDKManagerTest.setInstance(spy);
    Mockito.when(spy.getIWXHttpAdapter()).thenReturn(new IWXHttpAdapter() {
      @Override
      public void sendRequest(WXRequest request, OnHttpListener listener) {
        //do nothing.
      }
    });
  }

  adapter = new DefaultUriAdapter();
  instance = WXSDKInstanceTest.createInstance();
}
 
Example #5
Source File: ReturnsEmptyValues.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
public Object answer(InvocationOnMock invocation) {
    if (methodsGuru.isToString(invocation.getMethod())) {
        Object mock = invocation.getMock();
        MockName name = new MockUtil().getMockName(mock);
        if (name.isSurrogate()) {
            return "Mock for " + ClassNameFinder.classNameForMock(mock) + ", hashCode: " + mock.hashCode();
        } else {
            return name.toString();
        }
    } else if (methodsGuru.isCompareToMethod(invocation.getMethod())) {
        //see issue 184.
        //mocks by default should not return 0 for compareTo because they are not the same. Hence we return 1 (anything but 0 is good).
        //Only for compareTo() method by the Comparable interface
        return 1;
    }
    
    Class<?> returnType = invocation.getMethod().getReturnType();
    return returnValueFor(returnType);
}
 
Example #6
Source File: ReturnsDeepStubs.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private Object deepStub(InvocationOnMock invocation, GenericMetadataSupport returnTypeGenericMetadata) throws Throwable {
  	InternalMockHandler<Object> handler = new MockUtil().getMockHandler(invocation.getMock());
  	InvocationContainerImpl container = (InvocationContainerImpl) handler.getInvocationContainer();

      // matches invocation for verification
      for (StubbedInvocationMatcher stubbedInvocationMatcher : container.getStubbedInvocations()) {
  		if(container.getInvocationForStubbing().matches(stubbedInvocationMatcher.getInvocation())) {
  			return stubbedInvocationMatcher.answer(invocation);
  		}
}

      // record deep stub answer
      return recordDeepStubAnswer(newDeepStubMock(returnTypeGenericMetadata), container);
  }
 
Example #7
Source File: Reporter.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void cannotInjectDependency(Field field, Object matchingMock, Exception details) {
    throw new MockitoException(join(
            "Mockito couldn't inject mock dependency '" + new MockUtil().getMockName(matchingMock) + "' on field ",
            "'" + field + "'",
            "whose type '" + field.getDeclaringClass().getCanonicalName() + "' was annotated by @InjectMocks in your test.",
            "Also I failed because: " + details.getCause().getMessage(),
            ""
    ), details);
}
 
Example #8
Source File: Reporter.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public int invalidArgumentPositionRangeAtInvocationTime(InvocationOnMock invocation, boolean willReturnLastParameter, int argumentIndex) {
    throw new MockitoException(
            join("Invalid argument index for the current invocation of method : ",
                    " -> " + new MockUtil().getMockName(invocation.getMock()) + "." + invocation.getMethod().getName() + "()",
                    "",
                    (willReturnLastParameter ?
                            "Last parameter wanted" :
                            "Wanted parameter at position " + argumentIndex) + " but " + possibleArgumentTypesOf(invocation),
                    "The index need to be a positive number that indicates a valid position of the argument in the invocation.",
                    "However it is possible to use the -1 value to indicates that the last argument should be returned.",
                    ""));
}
 
Example #9
Source File: MockitoUtils.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Verify the same invocations have been applied to two mocks. This is generally not
 * the preferred way test with mockito and should be avoided if possible.
 * @param expected the mock containing expected invocations
 * @param actual the mock containing actual invocations
 * @param argumentAdapters adapters that can be used to change argument values before they are compared
 */
public static <T> void verifySameInvocations(T expected, T actual, InvocationArgumentsAdapter... argumentAdapters) {
	List<Invocation> expectedInvocations =
			((InvocationContainerImpl) MockUtil.getMockHandler(expected).getInvocationContainer()).getInvocations();
	List<Invocation> actualInvocations =
			((InvocationContainerImpl) MockUtil.getMockHandler(actual).getInvocationContainer()).getInvocations();
	verifySameInvocations(expectedInvocations, actualInvocations, argumentAdapters);
}
 
Example #10
Source File: MockitoCore.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public Object[] ignoreStubs(Object... mocks) {
    for (Object m : mocks) {
        InvocationContainer invocationContainer = new MockUtil().getMockHandler(m).getInvocationContainer();
        List<Invocation> ins = invocationContainer.getInvocations();
        for (Invocation in : ins) {
            if (in.stubInfo() != null) {
                in.ignoreForVerification();
            }
        }
    }
    return mocks;
}
 
Example #11
Source File: UnusedStubsFinder.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Finds all unused stubs for given mocks
 * 
 * @param mocks
 */
public List<Invocation> find(List<?> mocks) {
    List<Invocation> unused = new LinkedList<Invocation>();
    for (Object mock : mocks) {
        InternalMockHandler<Object> handler = new MockUtil().getMockHandler(mock);
        List<StubbedInvocationMatcher> fromSingleMock = handler.getInvocationContainer().getStubbedInvocations();
        for(StubbedInvocationMatcher s : fromSingleMock) {
            if (!s.wasUsed()) {
                 unused.add(s.getInvocation());
            }
        }
    }
    return unused;
}
 
Example #12
Source File: AllInvocationsFinder.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * gets all invocations from mocks. Invocations are ordered earlier first. 
 * 
 * @param mocks mocks
 * @return invocations
 */
public List<Invocation> find(List<?> mocks) {
    Set<Invocation> invocationsInOrder = new TreeSet<Invocation>(new SequenceNumberComparator());
    for (Object mock : mocks) {
        InternalMockHandler<Object> handler = new MockUtil().getMockHandler(mock);
        List<Invocation> fromSingleMock = handler.getInvocationContainer().getInvocations();
        invocationsInOrder.addAll(fromSingleMock);
    }
    
    return new LinkedList<Invocation>(invocationsInOrder);
}
 
Example #13
Source File: PrintSettings.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public String print(List<Matcher> matchers, Invocation invocation) {
    MatchersPrinter matchersPrinter = new MatchersPrinter();
    String qualifiedName = new MockUtil().getMockName(invocation.getMock()) + "." + invocation.getMethod().getName();
    String invocationString = qualifiedName + matchersPrinter.getArgumentsLine(matchers, this);
    if (isMultiline() || (!matchers.isEmpty() && invocationString.length() > MAX_LINE_LENGTH)) {
        return qualifiedName + matchersPrinter.getArgumentsBlock(matchers, this);
    } else {
        return invocationString;
    }
}
 
Example #14
Source File: StubberImpl.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public <T> T when(T mock) {
    MockUtil mockUtil = new MockUtil();
    
    if (mock == null) {
        reporter.nullPassedToWhenMethod();
    } else {
        if (!mockUtil.isMock(mock)) {
            reporter.notAMockPassedToWhenMethod();
        }
    }
    
    mockUtil.getMockHandler(mock).setAnswersForStubbing(answers);
    return mock;
}
 
Example #15
Source File: ThrowsException.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public Object answer(InvocationOnMock invocation) throws Throwable {
    if (new MockUtil().isMock(throwable)) {
        throw throwable;
    }
    Throwable t = throwable.fillInStackTrace();
    filter.filter(t);
    throw t;
}
 
Example #16
Source File: SpyOnInjectedFieldsHandler.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected boolean processInjection(Field field, Object fieldOwner, Set<Object> mockCandidates) {
    FieldReader fieldReader = new FieldReader(fieldOwner, field);

    // TODO refoctor : code duplicated in SpyAnnotationEngine
    if(!fieldReader.isNull() && field.isAnnotationPresent(Spy.class)) {
        try {
            Object instance = fieldReader.read();
            if (new MockUtil().isMock(instance)) {
                // A. instance has been spied earlier
                // B. protect against multiple use of MockitoAnnotations.initMocks()
                Mockito.reset(instance);
            } else {
                new FieldSetter(fieldOwner, field).set(
                    Mockito.mock(instance.getClass(), withSettings()
                        .spiedInstance(instance)
                        .defaultAnswer(Mockito.CALLS_REAL_METHODS)
                        .name(field.getName()))
                );
            }
        } catch (Exception e) {
            throw new MockitoException("Problems initiating spied field " + field.getName(), e);
        }
    }

    return false;
}
 
Example #17
Source File: AcrossJVMSerializationFeature.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates the wrapper that be used in the serialization stream.
 *
 * <p>Immediately serializes the Mockito mock using specifically crafted {@link MockitoMockObjectOutputStream},
 * in a byte array.</p>
 *
 * @param mockitoMock The Mockito mock to serialize.
 * @throws IOException
 */
public AcrossJVMMockSerializationProxy(Object mockitoMock) throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ObjectOutputStream objectOutputStream = new MockitoMockObjectOutputStream(out);

    objectOutputStream.writeObject(mockitoMock);

    objectOutputStream.close();
    out.close();

    MockCreationSettings mockSettings = new MockUtil().getMockSettings(mockitoMock);
    this.serializedMock = out.toByteArray();
    this.typeToMock = mockSettings.getTypeToMock();
    this.extraInterfaces = mockSettings.getExtraInterfaces();
}
 
Example #18
Source File: ToStringCheckerTest.java    From storio with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldCreateSampleValueOfAnyObject() {
    Object sample = new ToStringChecker<Object>(Object.class)
            .createSampleValueOfType(Object.class);

    MockUtil.isMock(sample);
    assertThat(sample.getClass().getSuperclass()).isEqualTo(Object.class);
}
 
Example #19
Source File: ThrowsException.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public Object answer(InvocationOnMock invocation) throws Throwable {
    if (new MockUtil().isMock(throwable)) {
        throw throwable;
    }
    Throwable t = throwable.fillInStackTrace();
    filter.filter(t);
    throw t;
}
 
Example #20
Source File: StubberImpl.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public <T> T when(T mock) {
    MockUtil mockUtil = new MockUtil();
    
    if (mock == null) {
        reporter.nullPassedToWhenMethod();
    } else {
        if (!mockUtil.isMock(mock)) {
            reporter.notAMockPassedToWhenMethod();
        }
    }
    
    mockUtil.getMockHandler(mock).setAnswersForStubbing(answers);
    return mock;
}
 
Example #21
Source File: UnusedStubsFinder.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Finds all unused stubs for given mocks
 * 
 * @param mocks
 */
public List<Invocation> find(List<?> mocks) {
    List<Invocation> unused = new LinkedList<Invocation>();
    for (Object mock : mocks) {
        MockHandlerInterface<Object> handler = new MockUtil().getMockHandler(mock);
        List<StubbedInvocationMatcher> fromSingleMock = handler.getInvocationContainer().getStubbedInvocations();
        for(StubbedInvocationMatcher s : fromSingleMock) {
            if (!s.wasUsed()) {
                 unused.add(s.getInvocation());
            }
        }
    }
    return unused;
}
 
Example #22
Source File: AllInvocationsFinder.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * gets all invocations from mocks. Invocations are ordered earlier first. 
 * 
 * @param mocks mocks
 * @return invocations
 */
public List<Invocation> find(List<?> mocks) {
    Set<Invocation> invocationsInOrder = new TreeSet<Invocation>(new SequenceNumberComparator());
    for (Object mock : mocks) {
        MockHandlerInterface<Object> handler = new MockUtil().getMockHandler(mock);
        List<Invocation> fromSingleMock = handler.getInvocationContainer().getInvocations();
        invocationsInOrder.addAll(fromSingleMock);
    }
    
    return new LinkedList<Invocation>(invocationsInOrder);
}
 
Example #23
Source File: MockitoUtils.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Verify the same invocations have been applied to two mocks. This is generally not
 * the preferred way test with mockito and should be avoided if possible.
 * @param expected the mock containing expected invocations
 * @param actual the mock containing actual invocations
 * @param argumentAdapters adapters that can be used to change argument values before they are compared
 */
public static <T> void verifySameInvocations(T expected, T actual, InvocationArgumentsAdapter... argumentAdapters) {
	List<Invocation> expectedInvocations =
			((InvocationContainerImpl) MockUtil.getMockHandler(expected).getInvocationContainer()).getInvocations();
	List<Invocation> actualInvocations =
			((InvocationContainerImpl) MockUtil.getMockHandler(actual).getInvocationContainer()).getInvocations();
	verifySameInvocations(expectedInvocations, actualInvocations, argumentAdapters);
}
 
Example #24
Source File: MethodForwardingTestUtil.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
/**
 * This is a best effort automatic test for method forwarding between a delegate and its wrapper, where the wrapper
 * class is a subtype of the delegate. Methods can be remapped in case that the implementation does not call the
 * original method. Remapping to null skips the method. This ignores methods that are inherited from Object.
 *
 * @param delegateClass the class for the delegate.
 * @param wrapperFactory factory that produces a wrapper from a delegate.
 * @param delegateObjectSupplier supplier for the delegate object passed to the wrapper factory.
 * @param skipMethodSet set of methods to ignore.
 * @param <D> type of the delegate
 * @param <W> type of the wrapper
 * @param <I> type of the object created as delegate, is a subtype of D.
 */
public static <D, W, I extends D> void testMethodForwarding(
	Class<D> delegateClass,
	Function<I, W> wrapperFactory,
	Supplier<I> delegateObjectSupplier,
	Set<Method> skipMethodSet) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {

	Preconditions.checkNotNull(delegateClass);
	Preconditions.checkNotNull(wrapperFactory);
	Preconditions.checkNotNull(skipMethodSet);

	I delegate = delegateObjectSupplier.get();

	//check if we need to wrap the delegate object as a spy, or if it is already testable with Mockito.
	if (!MockUtil.isSpy(delegate) || !MockUtil.isMock(delegate)) {
		delegate = spy(delegate);
	}

	W wrapper = wrapperFactory.apply(delegate);

	// ensure that wrapper is a subtype of delegate
	Preconditions.checkArgument(delegateClass.isAssignableFrom(wrapper.getClass()));

	for (Method delegateMethod : delegateClass.getMethods()) {

		if (checkSkipMethodForwardCheck(delegateMethod, skipMethodSet)) {
			continue;
		}

		// find the correct method to substitute the bridge for erased generic types.
		// if this doesn't work, the user need to exclude the method and write an additional test.
		Method wrapperMethod = wrapper.getClass().getMethod(
			delegateMethod.getName(),
			delegateMethod.getParameterTypes());

		// things get a bit fuzzy here, best effort to find a match but this might end up with a wrong method.
		if (wrapperMethod.isBridge()) {
			for (Method method : wrapper.getClass().getMethods()) {
				if (!method.isBridge()
					&& method.getName().equals(wrapperMethod.getName())
					&& method.getParameterCount() == wrapperMethod.getParameterCount()) {
					wrapperMethod = method;
					break;
				}
			}
		}

		Class<?>[] parameterTypes = wrapperMethod.getParameterTypes();
		Object[] arguments = new Object[parameterTypes.length];
		for (int j = 0; j < arguments.length; j++) {
			Class<?> parameterType = parameterTypes[j];
			if (parameterType.isArray()) {
				arguments[j] = Array.newInstance(parameterType.getComponentType(), 0);
			} else if (parameterType.isPrimitive()) {
				if (boolean.class.equals(parameterType)) {
					arguments[j] = false;
				} else if (char.class.equals(parameterType)) {
					arguments[j] = 'a';
				} else {
					arguments[j] = (byte) 0;
				}
			} else {
				arguments[j] = Mockito.mock(parameterType);
			}
		}

		wrapperMethod.invoke(wrapper, arguments);
		delegateMethod.invoke(Mockito.verify(delegate, Mockito.times(1)), arguments);
		reset(delegate);
	}
}
 
Example #25
Source File: ReturnsMocksTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void shouldReturnMockValueForClass() throws Exception {
    Object classMock = values.returnValueFor(BarClass.class);
    assertTrue(new MockUtil().isMock(classMock));
}
 
Example #26
Source File: UnstubbedMethodException.java    From yangtools with Eclipse Public License 1.0 4 votes vote down vote up
public UnstubbedMethodException(final Method method, final Object mockAbstractFakeObject) {
    super(MethodExtensions.toString(method) + " is not implemented in "
            + MockUtil.getMockName(mockAbstractFakeObject).toString());
}
 
Example #27
Source File: MethodForwardingTestUtil.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * This is a best effort automatic test for method forwarding between a delegate and its wrapper, where the wrapper
 * class is a subtype of the delegate. Methods can be remapped in case that the implementation does not call the
 * original method. Remapping to null skips the method. This ignores methods that are inherited from Object.
 *
 * @param delegateClass the class for the delegate.
 * @param wrapperFactory factory that produces a wrapper from a delegate.
 * @param delegateObjectSupplier supplier for the delegate object passed to the wrapper factory.
 * @param skipMethodSet set of methods to ignore.
 * @param <D> type of the delegate
 * @param <W> type of the wrapper
 * @param <I> type of the object created as delegate, is a subtype of D.
 */
public static <D, W, I extends D> void testMethodForwarding(
	Class<D> delegateClass,
	Function<I, W> wrapperFactory,
	Supplier<I> delegateObjectSupplier,
	Set<Method> skipMethodSet) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {

	Preconditions.checkNotNull(delegateClass);
	Preconditions.checkNotNull(wrapperFactory);
	Preconditions.checkNotNull(skipMethodSet);

	I delegate = delegateObjectSupplier.get();

	//check if we need to wrap the delegate object as a spy, or if it is already testable with Mockito.
	if (!MockUtil.isSpy(delegate) || !MockUtil.isMock(delegate)) {
		delegate = spy(delegate);
	}

	W wrapper = wrapperFactory.apply(delegate);

	// ensure that wrapper is a subtype of delegate
	Preconditions.checkArgument(delegateClass.isAssignableFrom(wrapper.getClass()));

	for (Method delegateMethod : delegateClass.getMethods()) {

		if (checkSkipMethodForwardCheck(delegateMethod, skipMethodSet)) {
			continue;
		}

		// find the correct method to substitute the bridge for erased generic types.
		// if this doesn't work, the user need to exclude the method and write an additional test.
		Method wrapperMethod = wrapper.getClass().getMethod(
			delegateMethod.getName(),
			delegateMethod.getParameterTypes());

		// things get a bit fuzzy here, best effort to find a match but this might end up with a wrong method.
		if (wrapperMethod.isBridge()) {
			for (Method method : wrapper.getClass().getMethods()) {
				if (!method.isBridge()
					&& method.getName().equals(wrapperMethod.getName())
					&& method.getParameterCount() == wrapperMethod.getParameterCount()) {
					wrapperMethod = method;
					break;
				}
			}
		}

		Class<?>[] parameterTypes = wrapperMethod.getParameterTypes();
		Object[] arguments = new Object[parameterTypes.length];
		for (int j = 0; j < arguments.length; j++) {
			Class<?> parameterType = parameterTypes[j];
			if (parameterType.isArray()) {
				arguments[j] = Array.newInstance(parameterType.getComponentType(), 0);
			} else if (parameterType.isPrimitive()) {
				if (boolean.class.equals(parameterType)) {
					arguments[j] = false;
				} else if (char.class.equals(parameterType)) {
					arguments[j] = 'a';
				} else {
					arguments[j] = (byte) 0;
				}
			} else {
				arguments[j] = Mockito.mock(parameterType);
			}
		}

		wrapperMethod.invoke(wrapper, arguments);
		delegateMethod.invoke(Mockito.verify(delegate, Mockito.times(1)), arguments);
		reset(delegate);
	}
}
 
Example #28
Source File: ReturnsMocksTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void should_return_mock_value_for_class() throws Exception {
    Object classMock = values.returnValueFor(BarClass.class);
    assertTrue(new MockUtil().isMock(classMock));
}
 
Example #29
Source File: ReturnsMocksTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void should_return_mock_value_for_interface() throws Exception {
    Object interfaceMock = values.returnValueFor(FooInterface.class);
    assertTrue(new MockUtil().isMock(interfaceMock));
}
 
Example #30
Source File: TestBase.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
protected boolean isMock(Object o) {
    return new MockUtil().isMock(o);
}