[ONOS-5919] (vCore) separate Intent store

Change-Id: I3b5b67d7286dafdf11bf3d8d4acafb59a3034e22
diff --git a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkIntentManagerTest.java b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkIntentManagerTest.java
index 4b7cf84..3b59e9a 100644
--- a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkIntentManagerTest.java
+++ b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkIntentManagerTest.java
@@ -37,8 +37,10 @@
 import org.onosproject.incubator.net.virtual.VirtualLink;
 import org.onosproject.incubator.net.virtual.VirtualNetwork;
 import org.onosproject.incubator.net.virtual.VirtualNetworkIntent;
+import org.onosproject.incubator.net.virtual.VirtualNetworkIntentStore;
 import org.onosproject.incubator.net.virtual.VirtualNetworkStore;
 import org.onosproject.incubator.store.virtual.impl.DistributedVirtualNetworkStore;
+import org.onosproject.incubator.store.virtual.impl.SimpleVirtualIntentStore;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.DefaultPort;
 import org.onosproject.net.EncapsulationType;
@@ -100,6 +102,7 @@
 
     private VirtualNetworkManager manager;
     private static DistributedVirtualNetworkStore virtualNetworkManagerStore;
+    private VirtualNetworkIntentStore intentStore;
     private CoreService coreService;
     private TestableIntentService intentService = new FakeIntentManager();
     private VirtualNetworkIntentManager vnetIntentService;
@@ -117,6 +120,7 @@
     @Before
     public void setUp() throws Exception {
         virtualNetworkManagerStore = new DistributedVirtualNetworkStore();
+        intentStore = new SimpleVirtualIntentStore();
 
         coreService = new VirtualNetworkIntentManagerTest.TestCoreService();
 
@@ -215,7 +219,7 @@
 
         vnetIntentService = new VirtualNetworkIntentManager(manager, virtualNetwork.id());
         vnetIntentService.intentService = intentService;
-        vnetIntentService.store = virtualNetworkManagerStore;
+        vnetIntentService.intentStore = intentStore;
         vnetIntentService.partitionService = workPartitionService;
         return virtualNetwork;
     }
@@ -347,12 +351,12 @@
             switch (event.type()) {
                 case INSTALLED:
                     // Release one permit on the created semaphore since the Intent event was received.
-                    virtualNetworkManagerStore.addOrUpdateIntent(event.subject(), IntentState.INSTALLED);
+//                    virtualNetworkManagerStore.addOrUpdateIntent(event.subject(), IntentState.INSTALLED);
                     created.release();
                     break;
                 case WITHDRAWN:
                     // Release one permit on the removed semaphore since the Intent event was received.
-                    virtualNetworkManagerStore.addOrUpdateIntent(event.subject(), IntentState.WITHDRAWN);
+//                    virtualNetworkManagerStore.addOrUpdateIntent(event.subject(), IntentState.WITHDRAWN);
                     withdrawn.release();
                     break;
                 case PURGED:
@@ -396,4 +400,15 @@
             super(APP_ID, Collections.singletonList(new IntentTestsMocks.MockFlowRule(100)), Collections.emptyList());
         }
     }
+
+//    private void addOrUpdateIntent(Intent intent, IntentState state) {
+//        checkNotNull(intent, "Intent cannot be null");
+//        IntentData intentData = intentStore.(intent.key());
+//        if (intentData == null) {
+//            intentData = new IntentData(intent, state, new WallClockTimestamp(System.currentTimeMillis()));
+//        } else {
+//            intentData = new IntentData(intent, state, intentData.version());
+//        }
+//        intentKeyIntentDataMap.put(intent.key(), intentData);
+//    }
 }
diff --git a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkManagerTest.java b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkManagerTest.java
index 765b4cb..9d4086e 100644
--- a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkManagerTest.java
+++ b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkManagerTest.java
@@ -71,7 +71,6 @@
 import org.onosproject.net.host.HostService;
 import org.onosproject.net.intent.FakeIntentManager;
 import org.onosproject.net.intent.IntentService;
-import org.onosproject.net.intent.IntentState;
 import org.onosproject.net.intent.Key;
 import org.onosproject.net.intent.MockIdGenerator;
 import org.onosproject.net.intent.TestableIntentService;
@@ -684,57 +683,6 @@
         assertTrue("The virtual network set should be empty.", virtualNetworks.isEmpty());
     }
 
-
-    /**
-     * Tests the addOrUpdateIntent() method in the store with a null intent.
-     */
-    @Test(expected = NullPointerException.class)
-    public void testAddOrUpdateNullIntent() {
-        manager.store.addOrUpdateIntent(null, null);
-    }
-
-    /**
-     * Tests the removeIntent() method in the store with a null intent key.
-     */
-    @Test(expected = NullPointerException.class)
-    public void testRemoveNullIntentKey() {
-        manager.store.removeIntent(null);
-    }
-
-    /**
-     * Tests the addOrUpdateIntent(), getIntents(), getIntent(), removeIntent() methods with the store.
-     */
-    @Test
-    public void testAddOrUpdateIntent() {
-        manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
-        VirtualNetwork virtualNetwork =
-                manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
-        ConnectPoint cp1 = new ConnectPoint(DID1, P1);
-        ConnectPoint cp2 = new ConnectPoint(DID2, P1);
-
-        VirtualNetworkIntent virtualIntent = VirtualNetworkIntent.builder()
-                .networkId(virtualNetwork.id())
-                .key(Key.of("Test", APP_ID))
-                .appId(APP_ID)
-                .ingressPoint(cp1)
-                .egressPoint(cp2)
-                .build();
-
-        // Add the intent to the store.
-        manager.store.addOrUpdateIntent(virtualIntent, IntentState.INSTALL_REQ);
-        assertEquals("The intent size should match.", 1,
-                     manager.store.getIntents().size());
-        assertNotNull("The intent should not be null.",
-                      manager.store.getIntent(virtualIntent.key()));
-
-        // remove the intent from the store.
-        manager.store.removeIntent(virtualIntent.key());
-        assertTrue("The intents should be empty.",
-                   manager.store.getIntents().isEmpty());
-        assertNull("The intent should be null.",
-                   manager.store.getIntent(virtualIntent.key()));
-    }
-
     /**
      * Tests the addTunnelId() method in the store with a null intent.
      */