2 * Copyright (c) 2018 AT&T Intellectual Property. 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
8 package org.opendaylight.protocol.bgp.openconfig.routing.policy.statement;
10 import static org.opendaylight.bgpcep.config.loader.routing.policy.OpenconfigRoutingPolicyLoader.ROUTING_POLICY_IID;
12 import java.util.List;
13 import java.util.concurrent.ExecutionException;
14 import org.junit.Before;
15 import org.opendaylight.bgpcep.config.loader.routing.policy.AbstractOpenconfigRoutingPolicyLoaderTest;
16 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
17 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
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;
24 public class AbstractStatementRegistryConsumerTest extends AbstractOpenconfigRoutingPolicyLoaderTest {
25 protected StatementRegistry statementRegistry;
29 public void setUp() throws Exception {
31 this.statementRegistry = new StatementRegistry(getDataBroker());
32 final StatementActivator activator = new StatementActivator(getDataBroker());
33 activator.start(this.statementRegistry);
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)))
41 return policy.getStatements().getStatement();