1 /* 2 * Copyright (c) 2007 Mockito contributors 3 * This program is made available under the terms of the MIT License. 4 */ 5 package org.mockito.internal.stubbing; 6 7 import org.mockito.stubbing.Answer; 8 import org.mockito.stubbing.OngoingStubbing; 9 10 public class ConsecutiveStubbing<T> extends BaseStubbing<T> { 11 private final InvocationContainerImpl invocationContainerImpl; 12 ConsecutiveStubbing(InvocationContainerImpl invocationContainerImpl)13 public ConsecutiveStubbing(InvocationContainerImpl invocationContainerImpl) { 14 this.invocationContainerImpl = invocationContainerImpl; 15 } 16 thenAnswer(Answer<?> answer)17 public OngoingStubbing<T> thenAnswer(Answer<?> answer) { 18 invocationContainerImpl.addConsecutiveAnswer(answer); 19 return this; 20 } 21 then(Answer<?> answer)22 public OngoingStubbing<T> then(Answer<?> answer) { 23 return thenAnswer(answer); 24 } 25 26 @SuppressWarnings("unchecked") getMock()27 public <M> M getMock() { 28 return (M) invocationContainerImpl.invokedMock(); 29 } 30 } 31