HONEYCOMB-58 - Routing Api
[honeycomb.git] / lisp / lisp2vpp / src / test / java / io / fd / honeycomb / lisp / translate / read / trait / MappingReaderTest.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.lisp.translate.read.trait;
18
19
20 import static org.junit.Assert.assertEquals;
21
22 import org.junit.Before;
23 import org.junit.Test;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.LocalMappings;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.RemoteMappings;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.local.mappings.LocalMapping;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.RemoteMapping;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtable;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.vni.table.VrfSubtable;
30 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
31
32 public class MappingReaderTest implements MappingReader {
33
34     private InstanceIdentifier<LocalMapping> validVrfLocal;
35     private InstanceIdentifier<LocalMapping> validBdLocal;
36     private InstanceIdentifier<LocalMapping> invalidLocal;
37
38     private InstanceIdentifier<RemoteMapping> validVrfRemote;
39     private InstanceIdentifier<RemoteMapping> validBdRemote;
40     private InstanceIdentifier<RemoteMapping> invalidRemote;
41
42
43     @Before
44     public void init() {
45         validVrfLocal = InstanceIdentifier.create(VrfSubtable.class)
46                 .child(LocalMappings.class)
47                 .child(LocalMapping.class);
48
49         validBdLocal = InstanceIdentifier.create(BridgeDomainSubtable.class)
50                 .child(LocalMappings.class)
51                 .child(LocalMapping.class);
52
53         invalidLocal = InstanceIdentifier.create(LocalMapping.class);
54
55         validVrfRemote = InstanceIdentifier.create(VrfSubtable.class)
56                 .child(RemoteMappings.class)
57                 .child(RemoteMapping.class);
58
59         validBdRemote = InstanceIdentifier.create(BridgeDomainSubtable.class)
60                 .child(RemoteMappings.class)
61                 .child(RemoteMapping.class);
62
63         invalidRemote = InstanceIdentifier.create(RemoteMapping.class);
64     }
65
66     @Test
67     public void testVrfLocalValid() {
68         assertEquals(VRF_MAPPINGS_ONLY, subtableFilterForLocalMappings(validVrfLocal));
69     }
70
71     @Test
72     public void testBridgeDomainLocalValid() {
73         assertEquals(BRIDGE_DOMAIN_MAPPINGS_ONLY, subtableFilterForLocalMappings(validBdLocal));
74     }
75
76     @Test(expected = IllegalArgumentException.class)
77     public void testLocalInvalid() {
78         subtableFilterForLocalMappings(invalidLocal);
79     }
80
81     @Test
82     public void testVrfRemoteValid() {
83         assertEquals(VRF_MAPPINGS_ONLY, subtableFilterForRemoteMappings(validVrfRemote));
84     }
85
86     @Test
87     public void testBridgeDomainRemoteValid() {
88         assertEquals(BRIDGE_DOMAIN_MAPPINGS_ONLY, subtableFilterForRemoteMappings(validBdRemote));
89     }
90
91     @Test(expected = IllegalArgumentException.class)
92     public void testRemoteInvalid() {
93         subtableFilterForRemoteMappings(invalidRemote);
94     }
95 }