Home | History | Annotate | Download | only in stubbing
      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.DeprecatedOngoingStubbing;
      9 import org.mockito.stubbing.OngoingStubbing;
     10 
     11 public class ConsecutiveStubbing<T> extends BaseStubbing<T> {
     12     private final InvocationContainerImpl invocationContainerImpl;
     13 
     14     public ConsecutiveStubbing(InvocationContainerImpl invocationContainerImpl) {
     15         this.invocationContainerImpl = invocationContainerImpl;
     16     }
     17 
     18     public OngoingStubbing<T> thenAnswer(Answer<?> answer) {
     19         invocationContainerImpl.addConsecutiveAnswer(answer);
     20         return this;
     21     }
     22 
     23     public OngoingStubbing<T> then(Answer<?> answer) {
     24         return thenAnswer(answer);
     25     }
     26 
     27     public DeprecatedOngoingStubbing<T> toAnswer(Answer<?> answer) {
     28         invocationContainerImpl.addConsecutiveAnswer(answer);
     29         return this;
     30     }
     31 
     32     public <M> M getMock() {
     33         return (M) invocationContainerImpl.invokedMock();
     34     }
     35 }