BGPCEP-754: Start using default import policy
[bgpcep.git] / bgp / openconfig-rp-statement / src / test / java / org / opendaylight / protocol / bgp / openconfig / routing / policy / statement / AbstractStatementRegistryConsumerTest.java
1 /*
2  * Copyright (c) 2018 AT&T Intellectual Property. 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 package org.opendaylight.protocol.bgp.openconfig.routing.policy.statement;
9
10 import static org.opendaylight.bgpcep.config.loader.routing.policy.OpenconfigRoutingPolicyLoader.ROUTING_POLICY_IID;
11
12 import java.util.List;
13 import java.util.concurrent.ExecutionException;
14 import org.junit.Before;
15 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
16 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
17 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.AbstractStatementRegistryTest;
18 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.StatementRegistry;
19 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.PolicyDefinitions;
20 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.PolicyDefinition;
21 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.PolicyDefinitionKey;
22 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
23
24 public class AbstractStatementRegistryConsumerTest extends AbstractStatementRegistryTest {
25     protected StatementRegistry statementRegistry;
26
27     @Before
28     @Override
29     public void setUp() throws Exception {
30         super.setUp();
31         this.statementRegistry = new StatementRegistry(getDataBroker());
32         final StatementActivator activator = new StatementActivator(getDataBroker());
33         activator.start(this.statementRegistry);
34     }
35
36     protected List<Statement> loadStatement(final String policyName) throws ExecutionException, InterruptedException {
37         final ReadWriteTransaction rt = getDataBroker().newReadWriteTransaction();
38         final PolicyDefinition policy = rt.read(LogicalDatastoreType.CONFIGURATION, ROUTING_POLICY_IID
39                 .child(PolicyDefinitions.class).child(PolicyDefinition.class, new PolicyDefinitionKey(policyName)))
40                 .get().get();
41         return policy.getStatements().getStatement();
42     }
43
44 }