HONEYCOMB-58 - Routing Api
[honeycomb.git] / vpp-common / vpp-translate-test / src / main / java / io / fd / honeycomb / vpp / test / util / InterfaceDumpHelper.java
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package io.fd.honeycomb.vpp.test.util;
18
19 import static org.mockito.Matchers.any;
20 import static org.mockito.Mockito.when;
21
22 import java.util.Collections;
23 import javax.annotation.Nonnull;
24 import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails;
25 import io.fd.vpp.jvpp.core.dto.SwInterfaceDetailsReplyDump;
26 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
27
28 /**
29  * VPP translation test helper, that helps stubbing {@link FutureJVppCore#swInterfaceDump}.
30  */
31 public interface InterfaceDumpHelper extends FutureProducer {
32
33     /**
34      * Stubs swInterfaceDump to return given list of interfaces.
35      *
36      * @param api        vppApi reference
37      * @param interfaces list of interface details to be returned
38      */
39     default void whenSwInterfaceDumpThenReturn(@Nonnull final FutureJVppCore api,
40                                                final SwInterfaceDetails... interfaces) {
41         final SwInterfaceDetailsReplyDump reply = new SwInterfaceDetailsReplyDump();
42         Collections.addAll(reply.swInterfaceDetails, interfaces);
43         when(api.swInterfaceDump(any())).thenReturn(future(reply));
44     }
45 }