Add intent state to JSON output

Change-Id: I3a5995e0dfdc83e1253b8e414e825b796a57264c
diff --git a/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java b/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java
index 0318b8f..2104654 100644
--- a/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java
+++ b/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java
@@ -18,12 +18,12 @@
 import java.time.Duration;
 import java.util.List;
 
+import org.junit.Before;
 import org.junit.Test;
 import org.onlab.packet.IpPrefix;
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.MplsLabel;
 import org.onlab.util.Bandwidth;
-import org.onosproject.codec.CodecContext;
 import org.onosproject.codec.JsonCodec;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.DefaultApplicationId;
@@ -39,6 +39,8 @@
 import org.onosproject.net.intent.AbstractIntentTest;
 import org.onosproject.net.intent.Constraint;
 import org.onosproject.net.intent.HostToHostIntent;
+import org.onosproject.net.intent.IntentService;
+import org.onosproject.net.intent.IntentServiceAdapter;
 import org.onosproject.net.intent.PointToPointIntent;
 import org.onosproject.net.intent.constraint.AnnotationConstraint;
 import org.onosproject.net.intent.constraint.AsymmetricPathConstraint;
@@ -71,7 +73,13 @@
             DefaultTrafficSelector.emptySelector();
     final TrafficTreatment emptyTreatment =
             DefaultTrafficTreatment.emptyTreatment();
-    private final CodecContext context = new MockCodecContext();
+    private final MockCodecContext context = new MockCodecContext();
+
+    @Before
+    public void setUpIntentService() {
+        final IntentService mockIntentService = new IntentServiceAdapter();
+        context.registerService(IntentService.class, mockIntentService);
+    }
 
     /**
      * Tests the encoding of a host to host intent.
@@ -109,7 +117,6 @@
                         .ingressPoint(ingress)
                         .egressPoint(egress).build();
 
-        final CodecContext context = new MockCodecContext();
         final JsonCodec<PointToPointIntent> intentCodec =
                 context.codec(PointToPointIntent.class);
         assertThat(intentCodec, notNullValue());
@@ -165,7 +172,6 @@
                         .build();
 
 
-        final CodecContext context = new MockCodecContext();
         final JsonCodec<PointToPointIntent> intentCodec =
                 context.codec(PointToPointIntent.class);
         assertThat(intentCodec, notNullValue());