Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame^] | 1 | package org.onlab.onos.net.intent.impl; |
| 2 | |
| 3 | import com.google.common.collect.Sets; |
| 4 | import com.google.common.util.concurrent.Futures; |
| 5 | import org.onlab.onos.core.ApplicationId; |
| 6 | import org.onlab.onos.net.DeviceId; |
| 7 | import org.onlab.onos.net.flow.CompletedBatchOperation; |
| 8 | import org.onlab.onos.net.flow.FlowEntry; |
| 9 | import org.onlab.onos.net.flow.FlowRule; |
| 10 | import org.onlab.onos.net.flow.FlowRuleBatchEntry; |
| 11 | import org.onlab.onos.net.flow.FlowRuleBatchOperation; |
| 12 | import org.onlab.onos.net.flow.FlowRuleListener; |
| 13 | import org.onlab.onos.net.flow.FlowRuleService; |
| 14 | |
| 15 | import java.util.Collections; |
| 16 | import java.util.Set; |
| 17 | import java.util.concurrent.Future; |
| 18 | |
| 19 | |
| 20 | public class MockFlowRuleService implements FlowRuleService { |
| 21 | |
| 22 | private Future<CompletedBatchOperation> future; |
| 23 | final Set<FlowRule> flows = Sets.newHashSet(); |
| 24 | |
| 25 | public void setFuture(boolean success) { |
| 26 | future = Futures.immediateFuture(new CompletedBatchOperation(true, Collections.emptySet())); |
| 27 | } |
| 28 | |
| 29 | @Override |
| 30 | public Future<CompletedBatchOperation> applyBatch(FlowRuleBatchOperation batch) { |
| 31 | for (FlowRuleBatchEntry fbe : batch.getOperations()) { |
| 32 | FlowRule fr = fbe.getTarget(); |
| 33 | switch (fbe.getOperator()) { |
| 34 | case ADD: |
| 35 | flows.add(fr); |
| 36 | break; |
| 37 | case REMOVE: |
| 38 | flows.remove(fr); |
| 39 | break; |
| 40 | case MODIFY: |
| 41 | break; |
| 42 | default: |
| 43 | break; |
| 44 | } |
| 45 | } |
| 46 | return future; |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | public int getFlowRuleCount() { |
| 51 | return flows.size(); |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public Iterable<FlowEntry> getFlowEntries(DeviceId deviceId) { |
| 56 | return null; |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public void applyFlowRules(FlowRule... flowRules) { |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public void removeFlowRules(FlowRule... flowRules) { |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public void removeFlowRulesById(ApplicationId appId) { |
| 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public Iterable<FlowRule> getFlowRulesById(ApplicationId id) { |
| 73 | return null; |
| 74 | } |
| 75 | |
| 76 | @Override |
| 77 | public Iterable<FlowRule> getFlowRulesByGroupId(ApplicationId appId, short groupId) { |
| 78 | return null; |
| 79 | } |
| 80 | |
| 81 | @Override |
| 82 | public void addListener(FlowRuleListener listener) { |
| 83 | |
| 84 | } |
| 85 | |
| 86 | @Override |
| 87 | public void removeListener(FlowRuleListener listener) { |
| 88 | |
| 89 | } |
| 90 | } |
| 91 | |