c884bc1bf9de220bccdc14e276cf838723499edf
[groupbasedpolicy.git] / renderers / ofoverlay / src / test / java / org / opendaylight / groupbasedpolicy / renderer / ofoverlay / flow / FlowTableTest.java
1 /*\r
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 \r
9 package org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow;\r
10 \r
11 import java.util.Map;\r
12 \r
13 import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.PolicyManager.FlowMap;\r
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;\r
15 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;\r
17 \r
18 public class FlowTableTest extends OfTableTest {\r
19     FlowTable table;\r
20     InstanceIdentifier<Table> tiid;\r
21 \r
22     protected void setup() throws Exception {\r
23         tiid = FlowUtils.createTablePath(nodeId,\r
24                                          table.getTableId());\r
25     }\r
26 \r
27     protected FlowMap dosync(Map<String, Flow> flows) throws Exception {\r
28         FlowMap flowMap = policyManager.new FlowMap();\r
29         if (flows != null) {\r
30             for (String key : flows.keySet()) {\r
31                 Flow flow = flows.get(key);\r
32                 if (flow != null) {\r
33                     flowMap.writeFlow(nodeId, flow.getTableId(), flow);\r
34                 }\r
35             }\r
36         }\r
37         table.sync(nodeId, policyResolver.getCurrentPolicy(), flowMap);\r
38         return flowMap;\r
39     }\r
40 }\r