diff options
Diffstat (limited to 'framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/HostToHostIntentTest.java')
-rw-r--r-- | framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/HostToHostIntentTest.java | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/HostToHostIntentTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/HostToHostIntentTest.java index 3f7650e4..c3a95473 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/HostToHostIntentTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/HostToHostIntentTest.java @@ -16,15 +16,18 @@ package org.onosproject.net.intent; import org.junit.Test; +import org.onlab.util.DataRateUnit; 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 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 +105,55 @@ public class HostToHostIntentTest extends IntentTest { .testEquals(); } + @Test + public void testImplicitConstraintsAreAdded() { + final Constraint other = BandwidthConstraint.of(1, DataRateUnit.GBPS); + 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() |