Avoid unnecessary state transition

Change state from WithdrawRequest to Withdrawn directly when
there is nothing in the store with the key

Change-Id: Ia38d02bcff8df7aad35fbb975843c6741ff540f4
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/WithdrawCoordinating.java b/core/net/src/main/java/org/onosproject/net/intent/impl/WithdrawCoordinating.java
index 5860d80..2515a35 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/WithdrawCoordinating.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/WithdrawCoordinating.java
@@ -17,7 +17,6 @@
 
 import org.onosproject.net.flow.FlowRuleOperations;
 import org.onosproject.net.intent.IntentData;
-import org.onosproject.net.intent.IntentState;
 
 import java.util.Optional;
 
@@ -37,14 +36,11 @@
     WithdrawCoordinating(IntentManager intentManager, IntentData pending, IntentData current) {
         this.intentManager = checkNotNull(intentManager);
         this.pending = checkNotNull(pending);
-        this.current = current;
+        this.current = checkNotNull(current);
     }
 
     @Override
     public Optional<IntentUpdate> execute() {
-        if (current == null) { // there's nothing in the store with this key
-            return Optional.of(new Withdrawn(pending, IntentState.WITHDRAWN));
-        }
         FlowRuleOperations flowRules = intentManager.uninstallCoordinate(current, pending);
         pending.setInstallables(current.installables());
         return Optional.of(new Withdrawing(intentManager, pending, flowRules));
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/WithdrawRequest.java b/core/net/src/main/java/org/onosproject/net/intent/impl/WithdrawRequest.java
index 2eb541a..5af60dc 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/WithdrawRequest.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/WithdrawRequest.java
@@ -20,6 +20,7 @@
 import java.util.Optional;
 
 import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onosproject.net.intent.IntentState.WITHDRAWN;
 
 /**
  * Represents a phase of requesting a withdraw of an intent.
@@ -39,6 +40,9 @@
     public Optional<IntentUpdate> execute() {
         //FIXME need store interface
         IntentData current = intentManager.store.getIntentData(pending.key());
+        if (current == null) {
+            return Optional.of(new Withdrawn(pending, WITHDRAWN));
+        }
         //TODO perhaps we want to validate that the pending and current are the
         // same version i.e. they are the same
         // Note: this call is not just the symmetric version of submit