2 * Copyright (c) 2016 Cisco and/or its affiliates.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package io.fd.honeycomb.lisp.translate.write.trait;
20 import static org.junit.Assert.assertEquals;
21 import static org.junit.Assert.assertNotNull;
22 import static org.mockito.Mockito.times;
23 import static org.mockito.Mockito.verify;
24 import static org.mockito.Mockito.when;
26 import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
27 import io.fd.vpp.jvpp.core.dto.LispEidTableAddDelMap;
28 import io.fd.vpp.jvpp.core.dto.LispEidTableAddDelMapReply;
29 import org.mockito.ArgumentCaptor;
30 import org.mockito.Captor;
31 import org.mockito.Mockito;
33 public class SubtableWriterTestCase extends WriterCustomizerTest implements SubtableWriter {
35 protected ArgumentCaptor<LispEidTableAddDelMap> requestCaptor;
38 protected void verifyAddDelEidTableAddDelMapInvokedCorrectly(final int addDel, final int vni, final int tableId,
40 verify(api, times(1)).lispEidTableAddDelMap(requestCaptor.capture());
42 final LispEidTableAddDelMap request = requestCaptor.getValue();
43 assertNotNull(request);
44 assertEquals(addDel, request.isAdd);
45 assertEquals(vni, request.vni);
46 assertEquals(tableId, request.dpTable);
47 assertEquals(isL2, request.isL2);
50 protected void whenAddDelEidTableAddDelMapSuccess() {
51 when(api.lispEidTableAddDelMap(Mockito.any(LispEidTableAddDelMap.class)))
52 .thenReturn(future(new LispEidTableAddDelMapReply()));
55 protected void whenAddDelEidTableAddDelMapFail() {
56 when(api.lispEidTableAddDelMap(Mockito.any(LispEidTableAddDelMap.class)))
57 .thenReturn(failedFuture());