490e26b2baa935872477efcae5d6668d304f54e8
[honeycomb.git] / v3po / v3po2vpp / src / test / java / io / fd / honeycomb / translate / v3po / interfaces / acl / common / AclTableContextManagerImplTest.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.translate.v3po.interfaces.acl.common;
18
19 import static org.mockito.Mockito.verify;
20 import static org.mockito.MockitoAnnotations.initMocks;
21
22 import io.fd.honeycomb.translate.MappingContext;
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.mockito.Mock;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.context.rev161214.mapping.entry.context.attributes.acl.mapping.entry.context.MappingTable;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.context.rev161214.mapping.entry.context.attributes.acl.mapping.entry.context.mapping.table.MappingEntry;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.context.rev161214.mapping.entry.context.attributes.acl.mapping.entry.context.mapping.table.MappingEntryBuilder;
29
30 public class AclTableContextManagerImplTest {
31
32     private AclTableContextManagerImpl ctx;
33     @Mock
34     private MappingContext mappingContext;
35     private static final int INDEX = 42;
36
37     @Before
38     public void setUp() throws Exception {
39         initMocks(this);
40         ctx = new AclTableContextManagerImpl(MappingTable.Direction.Ingress);
41     }
42
43     @Test
44     public void testAddEntry() throws Exception {
45         final MappingEntry entry =
46             new MappingEntryBuilder().setL2TableId(1).setIp4TableId(2).setIp6TableId(3).setIndex(INDEX).build();
47         ctx.addEntry(entry, mappingContext);
48         verify(mappingContext).put(ctx.getId(INDEX), entry);
49     }
50
51     @Test
52     public void testRemoveEntry() throws Exception {
53         ctx.removeEntry(INDEX, mappingContext);
54         verify(mappingContext).delete(ctx.getId(INDEX));
55     }
56
57     @Test
58     public void testReadEntry() throws Exception {
59         ctx.getEntry(INDEX, mappingContext);
60         verify(mappingContext).read(ctx.getId(INDEX));
61     }
62 }