[ONOS-7681] IntentCleanup.resubmitPendingRequest() can not generate pendingMap PUT event, and IntentData processing does not happen.
Change-Id: I4bcaf21581d72e9715443f9089a2940bffdc6df0
diff --git a/core/api/src/main/java/org/onosproject/net/intent/IntentData.java b/core/api/src/main/java/org/onosproject/net/intent/IntentData.java
index cad48ab..2c996c2 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/IntentData.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/IntentData.java
@@ -117,6 +117,17 @@
}
/**
+ * Creates a copy of given IntentData, and update request version.
+ *
+ * @param data intent data to copy
+ * @param reqVersion request version to be updated
+ * @return copy
+ */
+ public static IntentData copy(IntentData data, Timestamp reqVersion) {
+ return new IntentData(data, checkNotNull(reqVersion));
+ }
+
+ /**
* Create a copy of IntentData in next state.
*
* @param data intent data to copy
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/IntentCleanup.java b/core/net/src/main/java/org/onosproject/net/intent/impl/IntentCleanup.java
index 27f38af..823aa3b 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/IntentCleanup.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/IntentCleanup.java
@@ -203,7 +203,7 @@
case INSTALL_REQ:
case WITHDRAW_REQ:
case PURGE_REQ:
- service.addPending(intentData);
+ service.addPending(IntentData.copy(intentData, new WallClockTimestamp()));
break;
default:
log.warn("Failed to resubmit pending intent {} in state {} with request {}",
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/IntentCleanupTestMock.java b/core/net/src/test/java/org/onosproject/net/intent/impl/IntentCleanupTestMock.java
index dcc4188..1ccd3aa 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/IntentCleanupTestMock.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/IntentCleanupTestMock.java
@@ -123,7 +123,8 @@
IntentData data = new IntentData(intent, INSTALL_REQ, version);
store.addPending(data);
- service.addPending(data);
+ service.addPending(isA(IntentData.class));
+
expectLastCall().once();
replay(service);