All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mockito.internal.stubbing.OngoingStubbingImpl Maven / Gradle / Ivy

There is a newer version: 2.0.2-beta
Show newest version
/*
 * Copyright (c) 2007 Mockito contributors
 * This program is made available under the terms of the MIT License.
 */
package org.mockito.internal.stubbing;

import org.mockito.internal.verification.RegisteredInvocations;
import org.mockito.stubbing.Answer;
import org.mockito.stubbing.DeprecatedOngoingStubbing;
import org.mockito.stubbing.OngoingStubbing;

public class OngoingStubbingImpl extends BaseStubbing {
    
    private final MockitoStubber mockitoStubber;
    private final RegisteredInvocations registeredInvocations;

    public OngoingStubbingImpl(MockitoStubber mockitoStubber,
            RegisteredInvocations registeredInvocations) {
        this.mockitoStubber = mockitoStubber;
        this.registeredInvocations = registeredInvocations;
    }

    public OngoingStubbing thenAnswer(Answer answer) {
        registeredInvocations.removeLast();
        mockitoStubber.addAnswer(answer);
        return new ConsecutiveStubbing(mockitoStubber);
    }

    public DeprecatedOngoingStubbing toAnswer(Answer answer) {
        registeredInvocations.removeLast();
        mockitoStubber.addAnswer(answer);
        return new ConsecutiveStubbing(mockitoStubber);
    }

    public RegisteredInvocations getRegisteredInvocations() {
        return registeredInvocations;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy