Package org.mockito.internal.util

Examples of org.mockito.internal.util.MockUtil


     * @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());
                }
View Full Code Here


            return invocation;
        }
    }

    private String qualifiedMethodName() {
        return new MockUtil().getMockName(mock) + "." + method.getName();
    }
View Full Code Here

     * @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);
View Full Code Here

  @Mock
  private Object mock;

  @Test
  public void shouldCreateMock() throws Exception {
      assertThat(new MockUtil().isMock(mock)).isTrue();
  }
View Full Code Here

     * @see org.mockito.stubbing.Answer#answer(org.mockito.invocation.InvocationOnMock)
     */
    public Object answer(InvocationOnMock invocation) {
        if (Invocation.isToString(invocation)) {
            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();
            }
View Full Code Here

            return invocation;
        }
    }

    private String qualifiedMethodName() {
        return new MockUtil().getMockName(mock) + "." + method.getName();
    }
View Full Code Here

    final List<Answer> answers = new LinkedList<Answer>();
    private final Reporter reporter = new Reporter();

    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;
    }
View Full Code Here

     * @return invocations
     */
    public List<Invocation> getAllInvocations(List<?> mocks) {
        Set<Invocation> invocationsInOrder = new TreeSet<Invocation>(new SequenceNumberComparator());
        for (Object mock : mocks) {
            List<Invocation> fromSingleMock = new MockUtil().getMockHandler(mock).getRegisteredInvocations();
            invocationsInOrder.addAll(fromSingleMock);
        }
       
        return new LinkedList<Invocation>(invocationsInOrder);
    }
View Full Code Here

                                  "Example of correct usage of @Spy:\n" +
                                "   @Spy List mock = new LinkedList();\n" +
                                "   //also, don't forget about MockitoAnnotations.initMocks();");

                    }
                    if (new MockUtil().isMock(instance)) {
                        // instance has been spied earlier
                        Mockito.reset(instance);
                    } else {
                        field.set(testClass, Mockito.spy(instance));
                    }
View Full Code Here

     * @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);
View Full Code Here

TOP

Related Classes of org.mockito.internal.util.MockUtil

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.