Sho SHIMIZU
Committed by Ray Milkey

Remove dependency on LinkResourceService from MplsPathIntentCompiler

In addition, revise test to make the situation more realistic

Change-Id: If23648b77f2eddbe27873711dab3b196a4a2729d
...@@ -24,12 +24,14 @@ import org.apache.felix.scr.annotations.Reference; ...@@ -24,12 +24,14 @@ import org.apache.felix.scr.annotations.Reference;
24 import org.apache.felix.scr.annotations.ReferenceCardinality; 24 import org.apache.felix.scr.annotations.ReferenceCardinality;
25 import org.onlab.packet.EthType; 25 import org.onlab.packet.EthType;
26 import org.onlab.packet.Ethernet; 26 import org.onlab.packet.Ethernet;
27 +import org.onlab.packet.MplsLabel;
27 import org.onlab.packet.VlanId; 28 import org.onlab.packet.VlanId;
28 import org.onosproject.core.ApplicationId; 29 import org.onosproject.core.ApplicationId;
29 import org.onosproject.core.CoreService; 30 import org.onosproject.core.CoreService;
30 import org.onosproject.net.ConnectPoint; 31 import org.onosproject.net.ConnectPoint;
31 import org.onosproject.net.DeviceId; 32 import org.onosproject.net.DeviceId;
32 import org.onosproject.net.Link; 33 import org.onosproject.net.Link;
34 +import org.onosproject.net.LinkKey;
33 import org.onosproject.net.PortNumber; 35 import org.onosproject.net.PortNumber;
34 import org.onosproject.net.flow.DefaultFlowRule; 36 import org.onosproject.net.flow.DefaultFlowRule;
35 import org.onosproject.net.flow.DefaultTrafficSelector; 37 import org.onosproject.net.flow.DefaultTrafficSelector;
...@@ -46,17 +48,9 @@ import org.onosproject.net.intent.Intent; ...@@ -46,17 +48,9 @@ import org.onosproject.net.intent.Intent;
46 import org.onosproject.net.intent.IntentCompiler; 48 import org.onosproject.net.intent.IntentCompiler;
47 import org.onosproject.net.intent.IntentExtensionService; 49 import org.onosproject.net.intent.IntentExtensionService;
48 import org.onosproject.net.intent.MplsPathIntent; 50 import org.onosproject.net.intent.MplsPathIntent;
49 -import org.onosproject.net.link.LinkStore; 51 +import org.onosproject.net.newresource.ResourcePath;
50 -import org.onosproject.net.resource.ResourceRequest; 52 +import org.onosproject.net.newresource.ResourceService;
51 -import org.onosproject.net.resource.link.DefaultLinkResourceRequest;
52 import org.onosproject.net.resource.link.LinkResourceAllocations; 53 import org.onosproject.net.resource.link.LinkResourceAllocations;
53 -import org.onosproject.net.resource.link.LinkResourceRequest;
54 -import org.onosproject.net.resource.link.LinkResourceService;
55 -import org.onosproject.net.resource.link.MplsLabel;
56 -import org.onosproject.net.resource.link.MplsLabelResourceAllocation;
57 -import org.onosproject.net.resource.ResourceAllocation;
58 -import org.onosproject.net.resource.ResourceType;
59 -import org.onosproject.net.resource.link.MplsLabelResourceRequest;
60 import org.slf4j.Logger; 54 import org.slf4j.Logger;
61 55
62 import java.util.Collections; 56 import java.util.Collections;
...@@ -67,9 +61,10 @@ import java.util.List; ...@@ -67,9 +61,10 @@ import java.util.List;
67 import java.util.Map; 61 import java.util.Map;
68 import java.util.Optional; 62 import java.util.Optional;
69 import java.util.Set; 63 import java.util.Set;
70 -import java.util.stream.StreamSupport; 64 +import java.util.stream.Collectors;
71 65
72 import static com.google.common.base.Preconditions.checkNotNull; 66 import static com.google.common.base.Preconditions.checkNotNull;
67 +import static org.onosproject.net.LinkKey.linkKey;
73 import static org.slf4j.LoggerFactory.getLogger; 68 import static org.slf4j.LoggerFactory.getLogger;
74 69
75 @Component(immediate = true) 70 @Component(immediate = true)
...@@ -84,18 +79,15 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { ...@@ -84,18 +79,15 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> {
84 protected CoreService coreService; 79 protected CoreService coreService;
85 80
86 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 81 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
87 - protected LinkResourceService resourceService; 82 + protected ResourceService resourceService;
88 -
89 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
90 - protected LinkStore linkStore;
91 83
92 protected ApplicationId appId; 84 protected ApplicationId appId;
93 85
94 @Override 86 @Override
95 public List<Intent> compile(MplsPathIntent intent, List<Intent> installable, 87 public List<Intent> compile(MplsPathIntent intent, List<Intent> installable,
96 Set<LinkResourceAllocations> resources) { 88 Set<LinkResourceAllocations> resources) {
97 - LinkResourceAllocations allocations = assignMplsLabel(intent); 89 + Map<LinkKey, MplsLabel> labels = assignMplsLabel(intent);
98 - List<FlowRule> rules = generateRules(intent, allocations); 90 + List<FlowRule> rules = generateRules(intent, labels);
99 91
100 return Collections.singletonList(new FlowRuleIntent(appId, rules, intent.resources())); 92 return Collections.singletonList(new FlowRuleIntent(appId, rules, intent.resources()));
101 } 93 }
...@@ -111,30 +103,38 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { ...@@ -111,30 +103,38 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> {
111 intentExtensionService.unregisterCompiler(MplsPathIntent.class); 103 intentExtensionService.unregisterCompiler(MplsPathIntent.class);
112 } 104 }
113 105
114 - private LinkResourceAllocations assignMplsLabel(MplsPathIntent intent) { 106 + private Map<LinkKey, MplsLabel> assignMplsLabel(MplsPathIntent intent) {
115 // TODO: do it better... Suggestions? 107 // TODO: do it better... Suggestions?
116 - Set<Link> linkRequest = Sets.newHashSetWithExpectedSize(intent.path() 108 + Set<LinkKey> linkRequest = Sets.newHashSetWithExpectedSize(intent.path()
117 .links().size() - 2); 109 .links().size() - 2);
118 for (int i = 1; i <= intent.path().links().size() - 2; i++) { 110 for (int i = 1; i <= intent.path().links().size() - 2; i++) {
119 - Link link = intent.path().links().get(i); 111 + LinkKey link = linkKey(intent.path().links().get(i));
120 linkRequest.add(link); 112 linkRequest.add(link);
121 // add the inverse link. I want that the label is reserved both for 113 // add the inverse link. I want that the label is reserved both for
122 // the direct and inverse link 114 // the direct and inverse link
123 - linkRequest.add(linkStore.getLink(link.dst(), link.src())); 115 + linkRequest.add(linkKey(link.dst(), link.src()));
124 } 116 }
125 117
126 - Map<Link, MplsLabel> labels = findMplsLabels(linkRequest); 118 + Map<LinkKey, MplsLabel> labels = findMplsLabels(linkRequest);
119 + if (labels.isEmpty()) {
120 + return Collections.emptyMap();
121 + }
127 122
128 - LinkResourceRequest request = DefaultLinkResourceRequest 123 + List<ResourcePath> resources = labels.entrySet().stream()
129 - .builder(intent.id(), linkRequest) 124 + .map(x -> new ResourcePath(linkKey(x.getKey().src(), x.getKey().src()), x.getValue()))
130 - .addMplsRequest(labels) 125 + .collect(Collectors.toList());
131 - .build(); 126 + List<org.onosproject.net.newresource.ResourceAllocation> allocations =
132 - return resourceService.requestResources(request); 127 + resourceService.allocate(intent.id(), resources);
128 + if (allocations.isEmpty()) {
129 + Collections.emptyMap();
133 } 130 }
134 131
135 - private Map<Link, MplsLabel> findMplsLabels(Set<Link> links) { 132 + return labels;
136 - Map<Link, MplsLabel> labels = new HashMap<>(); 133 + }
137 - for (Link link : links) { 134 +
135 + private Map<LinkKey, MplsLabel> findMplsLabels(Set<LinkKey> links) {
136 + Map<LinkKey, MplsLabel> labels = new HashMap<>();
137 + for (LinkKey link : links) {
138 Optional<MplsLabel> label = findMplsLabel(link); 138 Optional<MplsLabel> label = findMplsLabel(link);
139 if (label.isPresent()) { 139 if (label.isPresent()) {
140 labels.put(link, label.get()); 140 labels.put(link, label.get());
...@@ -144,29 +144,19 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { ...@@ -144,29 +144,19 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> {
144 return labels; 144 return labels;
145 } 145 }
146 146
147 - private Optional<MplsLabel> findMplsLabel(Link link) { 147 + private Optional<MplsLabel> findMplsLabel(LinkKey link) {
148 - Iterable<ResourceRequest> freeLabels = resourceService.getAvailableResources(link); 148 + return resourceService.getAvailableResources(new ResourcePath(link)).stream()
149 - return StreamSupport.stream(freeLabels.spliterator(), false) 149 + .filter(x -> x.lastComponent() instanceof MplsLabel)
150 - .filter(x -> x instanceof MplsLabelResourceRequest) 150 + .map(x -> (MplsLabel) x.lastComponent())
151 - .map(x -> (MplsLabelResourceRequest) x)
152 - .map(MplsLabelResourceRequest::mplsLabel)
153 .findFirst(); 151 .findFirst();
154 } 152 }
155 153
156 - private MplsLabel getMplsLabel(LinkResourceAllocations allocations, Link link) { 154 + private MplsLabel getMplsLabel(Map<LinkKey, MplsLabel> labels, LinkKey link) {
157 - for (ResourceAllocation allocation : allocations 155 + return labels.get(link);
158 - .getResourceAllocation(link)) {
159 - if (allocation.type() == ResourceType.MPLS_LABEL) {
160 - return ((MplsLabelResourceAllocation) allocation).mplsLabel();
161 -
162 - }
163 - }
164 - log.warn("MPLS label was not assigned successfully");
165 - return null;
166 } 156 }
167 157
168 private List<FlowRule> generateRules(MplsPathIntent intent, 158 private List<FlowRule> generateRules(MplsPathIntent intent,
169 - LinkResourceAllocations allocations) { 159 + Map<LinkKey, MplsLabel> labels) {
170 160
171 Iterator<Link> links = intent.path().links().iterator(); 161 Iterator<Link> links = intent.path().links().iterator();
172 Link srcLink = links.next(); 162 Link srcLink = links.next();
...@@ -178,7 +168,7 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { ...@@ -178,7 +168,7 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> {
178 168
179 // Ingress traffic 169 // Ingress traffic
180 // Get the new MPLS label 170 // Get the new MPLS label
181 - MplsLabel mpls = getMplsLabel(allocations, link); 171 + MplsLabel mpls = getMplsLabel(labels, linkKey(link));
182 checkNotNull(mpls); 172 checkNotNull(mpls);
183 MplsLabel prevLabel = mpls; 173 MplsLabel prevLabel = mpls;
184 rules.add(ingressFlow(prev.port(), link, intent, mpls)); 174 rules.add(ingressFlow(prev.port(), link, intent, mpls));
...@@ -192,7 +182,7 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { ...@@ -192,7 +182,7 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> {
192 if (links.hasNext()) { 182 if (links.hasNext()) {
193 // Transit traffic 183 // Transit traffic
194 // Get the new MPLS label 184 // Get the new MPLS label
195 - mpls = getMplsLabel(allocations, link); 185 + mpls = getMplsLabel(labels, linkKey(link));
196 checkNotNull(mpls); 186 checkNotNull(mpls);
197 rules.add(transitFlow(prev.port(), link, intent, 187 rules.add(transitFlow(prev.port(), link, intent,
198 prevLabel, mpls)); 188 prevLabel, mpls));
...@@ -210,7 +200,8 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { ...@@ -210,7 +200,8 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> {
210 } 200 }
211 201
212 private FlowRule ingressFlow(PortNumber inPort, Link link, 202 private FlowRule ingressFlow(PortNumber inPort, Link link,
213 - MplsPathIntent intent, MplsLabel label) { 203 + MplsPathIntent intent,
204 + MplsLabel label) {
214 205
215 TrafficSelector.Builder ingressSelector = DefaultTrafficSelector 206 TrafficSelector.Builder ingressSelector = DefaultTrafficSelector
216 .builder(intent.selector()); 207 .builder(intent.selector());
...@@ -222,10 +213,10 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { ...@@ -222,10 +213,10 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> {
222 .matchMplsLabel(intent.ingressLabel().get()); 213 .matchMplsLabel(intent.ingressLabel().get());
223 214
224 // Swap the MPLS label 215 // Swap the MPLS label
225 - treat.setMpls(label.label()); 216 + treat.setMpls(label);
226 } else { 217 } else {
227 // Push and set the MPLS label 218 // Push and set the MPLS label
228 - treat.pushMpls().setMpls(label.label()); 219 + treat.pushMpls().setMpls(label);
229 } 220 }
230 // Add the output action 221 // Add the output action
231 treat.setOutput(link.src().port()); 222 treat.setOutput(link.src().port());
...@@ -242,13 +233,13 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { ...@@ -242,13 +233,13 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> {
242 // assigned in the previous link 233 // assigned in the previous link
243 TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); 234 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
244 selector.matchInPort(inPort).matchEthType(Ethernet.MPLS_UNICAST) 235 selector.matchInPort(inPort).matchEthType(Ethernet.MPLS_UNICAST)
245 - .matchMplsLabel(prevLabel.label()); 236 + .matchMplsLabel(prevLabel);
246 TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder(); 237 TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder();
247 238
248 // Set the new label only if the label on the packet is 239 // Set the new label only if the label on the packet is
249 // different 240 // different
250 if (!prevLabel.equals(outLabel)) { 241 if (!prevLabel.equals(outLabel)) {
251 - treat.setMpls(outLabel.label()); 242 + treat.setMpls(outLabel);
252 } 243 }
253 244
254 treat.setOutput(link.src().port()); 245 treat.setOutput(link.src().port());
...@@ -263,7 +254,7 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { ...@@ -263,7 +254,7 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> {
263 254
264 TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); 255 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
265 selector.matchInPort(inPort).matchEthType(Ethernet.MPLS_UNICAST) 256 selector.matchInPort(inPort).matchEthType(Ethernet.MPLS_UNICAST)
266 - .matchMplsLabel(prevLabel.label()); 257 + .matchMplsLabel(prevLabel);
267 258
268 // apply the intent's treatments 259 // apply the intent's treatments
269 TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder(intent 260 TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder(intent
......
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.net.intent.impl.compiler;
17 +
18 +import com.google.common.collect.ImmutableList;
19 +import org.onlab.packet.MplsLabel;
20 +import org.onosproject.net.newresource.ResourceAllocation;
21 +import org.onosproject.net.newresource.ResourceConsumer;
22 +import org.onosproject.net.newresource.ResourcePath;
23 +import org.onosproject.net.newresource.ResourceService;
24 +
25 +import java.util.Collection;
26 +import java.util.HashMap;
27 +import java.util.List;
28 +import java.util.Map;
29 +import java.util.Optional;
30 +import java.util.stream.Collectors;
31 +
32 +class MockResourceService implements ResourceService {
33 +
34 + private final Map<ResourcePath, ResourceConsumer> assignment = new HashMap<>();
35 +
36 + @Override
37 + public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<ResourcePath> resources) {
38 + assignment.putAll(
39 + resources.stream().collect(Collectors.toMap(x -> x, x -> consumer))
40 + );
41 +
42 + return resources.stream()
43 + .map(x -> new ResourceAllocation(x, consumer))
44 + .collect(Collectors.toList());
45 + }
46 +
47 + @Override
48 + public boolean release(List<ResourceAllocation> allocations) {
49 + allocations.forEach(x -> assignment.remove(x.resource()));
50 +
51 + return true;
52 + }
53 +
54 + @Override
55 + public boolean release(ResourceConsumer consumer) {
56 + List<ResourcePath> resources = assignment.entrySet().stream()
57 + .filter(x -> x.getValue().equals(consumer))
58 + .map(Map.Entry::getKey)
59 + .collect(Collectors.toList());
60 + List<ResourceAllocation> allocations = resources.stream()
61 + .map(x -> new ResourceAllocation(x, consumer))
62 + .collect(Collectors.toList());
63 +
64 + return release(allocations);
65 + }
66 +
67 + @Override
68 + public Optional<ResourceAllocation> getResourceAllocation(ResourcePath resource) {
69 + return Optional.ofNullable(assignment.get(resource))
70 + .map(x -> new ResourceAllocation(resource, x));
71 + }
72 +
73 + @Override
74 + public <T> Collection<ResourceAllocation> getResourceAllocations(ResourcePath parent, Class<T> cls) {
75 + return assignment.entrySet().stream()
76 + .filter(x -> x.getKey().parent().isPresent())
77 + .filter(x -> x.getKey().parent().get().equals(parent))
78 + .map(x -> new ResourceAllocation(x.getKey(), x.getValue()))
79 + .collect(Collectors.toList());
80 + }
81 +
82 + @Override
83 + public Collection<ResourceAllocation> getResourceAllocations(ResourceConsumer consumer) {
84 + return assignment.entrySet().stream()
85 + .filter(x -> x.getValue().equals(consumer))
86 + .map(x -> new ResourceAllocation(x.getKey(), x.getValue()))
87 + .collect(Collectors.toList());
88 + }
89 +
90 + @Override
91 + public Collection<ResourcePath> getAvailableResources(ResourcePath parent) {
92 + ResourcePath resource = ResourcePath.child(parent, MplsLabel.mplsLabel(10));
93 + return ImmutableList.of(resource);
94 + }
95 +
96 + @Override
97 + public boolean isAvailable(ResourcePath resource) {
98 + return true;
99 + }
100 +}
...@@ -41,10 +41,8 @@ import org.onosproject.net.flow.TrafficTreatment; ...@@ -41,10 +41,8 @@ import org.onosproject.net.flow.TrafficTreatment;
41 import org.onosproject.net.intent.FlowRuleIntent; 41 import org.onosproject.net.intent.FlowRuleIntent;
42 import org.onosproject.net.intent.Intent; 42 import org.onosproject.net.intent.Intent;
43 import org.onosproject.net.intent.IntentExtensionService; 43 import org.onosproject.net.intent.IntentExtensionService;
44 -import org.onosproject.net.intent.IntentTestsMocks;
45 import org.onosproject.net.intent.MockIdGenerator; 44 import org.onosproject.net.intent.MockIdGenerator;
46 import org.onosproject.net.intent.MplsPathIntent; 45 import org.onosproject.net.intent.MplsPathIntent;
47 -import org.onosproject.store.trivial.SimpleLinkStore;
48 46
49 import static org.easymock.EasyMock.createMock; 47 import static org.easymock.EasyMock.createMock;
50 import static org.easymock.EasyMock.expect; 48 import static org.easymock.EasyMock.expect;
...@@ -52,6 +50,7 @@ import static org.easymock.EasyMock.replay; ...@@ -52,6 +50,7 @@ import static org.easymock.EasyMock.replay;
52 import static org.hamcrest.MatcherAssert.assertThat; 50 import static org.hamcrest.MatcherAssert.assertThat;
53 import static org.hamcrest.Matchers.hasSize; 51 import static org.hamcrest.Matchers.hasSize;
54 import static org.hamcrest.Matchers.is; 52 import static org.hamcrest.Matchers.is;
53 +import static org.onosproject.net.DefaultEdgeLink.createEdgeLink;
55 import static org.onosproject.net.Link.Type.DIRECT; 54 import static org.onosproject.net.Link.Type.DIRECT;
56 import static org.onosproject.net.NetTestTools.APP_ID; 55 import static org.onosproject.net.NetTestTools.APP_ID;
57 import static org.onosproject.net.NetTestTools.PID; 56 import static org.onosproject.net.NetTestTools.PID;
...@@ -61,10 +60,12 @@ public class MplsPathIntentCompilerTest { ...@@ -61,10 +60,12 @@ public class MplsPathIntentCompilerTest {
61 60
62 private final ApplicationId appId = new TestApplicationId("test"); 61 private final ApplicationId appId = new TestApplicationId("test");
63 62
63 + private final ConnectPoint d1pi = connectPoint("s1", 100);
64 private final ConnectPoint d1p1 = connectPoint("s1", 0); 64 private final ConnectPoint d1p1 = connectPoint("s1", 0);
65 private final ConnectPoint d2p0 = connectPoint("s2", 0); 65 private final ConnectPoint d2p0 = connectPoint("s2", 0);
66 private final ConnectPoint d2p1 = connectPoint("s2", 1); 66 private final ConnectPoint d2p1 = connectPoint("s2", 1);
67 private final ConnectPoint d3p1 = connectPoint("s3", 1); 67 private final ConnectPoint d3p1 = connectPoint("s3", 1);
68 + private final ConnectPoint d3pe = connectPoint("s3", 100);
68 69
69 private final TrafficSelector selector = DefaultTrafficSelector.builder().build(); 70 private final TrafficSelector selector = DefaultTrafficSelector.builder().build();
70 private final TrafficTreatment treatment = DefaultTrafficTreatment.builder().build(); 71 private final TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
...@@ -75,8 +76,10 @@ public class MplsPathIntentCompilerTest { ...@@ -75,8 +76,10 @@ public class MplsPathIntentCompilerTest {
75 Optional.of(MplsLabel.mplsLabel(20)); 76 Optional.of(MplsLabel.mplsLabel(20));
76 77
77 private final List<Link> links = Arrays.asList( 78 private final List<Link> links = Arrays.asList(
79 + createEdgeLink(d1pi, true),
78 new DefaultLink(PID, d1p1, d2p0, DIRECT), 80 new DefaultLink(PID, d1p1, d2p0, DIRECT),
79 - new DefaultLink(PID, d2p1, d3p1, DIRECT) 81 + new DefaultLink(PID, d2p1, d3p1, DIRECT),
82 + createEdgeLink(d3pe, false)
80 ); 83 );
81 84
82 private IdGenerator idGenerator = new MockIdGenerator(); 85 private IdGenerator idGenerator = new MockIdGenerator();
...@@ -92,8 +95,7 @@ public class MplsPathIntentCompilerTest { ...@@ -92,8 +95,7 @@ public class MplsPathIntentCompilerTest {
92 expect(coreService.registerApplication("org.onosproject.net.intent")) 95 expect(coreService.registerApplication("org.onosproject.net.intent"))
93 .andReturn(appId); 96 .andReturn(appId);
94 sut.coreService = coreService; 97 sut.coreService = coreService;
95 - sut.linkStore = new SimpleLinkStore(); 98 + sut.resourceService = new MockResourceService();
96 - sut.resourceService = new IntentTestsMocks.MockResourceService();
97 99
98 Intent.bindIdGenerator(idGenerator); 100 Intent.bindIdGenerator(idGenerator);
99 101
...@@ -128,7 +130,7 @@ public class MplsPathIntentCompilerTest { ...@@ -128,7 +130,7 @@ public class MplsPathIntentCompilerTest {
128 assertThat(compiled, hasSize(1)); 130 assertThat(compiled, hasSize(1));
129 131
130 Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules(); 132 Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
131 - assertThat(rules, hasSize(1)); 133 + assertThat(rules, hasSize(3));
132 134
133 FlowRule rule = rules.stream() 135 FlowRule rule = rules.stream()
134 .filter(x -> x.deviceId().equals(d2p0.deviceId())) 136 .filter(x -> x.deviceId().equals(d2p0.deviceId()))
...@@ -139,4 +141,5 @@ public class MplsPathIntentCompilerTest { ...@@ -139,4 +141,5 @@ public class MplsPathIntentCompilerTest {
139 sut.deactivate(); 141 sut.deactivate();
140 142
141 } 143 }
144 +
142 } 145 }
......