Fixed SDN-IP tests after ONOS-874 merge.
Change-Id: Ie14f64ecf7f9bc72120f837ef9cd2b8904cc4bd2
diff --git a/apps/sdnip/src/test/java/org/onosproject/sdnip/IntentSyncTest.java b/apps/sdnip/src/test/java/org/onosproject/sdnip/IntentSyncTest.java
index 1af0914..857f49a 100644
--- a/apps/sdnip/src/test/java/org/onosproject/sdnip/IntentSyncTest.java
+++ b/apps/sdnip/src/test/java/org/onosproject/sdnip/IntentSyncTest.java
@@ -17,7 +17,6 @@
import com.google.common.collect.Sets;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.onlab.junit.TestUtils;
import org.onlab.junit.TestUtils.TestUtilsException;
@@ -59,13 +58,16 @@
import static org.easymock.EasyMock.*;
import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.onosproject.sdnip.TestIntentServiceHelper.eqExceptId;
/**
* This class tests the intent synchronization function in the
* IntentSynchronizer class.
*/
-@Ignore //FIXME
public class IntentSyncTest extends AbstractIntentTest {
private SdnIpConfigurationService sdnIpConfigService;
@@ -237,11 +239,7 @@
ingressPoints, SW1_ETH1);
// Setup the expected intents
-// FIXME Jono needs to refactor
-// IntentOperations.Builder builder = IntentOperations.builder(APPID);
-// builder.addSubmitOperation(intent);
-// intentService.execute(TestIntentServiceHelper.eqExceptId(
-// builder.build()));
+ intentService.submit(eqExceptId(intent));
replay(intentService);
intentSynchronizer.leaderChanged(true);
@@ -299,11 +297,8 @@
ingressPoints, SW4_ETH1);
// Setup the expected intents
-// FIXME Jono needs to refactor
-// IntentOperations.Builder builder = IntentOperations.builder(APPID);
-// builder.addSubmitOperation(intent);
-// intentService.execute(
-// TestIntentServiceHelper.eqExceptId(builder.build()));
+ intentService.submit(eqExceptId(intent));
+
replay(intentService);
// Run the test
@@ -371,15 +366,8 @@
// Set up test expectation
reset(intentService);
// Setup the expected intents
-// FIXME Jono needs to refactor
-// IntentOperations.Builder builder = IntentOperations.builder(APPID);
-// builder.addWithdrawOperation(addedIntent.id());
-// intentService.execute(TestIntentServiceHelper.eqExceptId(
-// builder.build()));
-// builder = IntentOperations.builder(APPID);
-// builder.addSubmitOperation(intentNew);
-// intentService.execute(TestIntentServiceHelper.eqExceptId(
-// builder.build()));
+ intentService.withdraw(eqExceptId(addedIntent));
+ intentService.submit(eqExceptId(intentNew));
replay(intentService);
// Call the update() method in IntentSynchronizer class
@@ -423,11 +411,7 @@
// Set up expectation
reset(intentService);
// Setup the expected intents
-// FIXME Jono needs to refactor
-// IntentOperations.Builder builder = IntentOperations.builder(APPID);
-// builder.addWithdrawOperation(addedIntent.id());
-// intentService.execute(TestIntentServiceHelper.eqExceptId(
-// builder.build()));
+ intentService.withdraw(eqExceptId(addedIntent));
replay(intentService);
// Call the update() method in IntentSynchronizer class
diff --git a/apps/sdnip/src/test/java/org/onosproject/sdnip/PeerConnectivityManagerTest.java b/apps/sdnip/src/test/java/org/onosproject/sdnip/PeerConnectivityManagerTest.java
index 0088d92..ed703b9 100644
--- a/apps/sdnip/src/test/java/org/onosproject/sdnip/PeerConnectivityManagerTest.java
+++ b/apps/sdnip/src/test/java/org/onosproject/sdnip/PeerConnectivityManagerTest.java
@@ -54,11 +54,11 @@
import java.util.Map;
import static org.easymock.EasyMock.*;
+import static org.onosproject.sdnip.TestIntentServiceHelper.eqExceptId;
/**
* Unit tests for PeerConnectivityManager.
*/
-@Ignore
public class PeerConnectivityManagerTest extends AbstractIntentTest {
private static final ApplicationId APPID = new ApplicationId() {
@@ -571,7 +571,7 @@
// Setup the expected intents
for (Intent intent : intentList) {
- intentService.submit(intent);
+ intentService.submit(eqExceptId(intent));
}
replay(intentService);
diff --git a/apps/sdnip/src/test/java/org/onosproject/sdnip/TestIntentServiceHelper.java b/apps/sdnip/src/test/java/org/onosproject/sdnip/TestIntentServiceHelper.java
index 98ce292..feb10fe 100644
--- a/apps/sdnip/src/test/java/org/onosproject/sdnip/TestIntentServiceHelper.java
+++ b/apps/sdnip/src/test/java/org/onosproject/sdnip/TestIntentServiceHelper.java
@@ -43,20 +43,6 @@
return intent;
}
- /**
- * Matcher method to set the expected intent operations to match against
- * (ignoring the intent ID for each intent).
- *
- * param intentOperations the expected Intent Operations
- * @return the submitted Intent Operations
- */
- /*
- static IntentOperations eqExceptId(IntentOperations intentOperations) {
- reportMatcher(new IdAgnosticIntentOperationsMatcher(intentOperations));
- return intentOperations;
- }
- */
-
/*
* EasyMock matcher that matches {@link Intent} but
* ignores the {@link IntentId} when matching.
@@ -67,6 +53,8 @@
* the solution is to use an EasyMock matcher that verifies that all the
* value properties of the provided intent match the expected values, but
* ignores the intent ID when testing equality.
+ *
+ * FIXME this currently does not take key into account
*/
private static final class IdAgnosticIntentMatcher implements
IArgumentMatcher {
@@ -104,109 +92,4 @@
}
}
- /*
- * EasyMock matcher that matches {@link IntenOperations} but
- * ignores the {@link IntentId} when matching.
- * <p/>
- * The normal intent equals method tests that the intent IDs are equal,
- * however in these tests we can't know what the intent IDs will be in
- * advance, so we can't set up expected intents with the correct IDs. Thus,
- * the solution is to use an EasyMock matcher that verifies that all the
- * value properties of the provided intent match the expected values, but
- * ignores the intent ID when testing equality.
- */
- /*
- private static final class IdAgnosticIntentOperationsMatcher implements
- IArgumentMatcher {
-
- //private final IntentOperations intentOperations;
- private String providedString;
-
- @Override
- public void appendTo(StringBuffer strBuffer) {
- strBuffer.append("IntentOperationsMatcher unable to match: "
- + providedString);
- }
-
- @Override
- public boolean matches(Object object) {
- if (!(object instanceof IntentOperations)) {
- return false;
- }
-
- IntentOperations providedIntentOperations =
- (IntentOperations) object;
- providedString = providedIntentOperations.toString();
-
- List<IntentKey> thisSubmitIntents = new LinkedList<>();
- List<IntentId> thisWithdrawIntentIds = new LinkedList<>();
- List<IntentKey> thisReplaceIntents = new LinkedList<>();
- List<IntentKey> thisUpdateIntents = new LinkedList<>();
- List<IntentKey> providedSubmitIntents = new LinkedList<>();
- List<IntentId> providedWithdrawIntentIds = new LinkedList<>();
- List<IntentKey> providedReplaceIntents = new LinkedList<>();
- List<IntentKey> providedUpdateIntents = new LinkedList<>();
-
- extractIntents(intentOperations, thisSubmitIntents,
- thisWithdrawIntentIds, thisReplaceIntents,
- thisUpdateIntents);
- extractIntents(providedIntentOperations, providedSubmitIntents,
- providedWithdrawIntentIds, providedReplaceIntents,
- providedUpdateIntents);
-
- return CollectionUtils.isEqualCollection(thisSubmitIntents,
- providedSubmitIntents) &&
- CollectionUtils.isEqualCollection(thisWithdrawIntentIds,
- providedWithdrawIntentIds) &&
- CollectionUtils.isEqualCollection(thisUpdateIntents,
- providedUpdateIntents) &&
- CollectionUtils.isEqualCollection(thisReplaceIntents,
- providedReplaceIntents);
- }
-
-
- /**
- * Extracts the intents per operation type. Each intent is encapsulated
- * in IntentKey so it can be compared by excluding the Intent ID.
- *
- * @param intentOperations the container with the intent operations
- * to extract the intents from
- * @param submitIntents the SUBMIT intents
- * @param withdrawIntentIds the WITHDRAW intents IDs
- * @param replaceIntents the REPLACE intents
- * @param updateIntents the UPDATE intents
- */
- /*
- private void extractIntents(IntentOperations intentOperations,
- List<IntentKey> submitIntents,
- List<IntentId> withdrawIntentIds,
- List<IntentKey> replaceIntents,
- List<IntentKey> updateIntents) {
- for (IntentOperation oper : intentOperations.operations()) {
- IntentId intentId;
- IntentKey intentKey;
- switch (oper.type()) {
- case SUBMIT:
- intentKey = new IntentKey(oper.intent());
- submitIntents.add(intentKey);
- break;
- case WITHDRAW:
- intentId = oper.intentId();
- withdrawIntentIds.add(intentId);
- break;
- case REPLACE:
- intentKey = new IntentKey(oper.intent());
- replaceIntents.add(intentKey);
- break;
- case UPDATE:
- intentKey = new IntentKey(oper.intent());
- updateIntents.add(intentKey);
- break;
- default:
- break;
- }
- }
- }
- }
- */
}