Separating renderers into features.
[groupbasedpolicy.git] / renderers / ofoverlay / src / test / java / org / opendaylight / groupbasedpolicy / resolver / IndexedTenantTest.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
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
9 package org.opendaylight.groupbasedpolicy.resolver;
10
11 import java.util.Collection;
12
13 import org.junit.Test;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L2BridgeDomainId;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L2FloodDomainId;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L3ContextId;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.SubnetId;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.Tenant;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.TenantBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.L2BridgeDomain;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.L2BridgeDomainBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.L2FloodDomain;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.L2FloodDomainBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.L3Context;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.L3ContextBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.Subnet;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.SubnetBuilder;
28
29 import com.google.common.collect.ImmutableList;
30
31 import static org.junit.Assert.*;
32
33 public class IndexedTenantTest {
34
35     @Test
36     public void testResolveND() throws Exception {
37         SubnetId sid = new SubnetId("dd25397d-d829-4c8d-8c01-31f129b8de8f");
38         SubnetId sid2 = new SubnetId("c752ba40-40aa-4a47-8138-9b7175b854fa");
39         L3ContextId l3id = new L3ContextId("f2311f52-890f-4095-8b85-485ec8b92b3c");
40         L2BridgeDomainId bdid= new L2BridgeDomainId("70aeb9ea-4ca1-4fb9-9780-22b04b84a0d6");
41         L2FloodDomainId fdid = new L2FloodDomainId("252fbac6-bb6e-4d16-808d-6f56d20e5cca");
42
43         L3Context l3c = new L3ContextBuilder().setId(l3id).build();
44         L2BridgeDomain bd = new L2BridgeDomainBuilder()
45             .setParent(l3id)
46             .setId(bdid).build();
47         L2FloodDomain fd = new L2FloodDomainBuilder()
48             .setParent(bdid)
49             .setId(fdid).build();
50         Subnet s = new SubnetBuilder()
51             .setParent(fdid)
52             .setId(sid).build();
53         Subnet s2 = new SubnetBuilder()
54             .setParent(bdid)
55             .setId(sid2).build();
56         Tenant t = new TenantBuilder()
57             .setSubnet(ImmutableList.of(s, s2))
58             .setL2BridgeDomain(ImmutableList.of(bd))
59             .setL3Context(ImmutableList.of(l3c))
60             .setL2FloodDomain(ImmutableList.of(fd))
61             .build();
62         IndexedTenant it = new IndexedTenant(t);
63
64         assertNotNull(it.getNetworkDomain(sid));
65         Collection<Subnet> sns = it.resolveSubnets(sid);
66         assertTrue(sns.contains(s));
67         assertTrue(sns.contains(s2));
68         assertEquals(l3id, it.resolveL3Context(sid).getId());
69         assertEquals(bdid, it.resolveL2BridgeDomain(sid).getId());
70         assertEquals(fdid, it.resolveL2FloodDomain(sid).getId());
71     }
72 }