Added range type to subject-feature-definition/parameter
[groupbasedpolicy.git] / renderers / opflex / src / test / java / org / opendaylight / groupbasedpolicy / renderer / opflex / IdentityTest.java
1 /*
2  * Copyright (C) 2014 Cisco Systems, Inc.
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  *  Authors : Thomas Bachman
9  */
10
11 package org.opendaylight.groupbasedpolicy.renderer.opflex;
12
13 import static org.junit.Assert.assertTrue;
14
15 import java.util.List;
16
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.mockito.MockitoAnnotations;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3Address;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23
24
25 /**
26  *
27  */
28 public class IdentityTest {
29     protected static final Logger logger = LoggerFactory.getLogger(IdentityTest.class);
30
31     Identity id;
32
33     @Before
34     public void setUp() throws Exception {
35         MockitoAnnotations.initMocks(this);
36
37     }
38
39     private static final String TEST_IP = "192.168.194.132";
40     private static final String TEST_MAC2 = "11:22:33:44:55:66";
41     private static final String TEST_CONTEXT = "9AC3DB0E-C47A-4409-B1AD-BDE647A29440";
42
43     @Test
44     public void testL3Identity() throws Exception {
45         id = new Identity(TEST_IP);
46         id.setContext(TEST_CONTEXT);
47         assertTrue(id.identityAsString().equals(TEST_IP));
48         assertTrue(id.getL3Context().getValue().equals(TEST_CONTEXT));
49         List<L3Address> lid = id.getL3Addresses();
50         assertTrue(lid.size() == 1);
51         for (L3Address l3addr : lid) {
52             assertTrue(l3addr.getIpAddress().equals(id.getL3Identity()));
53             assertTrue(l3addr.getL3Context().getValue().equals(TEST_CONTEXT));
54         }
55         //L2BridgeDomainId l2bdid = id.getL2Context();
56         //assertTrue(l2bdid.getValue().equals(TEST_CONTEXT));
57     }
58
59     @Test
60     public void testL2Identity() throws Exception {
61         id = new Identity(TEST_MAC2);
62         id.setContext(TEST_CONTEXT);
63         assertTrue(id.identityAsString().equals(TEST_MAC2));
64         assertTrue(id.getL2Identity().getValue().equals(TEST_MAC2));
65
66     }
67
68 }