2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.groupbasedpolicy.resolver;
11 import java.util.Collection;
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;
29 import com.google.common.collect.ImmutableList;
31 import static org.junit.Assert.*;
33 public class IndexedTenantTest {
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");
43 L3Context l3c = new L3ContextBuilder().setId(l3id).build();
44 L2BridgeDomain bd = new L2BridgeDomainBuilder()
47 L2FloodDomain fd = new L2FloodDomainBuilder()
50 Subnet s = new SubnetBuilder()
53 Subnet s2 = new SubnetBuilder()
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))
62 IndexedTenant it = new IndexedTenant(t);
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());