MRI version bumpup for Aluminium
[netvirt.git] / aclservice / impl / src / test / java / org / opendaylight / netvirt / aclservice / utils / MethodInvocationParamSaver.java
1 /*
2  * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.netvirt.aclservice.utils;
9
10 import java.util.ArrayList;
11 import java.util.Arrays;
12 import java.util.List;
13 import org.mockito.invocation.InvocationOnMock;
14 import org.mockito.stubbing.Answer;
15
16 public class  MethodInvocationParamSaver<T> implements Answer<T> {
17
18     private List<List<Object>> invocationParams = new ArrayList<>();
19     private T answer;
20
21     public MethodInvocationParamSaver(T answer) {
22         this.answer = answer;
23     }
24
25     @Override
26     public T answer(InvocationOnMock invocation) throws Throwable {
27         invocationParams.add(Arrays.asList(invocation.getArguments()));
28         return answer;
29     }
30
31     public int getNumOfInvocations() {
32         return invocationParams.size();
33     }
34
35     public List<Object> getInvocationParams(int index) {
36         return invocationParams.get(index);
37     }
38
39 }