Refactor tests to use shared mock implementations
Change-Id: Iba4e44b7bb88f8a31add9475a9155f85375ae61a
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/IntentManagerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/IntentManagerTest.java
index 642a66f..4be32c4 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/IntentManagerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/IntentManagerTest.java
@@ -15,12 +15,14 @@
*/
package org.onosproject.net.intent.impl;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Multimap;
-import com.google.common.collect.Sets;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;
import org.junit.After;
@@ -44,26 +46,29 @@
import org.onosproject.net.intent.IntentListener;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.IntentState;
-import org.onosproject.net.intent.IntentTestsMocks;
import org.onosproject.net.intent.Key;
import org.onosproject.net.resource.LinkResourceAllocations;
import org.onosproject.store.intent.impl.SimpleIntentStore;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.Sets;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.onlab.junit.TestTools.assertAfter;
import static org.onlab.util.Tools.delay;
-import static org.onosproject.net.intent.IntentState.*;
+import static org.onosproject.net.intent.IntentState.FAILED;
+import static org.onosproject.net.intent.IntentState.INSTALLED;
+import static org.onosproject.net.intent.IntentState.WITHDRAWN;
+import static org.onosproject.net.intent.IntentTestsMocks.MockFlowRule;
+import static org.onosproject.net.intent.IntentTestsMocks.MockIntent;
/**
* Test intent manager and transitions.
@@ -146,25 +151,6 @@
}
}
- private static class MockIntent extends Intent {
- private static AtomicLong counter = new AtomicLong(0);
-
- private final Long number;
- // Nothing new here
- public MockIntent(Long number) {
- super(APPID, Collections.emptyList());
- this.number = number;
- }
-
- public Long number() {
- return number;
- }
-
- public static Long nextId() {
- return counter.getAndIncrement();
- }
- }
-
private static class MockInstallableIntent extends MockIntent {
public MockInstallableIntent(Long number) {
super(number);
@@ -195,7 +181,7 @@
private static class TestIntentInstaller implements IntentInstaller<MockInstallableIntent> {
@Override
public List<Collection<org.onosproject.net.flow.FlowRuleOperation>> install(MockInstallableIntent intent) {
- FlowRule fr = new IntentTestsMocks.MockFlowRule(intent.number().intValue());
+ FlowRule fr = new MockFlowRule(intent.number().intValue());
Set<FlowRuleOperation> rules = ImmutableSet.of(
new FlowRuleOperation(fr, FlowRuleOperation.Type.ADD));
return Lists.newArrayList(ImmutableSet.of(rules));
@@ -203,7 +189,7 @@
@Override
public List<Collection<FlowRuleOperation>> uninstall(MockInstallableIntent intent) {
- FlowRule fr = new IntentTestsMocks.MockFlowRule(intent.number().intValue());
+ FlowRule fr = new MockFlowRule(intent.number().intValue());
Set<FlowRuleOperation> rules = ImmutableSet.of(
new FlowRuleOperation(fr, FlowRuleOperation.Type.REMOVE));
return Lists.newArrayList(ImmutableSet.of(rules));
@@ -212,8 +198,8 @@
@Override
public List<Collection<FlowRuleOperation>> replace(MockInstallableIntent oldIntent,
MockInstallableIntent newIntent) {
- FlowRule fr = new IntentTestsMocks.MockFlowRule(oldIntent.number().intValue());
- FlowRule fr2 = new IntentTestsMocks.MockFlowRule(newIntent.number().intValue());
+ FlowRule fr = new MockFlowRule(oldIntent.number().intValue());
+ FlowRule fr2 = new MockFlowRule(newIntent.number().intValue());
Set<FlowRuleOperation> rules = ImmutableSet.of(
new FlowRuleOperation(fr, FlowRuleOperation.Type.REMOVE),
new FlowRuleOperation(fr2, FlowRuleOperation.Type.ADD));