Add intent state to JSON output

Change-Id: I3a5995e0dfdc83e1253b8e414e825b796a57264c
diff --git a/web/api/src/test/java/org/onosproject/rest/IntentsResourceTest.java b/web/api/src/test/java/org/onosproject/rest/IntentsResourceTest.java
index 3307d20..08a6ce5 100644
--- a/web/api/src/test/java/org/onosproject/rest/IntentsResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/IntentsResourceTest.java
@@ -35,6 +35,7 @@
 import org.onosproject.net.NetworkResource;
 import org.onosproject.net.intent.Intent;
 import org.onosproject.net.intent.IntentService;
+import org.onosproject.net.intent.IntentState;
 import org.onosproject.net.intent.Key;
 import org.onosproject.net.intent.MockIdGenerator;
 
@@ -44,6 +45,7 @@
 import com.sun.jersey.api.client.UniformInterfaceException;
 import com.sun.jersey.api.client.WebResource;
 
+import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.createMock;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.replay;
@@ -121,6 +123,13 @@
                 return false;
             }
 
+            // check state field
+            final String jsonState = jsonIntent.get("state").asString();
+            if (!jsonState.equals("INSTALLED")) {
+                reason = "state INSTALLED";
+                return false;
+            }
+
             // check resources array
             final JsonArray jsonResources = jsonIntent.get("resources").asArray();
             if (intent.resources() != null) {
@@ -180,7 +189,7 @@
         @Override
         public boolean matchesSafely(JsonArray json) {
             boolean intentFound = false;
-            final int expectedAttributes = 5;
+            final int expectedAttributes = 6;
             for (int jsonIntentIndex = 0; jsonIntentIndex < json.size();
                  jsonIntentIndex++) {
 
@@ -229,6 +238,9 @@
     @Before
     public void setUpTest() {
         expect(mockIntentService.getIntents()).andReturn(intents).anyTimes();
+        expect(mockIntentService.getIntentState(anyObject()))
+                .andReturn(IntentState.INSTALLED)
+                .anyTimes();
         // Register the services needed for the test
         final CodecManager codecService =  new CodecManager();
         codecService.activate();