ONOS-3224 HostToHostIntent should have implicit non-OPTICAL constraint

Change-Id: Ibd6214e9b12199f56f0761cfdaa1eb45a600eb1c
diff --git a/core/api/src/test/java/org/onosproject/net/intent/HostToHostIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/HostToHostIntentTest.java
index 3f7650e..f870df6 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/HostToHostIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/HostToHostIntentTest.java
@@ -16,15 +16,20 @@
 package org.onosproject.net.intent;
 
 import org.junit.Test;
+import org.onlab.util.Bandwidth;
 import org.onosproject.TestApplicationId;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.net.HostId;
 import org.onosproject.net.flow.TrafficSelector;
+import org.onosproject.net.intent.constraint.BandwidthConstraint;
+import org.onosproject.net.resource.link.BandwidthResource;
 
+import com.google.common.collect.ImmutableList;
 import com.google.common.testing.EqualsTester;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasItem;
 import static org.hamcrest.Matchers.is;
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
 import static org.onosproject.net.NetTestTools.hid;
@@ -102,6 +107,56 @@
                 .testEquals();
     }
 
+    @Test
+    public void testImplicitConstraintsAreAdded() {
+        final BandwidthConstraint other = new BandwidthConstraint(
+                                           new BandwidthResource(Bandwidth.gbps(1)));
+        final HostToHostIntent intent = HostToHostIntent.builder()
+                .appId(APPID)
+                .one(id1)
+                .two(id2)
+                .selector(selector)
+                .treatment(treatment)
+                .constraints(ImmutableList.of(other))
+                .build();
+
+        assertThat(intent.constraints(), hasItem(HostToHostIntent.NOT_OPTICAL));
+    }
+
+    @Test
+    public void testImplicitConstraints() {
+        final HostToHostIntent implicit = HostToHostIntent.builder()
+                .appId(APPID)
+                .one(id1)
+                .two(id2)
+                .selector(selector)
+                .treatment(treatment)
+                .build();
+        final HostToHostIntent empty = HostToHostIntent.builder()
+                .appId(APPID)
+                .one(id1)
+                .two(id2)
+                .selector(selector)
+                .treatment(treatment)
+                .constraints(ImmutableList.of())
+                .build();
+        final HostToHostIntent exact = HostToHostIntent.builder()
+                .appId(APPID)
+                .one(id1)
+                .two(id2)
+                .selector(selector)
+                .treatment(treatment)
+                .constraints(ImmutableList.of(HostToHostIntent.NOT_OPTICAL))
+                .build();
+
+        new EqualsTester()
+            .addEqualityGroup(implicit.constraints(),
+                              empty.constraints(),
+                              exact.constraints())
+            .testEquals();
+
+    }
+
     @Override
     protected Intent createOne() {
         return HostToHostIntent.builder()