Initial import of CFM and SOAM api

Change-Id: Icf5cc2d5fb34b75460e80e8cced0d70265bcd33b
diff --git a/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/MilliPctTest.java b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/MilliPctTest.java
new file mode 100644
index 0000000..e51a761
--- /dev/null
+++ b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/MilliPctTest.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam;
+
+import static org.junit.Assert.assertEquals;
+
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+
+import org.junit.Test;
+
+public class MilliPctTest {
+
+    @Test
+    public void testIntValue() {
+        assertEquals(100, MilliPct.ofMilliPct(100).intValue());
+        assertEquals(-100, MilliPct.ofMilliPct(-100).intValue());
+    }
+
+    @Test
+    public void testLongValue() {
+        assertEquals(100, MilliPct.ofMilliPct(100).longValue());
+        assertEquals(-100, MilliPct.ofMilliPct(-100).longValue());
+    }
+
+    @Test
+    public void testFloatValue() {
+        assertEquals(100f, MilliPct.ofMilliPct(100).floatValue(), 0.0001f);
+        assertEquals(-100f, MilliPct.ofMilliPct(-100).floatValue(), 0.0001f);
+    }
+
+    @Test
+    public void testDoubleValue() {
+        assertEquals(100f, MilliPct.ofMilliPct(100).doubleValue(), 0.0001f);
+        assertEquals(-100f, MilliPct.ofMilliPct(-100).doubleValue(), 0.0001f);
+    }
+
+    @Test
+    public void testOfPercent() {
+        assertEquals(63563, MilliPct.ofPercent(63.563f).intValue());
+        assertEquals(-63563, MilliPct.ofPercent(-63.563f).intValue());
+    }
+
+    @Test
+    public void testOfRatio() {
+        assertEquals(43211, MilliPct.ofRatio(0.43211f).intValue());
+        assertEquals(-43211, MilliPct.ofRatio(-0.43211f).intValue());
+    }
+
+    @Test
+    public void testPercentValue() {
+        assertEquals(0.1f, MilliPct.ofMilliPct(100).percentValue(), 0.0001f);
+        assertEquals(-0.1f, MilliPct.ofMilliPct(-100).percentValue(), 0.0001f);
+    }
+
+    @Test
+    public void testRatioValue() {
+        assertEquals(0.002f, MilliPct.ofMilliPct(200).ratioValue(), 0.0001f);
+        assertEquals(-0.002f, MilliPct.ofMilliPct(-200).ratioValue(), 0.0001f);
+    }
+
+    @Test
+    public void testToString() {
+        NumberFormat pf = DecimalFormat.getPercentInstance(); //Varies by machine
+        pf.setMaximumFractionDigits(3);
+        assertEquals(pf.format(0.12345f), MilliPct.ofMilliPct(12345).toString());
+        assertEquals(pf.format(-0.12345f), MilliPct.ofMilliPct(-12345).toString());
+    }
+
+}
diff --git a/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/StartTimeTest.java b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/StartTimeTest.java
new file mode 100644
index 0000000..4d7c6c0
--- /dev/null
+++ b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/StartTimeTest.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.time.Duration;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
+
+import org.junit.Test;
+import org.onosproject.incubator.net.l2monitoring.soam.StartTime.StartTimeOption;
+import org.onosproject.incubator.net.l2monitoring.soam.StopTime.StopTimeOption;
+
+public class StartTimeTest {
+
+    @Test
+    public void testStartImmediate() {
+        StartTime st = StartTime.immediate();
+        assertEquals(StartTimeOption.IMMEDIATE, st.option());
+        assertNull(st.relativeTime());
+        assertNull(st.absoluteTime());
+    }
+
+    @Test
+    public void testStartRelative() {
+        StartTime st = StartTime.relative(Duration.ofMinutes(20));
+        assertEquals(StartTimeOption.RELATIVE, st.option());
+        assertEquals(20 * 60, st.relativeTime().getSeconds());
+        assertNull(st.absoluteTime());
+    }
+
+    @Test
+    public void testStartAbsolute() {
+        StartTime st = StartTime.absolute(OffsetDateTime
+                .of(2017, 3, 20, 11, 43, 11, 0, ZoneOffset.ofHours(-7))
+                .toInstant());
+        assertEquals(StartTimeOption.ABSOLUTE, st.option());
+        assertNull(st.relativeTime());
+        assertEquals("2017-03-20T11:43:11-07:00", st
+                .absoluteTime()
+                .atOffset(ZoneOffset.ofHours(-7))
+                .format(DateTimeFormatter.ISO_OFFSET_DATE_TIME));
+    }
+
+    @Test
+    public void testStopImmediate() {
+        StopTime st = StopTime.none();
+        assertEquals(StopTimeOption.NONE, st.option());
+        assertNull(st.relativeTime());
+        assertNull(st.absoluteTime());
+    }
+
+    @Test
+    public void testStopRelative() {
+        StopTime st = StopTime.relative(Duration.ofMinutes(20));
+        assertEquals(StopTimeOption.RELATIVE, st.option());
+        assertEquals(20 * 60, st.relativeTime().getSeconds());
+        assertNull(st.absoluteTime());
+    }
+
+    @Test
+    public void testStopAbsolute() {
+        StopTime st = StopTime.absolute(OffsetDateTime
+                .of(2017, 3, 20, 11, 43, 11, 0, ZoneOffset.ofHours(-7))
+                .toInstant());
+        assertEquals(StopTimeOption.ABSOLUTE, st.option());
+        assertNull(st.relativeTime());
+        assertEquals("2017-03-20T11:43:11-07:00", st
+                .absoluteTime()
+                .atOffset(ZoneOffset.ofHours(-7))
+                .format(DateTimeFormatter.ISO_OFFSET_DATE_TIME));
+    }
+
+}
diff --git a/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementCreateTest.java b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementCreateTest.java
new file mode 100644
index 0000000..d24effc
--- /dev/null
+++ b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementCreateTest.java
@@ -0,0 +1,304 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.delay;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.time.Duration;
+import java.time.OffsetDateTime;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.incubator.net.l2monitoring.cfm.Mep.Priority;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId;
+import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException;
+import org.onosproject.incubator.net.l2monitoring.soam.MeasurementCreateBase.SessionType;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+import org.onosproject.incubator.net.l2monitoring.soam.StartTime;
+import org.onosproject.incubator.net.l2monitoring.soam.StartTime.StartTimeOption;
+import org.onosproject.incubator.net.l2monitoring.soam.StopTime;
+import org.onosproject.incubator.net.l2monitoring.soam.StopTime.StopTimeOption;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DefaultDelayMeasurementCreate.DefaultDmCreateBuilder;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.DataPattern;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.DmType;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.MeasurementOption;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.TestTlvPattern;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.Version;
+
+public class DelayMeasurementCreateTest {
+
+    DelayMeasurementCreate dm1;
+
+    @Before
+    public void setUp() throws Exception, CfmConfigException, SoamConfigException {
+
+        DelayMeasurementThreshold dmT1 = DefaultDelayMeasurementThreshold
+                .builder(SoamId.valueOf(1))
+                .averageFrameDelayBackward(Duration.ofMillis(123))
+                .averageInterFrameDelayVariationForward(Duration.ofMillis(321))
+                .build();
+
+        DelayMeasurementThreshold dmT2 = DefaultDelayMeasurementThreshold
+                .builder(SoamId.valueOf(2))
+                .averageFrameDelayBackward(Duration.ofMillis(456))
+                .averageInterFrameDelayVariationForward(Duration.ofMillis(654))
+                .build();
+
+        try {
+            DefaultDmCreateBuilder builder = (DefaultDmCreateBuilder)
+                    DefaultDelayMeasurementCreate.builder(
+            DmType.DMDMM, Version.Y17312011, MepId.valueOf((short) 12), Priority.PRIO6)
+            .addToMeasurementsEnabled(MeasurementOption.FRAME_DELAY_FORWARD_MIN)
+            .addToMeasurementsEnabled(MeasurementOption.FRAME_DELAY_FORWARD_AVERAGE)
+            .addToMeasurementsEnabled(MeasurementOption.FRAME_DELAY_FORWARD_MAX)
+            .addToMeasurementsEnabled(MeasurementOption.FRAME_DELAY_FORWARD_BINS)
+            .binsPerFdInterval((short) 8)
+            .binsPerIfdvInterval((short) 9)
+            .ifdvSelectionOffset((short) 10)
+            .binsPerFdrInterval((short) 12)
+            .addToThresholds(dmT1)
+            .addToThresholds(dmT2)
+            .messagePeriod(Duration.ofMillis(100L))
+            .frameSize((short) 64)
+            .dataPattern(DataPattern.ONES)
+            .testTlvIncluded(true)
+            .testTlvPattern(TestTlvPattern.NULL_SIGNAL_WITHOUT_CRC_32)
+            .measurementInterval(Duration.ofMinutes(15))
+            .numberIntervalsStored((short) 32)
+            .alignMeasurementIntervals(true)
+            .alignMeasurementOffset(Duration.ofMinutes(4))
+            .sessionType(SessionType.ONDEMAND)
+            .startTime(StartTime.relative(Duration.ofMinutes(7)))
+            .stopTime(StopTime.relative(Duration.ofMinutes(8)));
+            dm1 = builder.build();
+        } catch (SoamConfigException e) {
+            throw new Exception(e);
+        }
+    }
+
+    @Test
+    public void testInvalidMessagePeriod() throws CfmConfigException {
+        try {
+            DefaultDelayMeasurementCreate.builder(
+                    DmType.DMDMM, Version.Y17312011, MepId.valueOf((short) 20),
+                    Priority.PRIO6)
+                    .messagePeriod(Duration.ofMinutes(61));
+            fail("Expected an exception to be thrown for invalid messagePeriod: " + 3660000);
+        } catch (SoamConfigException e) {
+            assertEquals(SoamConfigException.class, e.getClass());
+        }
+    }
+
+    @Test
+    public void testInvalidFrameSize() throws CfmConfigException {
+        try {
+            DefaultDelayMeasurementCreate.builder(
+                    DmType.DMDMM, Version.Y17312011, MepId.valueOf((short) 20),
+                    Priority.PRIO6)
+                    .frameSize((short) 11111);
+            fail("Expected an exception to be thrown for frame size: " + 11111);
+        } catch (SoamConfigException e) {
+            assertEquals(SoamConfigException.class, e.getClass());
+        }
+    }
+
+    @Test
+    public void testInvalidMeasurementInterval() throws CfmConfigException {
+        try {
+            DefaultDelayMeasurementCreate.builder(
+                    DmType.DMDMM, Version.Y17312011, MepId.valueOf((short) 20),
+                    Priority.PRIO6)
+                    .measurementInterval(Duration.ofMinutes(0));
+            fail("Expected an exception to be thrown for invalid measurementInterval: " + 0);
+        } catch (SoamConfigException e) {
+            assertEquals(SoamConfigException.class, e.getClass());
+        }
+    }
+
+    @Test
+    public void testInvalidNumberIntervalsStored() throws CfmConfigException {
+        try {
+            DefaultDelayMeasurementCreate.builder(
+                    DmType.DMDMM, Version.Y17312011, MepId.valueOf((short) 20),
+                    Priority.PRIO6)
+                    .numberIntervalsStored((short) 1001);
+            fail("Expected an exception to be thrown for number intervals stored: " + 1001);
+        } catch (SoamConfigException e) {
+            assertEquals(SoamConfigException.class, e.getClass());
+        }
+    }
+
+    @Test
+    public void testInvalidAlignMeasurementOffset() throws CfmConfigException {
+        try {
+            DefaultDelayMeasurementCreate.builder(
+                    DmType.DMDMM, Version.Y17312011, MepId.valueOf((short) 20),
+                    Priority.PRIO6)
+                    .alignMeasurementOffset(Duration.ofMinutes(525601));
+            fail("Expected an exception to be thrown for align Measurement Offset: " + 525601);
+        } catch (SoamConfigException e) {
+            assertEquals(SoamConfigException.class, e.getClass());
+        }
+    }
+
+    @Test
+    public void testInvalidStartTime() throws CfmConfigException {
+        OffsetDateTime oneMinuteAgo = OffsetDateTime.now().minusMinutes(1);
+        try {
+            DefaultDelayMeasurementCreate.builder(
+                    DmType.DMDMM, Version.Y17312011, MepId.valueOf((short) 20),
+                    Priority.PRIO6)
+                    .startTime(StartTime.absolute(oneMinuteAgo.toInstant()));
+            fail("Expected an exception to be thrown for align Start Time: " + oneMinuteAgo);
+        } catch (SoamConfigException e) {
+            assertEquals(SoamConfigException.class, e.getClass());
+        }
+    }
+
+    @Test
+    public void testInvalidStopTime() throws CfmConfigException {
+        OffsetDateTime oneMinuteAgo = OffsetDateTime.now().minusMinutes(1);
+        try {
+            DefaultDelayMeasurementCreate.builder(
+                    DmType.DMDMM, Version.Y17312011, MepId.valueOf((short) 20),
+                    Priority.PRIO6)
+                    .stopTime(StopTime.absolute(oneMinuteAgo.toInstant()));
+            fail("Expected an exception to be thrown for align Stop Time: " + oneMinuteAgo);
+        } catch (SoamConfigException e) {
+            assertEquals(SoamConfigException.class, e.getClass());
+        }
+    }
+
+    @Test
+    public void testDmCfgType() {
+        assertEquals(DmType.DMDMM, dm1.dmCfgType());
+    }
+
+    @Test
+    public void testVersion() {
+        assertEquals(Version.Y17312011, dm1.version());
+    }
+
+    @Test
+    public void testRemoteMepId() {
+        assertEquals(12, dm1.remoteMepId().value());
+    }
+
+    @Test
+    public void testMeasurementsEnabled() {
+        assertEquals(4, dm1.measurementsEnabled().size());
+    }
+
+    @Test
+    public void testMessagePeriod() {
+        assertEquals(100, dm1.messagePeriod().toMillis());
+    }
+
+    @Test
+    public void testPriority() {
+        assertEquals(Priority.PRIO6.name(), dm1.priority().name());
+    }
+
+    @Test
+    public void testFrameSize() {
+        assertEquals(64, dm1.frameSize().shortValue());
+    }
+
+    @Test
+    public void testDataPattern() {
+        assertEquals(DataPattern.ONES, dm1.dataPattern());
+    }
+
+    @Test
+    public void testTestTlvIncluded() {
+        assertTrue(dm1.testTlvIncluded());
+    }
+
+    @Test
+    public void testTestTlvPattern() {
+        assertEquals(TestTlvPattern.NULL_SIGNAL_WITHOUT_CRC_32, dm1.testTlvPattern());
+    }
+
+    @Test
+    public void testMeasurementInterval() {
+        assertEquals(15, dm1.measurementInterval().toMinutes());
+    }
+
+    @Test
+    public void testNumberIntervalsStored() {
+        assertEquals(32, dm1.numberIntervalsStored().shortValue());
+    }
+
+    @Test
+    public void testAlignMeasurementIntervals() {
+        assertTrue(dm1.alignMeasurementIntervals());
+    }
+
+    @Test
+    public void testAlignMeasurementOffset() {
+        assertEquals(4, dm1.alignMeasurementOffset().toMinutes());
+    }
+
+    @Test
+    public void testBinsPerFdInterval() {
+        assertEquals(8, dm1.binsPerFdInterval().shortValue());
+    }
+
+    @Test
+    public void testBinsPerIfdvInterval() {
+        assertEquals(9, dm1.binsPerIfdvInterval().shortValue());
+    }
+
+    @Test
+    public void testIfdvSelectionOffset() {
+        assertEquals(10, dm1.ifdvSelectionOffset().shortValue());
+    }
+
+    @Test
+    public void testBinsPerFdrInterval() {
+        assertEquals(12, dm1.binsPerFdrInterval().shortValue());
+    }
+
+    @Test
+    public void testSessionType() {
+        assertEquals(SessionType.ONDEMAND, dm1.sessionType());
+    }
+
+    @Test
+    public void testStartTime() {
+        assertEquals(StartTimeOption.RELATIVE, dm1.startTime().option());
+        assertEquals(7, dm1.startTime().relativeTime().toMinutes());
+    }
+
+    @Test
+    public void testStopTime() {
+        assertEquals(StopTimeOption.RELATIVE, dm1.stopTime().option());
+        assertEquals(8, dm1.stopTime().relativeTime().toMinutes());
+    }
+
+    @Test
+    public void testThresholds() {
+        DelayMeasurementThreshold[] thresholds =
+                dm1.thresholds().toArray(
+                        new DelayMeasurementThreshold[dm1.thresholds().size()]);
+
+        assertEquals(1, thresholds[0].threshId().id().intValue());
+        assertEquals(123, thresholds[0].averageFrameDelayBackward().toMillis());
+    }
+}
diff --git a/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementEntryTest.java b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementEntryTest.java
new file mode 100644
index 0000000..ad2439a
--- /dev/null
+++ b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementEntryTest.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.delay;
+
+import static org.junit.Assert.*;
+
+import java.time.Duration;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.incubator.net.l2monitoring.cfm.Mep.Priority;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId;
+import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.DmType;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.Version;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementEntry.SessionStatus;
+
+public class DelayMeasurementEntryTest {
+
+    DelayMeasurementEntry dmE1;
+
+    @Before
+    public void setUp() throws Exception, SoamConfigException, CfmConfigException {
+
+        DelayMeasurementStatCurrent dmE1c = (DelayMeasurementStatCurrent)
+                DefaultDelayMeasurementStatCurrent.builder(
+                Duration.ofMinutes(6), false)
+        .build();
+
+        DelayMeasurementStatHistory dmE1h1 = (DelayMeasurementStatHistory)
+                DefaultDelayMeasurementStatHistory.builder(
+                        SoamId.valueOf(1), Duration.ofMinutes(15), false)
+                .build();
+
+        DelayMeasurementStatHistory dmE1h2 = (DelayMeasurementStatHistory)
+                DefaultDelayMeasurementStatHistory.builder(
+                        SoamId.valueOf(2), Duration.ofMinutes(15), false)
+                .build();
+
+        dmE1 = DefaultDelayMeasurementEntry.builder(
+                SoamId.valueOf(1),
+                DmType.DMDMM,
+                Version.Y17312011,
+                MepId.valueOf((short) 10),
+                Priority.PRIO3)
+                .sessionStatus(SessionStatus.NOT_ACTIVE)
+                .frameDelayTwoWay(Duration.ofMillis(1))
+                .frameDelayForward(Duration.ofMillis(2))
+                .frameDelayBackward(Duration.ofMillis(3))
+                .interFrameDelayVariationTwoWay(Duration.ofMillis(4))
+                .interFrameDelayVariationForward(Duration.ofMillis(5))
+                .interFrameDelayVariationBackward(Duration.ofMillis(6))
+                .currentResult(dmE1c)
+                .addToHistoricalResults(dmE1h1)
+                .addToHistoricalResults(dmE1h2)
+                .build();
+    }
+
+    @Test
+    public void testDmId() {
+        assertEquals(1, dmE1.dmId().id().shortValue());
+    }
+
+    @Test
+    public void testSessionStatus() {
+        assertEquals(SessionStatus.NOT_ACTIVE.name(),
+                dmE1.sessionStatus().name());
+    }
+
+    @Test
+    public void testFrameDelayTwoWay() {
+        assertEquals(1, dmE1.frameDelayTwoWay().toMillis());
+    }
+
+    @Test
+    public void testFrameDelayForward() {
+        assertEquals(2, dmE1.frameDelayForward().toMillis());
+    }
+
+    @Test
+    public void testFrameDelayBackward() {
+        assertEquals(3, dmE1.frameDelayBackward().toMillis());
+    }
+
+    @Test
+    public void testInterFrameDelayVariationTwoWay() {
+        assertEquals(4, dmE1.interFrameDelayVariationTwoWay().toMillis());
+    }
+
+    @Test
+    public void testInterFrameDelayVariationForward() {
+        assertEquals(5, dmE1.interFrameDelayVariationForward().toMillis());
+    }
+
+    @Test
+    public void testInterFrameDelayVariationBackward() {
+        assertEquals(6, dmE1.interFrameDelayVariationBackward().toMillis());
+    }
+
+    @Test
+    public void testCurrentResult() {
+        assertEquals(360, dmE1.currentResult().elapsedTime().getSeconds());
+    }
+
+    @Test
+    public void testHistoricalResults() {
+        assertEquals(2, dmE1.historicalResults().size());
+    }
+
+}
diff --git a/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementStatCurrentAndHistoryTest.java b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementStatCurrentAndHistoryTest.java
new file mode 100644
index 0000000..0bde63a
--- /dev/null
+++ b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementStatCurrentAndHistoryTest.java
@@ -0,0 +1,385 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.delay;
+
+import static junit.framework.TestCase.fail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.time.Duration;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
+
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+
+public class DelayMeasurementStatCurrentAndHistoryTest {
+
+    private DelayMeasurementStatCurrent dmStCurr1;
+    private DelayMeasurementStatHistory dmStHist1;
+
+    @Before
+    public void setUp() throws Exception, SoamConfigException {
+        dmStCurr1 = (DelayMeasurementStatCurrent)
+                DefaultDelayMeasurementStatCurrent.builder(
+                        Duration.ofMinutes(9), false)
+                .startTime(OffsetDateTime.of(2017, 3, 20, 23, 22, 7, 0,
+                        ZoneOffset.ofHours(-7)).toInstant())
+                .frameDelayTwoWayMin(Duration.ofMillis(101))
+                .frameDelayTwoWayMax(Duration.ofMillis(102))
+                .frameDelayTwoWayAvg(Duration.ofMillis(103))
+                .frameDelayForwardMin(Duration.ofMillis(104))
+                .frameDelayForwardMax(Duration.ofMillis(105))
+                .frameDelayForwardAvg(Duration.ofMillis(106))
+                .frameDelayBackwardMin(Duration.ofMillis(107))
+                .frameDelayBackwardMax(Duration.ofMillis(108))
+                .frameDelayBackwardAvg(Duration.ofMillis(109))
+                .interFrameDelayVariationTwoWayMin(Duration.ofMillis(110))
+                .interFrameDelayVariationTwoWayMax(Duration.ofMillis(111))
+                .interFrameDelayVariationTwoWayAvg(Duration.ofMillis(112))
+                .interFrameDelayVariationForwardMin(Duration.ofMillis(113))
+                .interFrameDelayVariationForwardMax(Duration.ofMillis(114))
+                .interFrameDelayVariationForwardAvg(Duration.ofMillis(115))
+                .interFrameDelayVariationBackwardMin(Duration.ofMillis(116))
+                .interFrameDelayVariationBackwardMax(Duration.ofMillis(117))
+                .interFrameDelayVariationBackwardAvg(Duration.ofMillis(118))
+                .frameDelayRangeTwoWayMax(Duration.ofMillis(119))
+                .frameDelayRangeTwoWayAvg(Duration.ofMillis(120))
+                .frameDelayRangeForwardMax(Duration.ofMillis(121))
+                .frameDelayRangeForwardAvg(Duration.ofMillis(122))
+                .frameDelayRangeBackwardMax(Duration.ofMillis(123))
+                .frameDelayRangeBackwardAvg(Duration.ofMillis(124))
+                .soamPdusSent(125)
+                .soamPdusReceived(126)
+                .build();
+
+        dmStHist1 = (DelayMeasurementStatHistory)
+                DefaultDelayMeasurementStatHistory.builder(
+                        SoamId.valueOf(11), Duration.ofMinutes(15), true)
+                .endTime(OffsetDateTime.of(2017, 3, 20, 23, 22, 8, 0,
+                        ZoneOffset.ofHours(-7)).toInstant())
+                .frameDelayTwoWayMin(Duration.ofMillis(201))
+                .frameDelayTwoWayMax(Duration.ofMillis(202))
+                .frameDelayTwoWayAvg(Duration.ofMillis(203))
+                .frameDelayForwardMin(Duration.ofMillis(204))
+                .frameDelayForwardMax(Duration.ofMillis(205))
+                .frameDelayForwardAvg(Duration.ofMillis(206))
+                .frameDelayBackwardMin(Duration.ofMillis(207))
+                .frameDelayBackwardMax(Duration.ofMillis(208))
+                .frameDelayBackwardAvg(Duration.ofMillis(209))
+                .interFrameDelayVariationTwoWayMin(Duration.ofMillis(210))
+                .interFrameDelayVariationTwoWayMax(Duration.ofMillis(211))
+                .interFrameDelayVariationTwoWayAvg(Duration.ofMillis(212))
+                .interFrameDelayVariationForwardMin(Duration.ofMillis(213))
+                .interFrameDelayVariationForwardMax(Duration.ofMillis(214))
+                .interFrameDelayVariationForwardAvg(Duration.ofMillis(215))
+                .interFrameDelayVariationBackwardMin(Duration.ofMillis(216))
+                .interFrameDelayVariationBackwardMax(Duration.ofMillis(217))
+                .interFrameDelayVariationBackwardAvg(Duration.ofMillis(218))
+                .frameDelayRangeTwoWayMax(Duration.ofMillis(219))
+                .frameDelayRangeTwoWayAvg(Duration.ofMillis(220))
+                .frameDelayRangeForwardMax(Duration.ofMillis(221))
+                .frameDelayRangeForwardAvg(Duration.ofMillis(222))
+                .frameDelayRangeBackwardMax(Duration.ofMillis(223))
+                .frameDelayRangeBackwardAvg(Duration.ofMillis(224))
+                .soamPdusSent(225)
+                .soamPdusReceived(226)
+                .build();
+    }
+
+    @Test
+    public void testStartTime() {
+        assertEquals("2017-03-20T23:22:07-07:00",
+                dmStCurr1.startTime().atOffset(ZoneOffset.ofHours(-7))
+                .format(DateTimeFormatter.ISO_OFFSET_DATE_TIME));
+    }
+
+    @Test
+    public void testEndTime() {
+        assertEquals("2017-03-20T23:22:08-07:00",
+                dmStHist1.endTime().atOffset(ZoneOffset.ofHours(-7))
+                .format(DateTimeFormatter.ISO_OFFSET_DATE_TIME));
+    }
+
+    @Test
+    public void testHistoryStatsId() {
+        assertEquals(11, dmStHist1.historyStatsId().id().intValue());
+    }
+
+    @Test
+    public void testElapsedTime() {
+        assertEquals(9, dmStCurr1.elapsedTime().toMinutes());
+
+        assertEquals(15, dmStHist1.elapsedTime().toMinutes());
+    }
+
+    @Test
+    public void testSuspectStatus() {
+        assertFalse(dmStCurr1.suspectStatus());
+
+        assertTrue(dmStHist1.suspectStatus());
+    }
+
+    @Test
+    public void testFrameDelayTwoWayMin() {
+        assertEquals(101, dmStCurr1.frameDelayTwoWayMin().toMillis());
+
+        assertEquals(201, dmStHist1.frameDelayTwoWayMin().toMillis());
+    }
+
+    @Test
+    public void testFrameDelayTwoWayMax() {
+        assertEquals(102, dmStCurr1.frameDelayTwoWayMax().toMillis());
+
+        assertEquals(202, dmStHist1.frameDelayTwoWayMax().toMillis());
+    }
+
+    @Test
+    public void testFrameDelayTwoWayAvg() {
+        assertEquals(103, dmStCurr1.frameDelayTwoWayAvg().toMillis());
+
+        assertEquals(203, dmStHist1.frameDelayTwoWayAvg().toMillis());
+    }
+
+    @Test
+    public void testFrameDelayForwardMin() {
+        assertEquals(104, dmStCurr1.frameDelayForwardMin().toMillis());
+
+        assertEquals(204, dmStHist1.frameDelayForwardMin().toMillis());
+    }
+
+    @Test
+    public void testFrameDelayForwardMax() {
+        assertEquals(105, dmStCurr1.frameDelayForwardMax().toMillis());
+
+        assertEquals(205, dmStHist1.frameDelayForwardMax().toMillis());
+    }
+
+    @Test
+    public void testFrameDelayForwardAvg() {
+        assertEquals(106, dmStCurr1.frameDelayForwardAvg().toMillis());
+
+        assertEquals(206, dmStHist1.frameDelayForwardAvg().toMillis());
+    }
+
+    @Test
+    public void testFrameDelayBackwardMin() {
+        assertEquals(107, dmStCurr1.frameDelayBackwardMin().toMillis());
+
+        assertEquals(207, dmStHist1.frameDelayBackwardMin().toMillis());
+    }
+
+    @Test
+    public void testFrameDelayBackwardMax() {
+        assertEquals(108, dmStCurr1.frameDelayBackwardMax().toMillis());
+
+        assertEquals(208, dmStHist1.frameDelayBackwardMax().toMillis());
+    }
+
+    @Test
+    public void testFrameDelayBackwardAvg() {
+        assertEquals(109, dmStCurr1.frameDelayBackwardAvg().toMillis());
+
+        assertEquals(209, dmStHist1.frameDelayBackwardAvg().toMillis());
+    }
+
+    @Test
+    public void testInterFrameDelayVariationTwoWayMin() {
+        assertEquals(110, dmStCurr1.interFrameDelayVariationTwoWayMin().toMillis());
+
+        assertEquals(210, dmStHist1.interFrameDelayVariationTwoWayMin().toMillis());
+    }
+
+    @Test
+    public void testInterFrameDelayVariationTwoWayMax() {
+        assertEquals(111, dmStCurr1.interFrameDelayVariationTwoWayMax().toMillis());
+
+        assertEquals(211, dmStHist1.interFrameDelayVariationTwoWayMax().toMillis());
+    }
+
+    @Test
+    public void testInterFrameDelayVariationTwoWayAvg() {
+        assertEquals(112, dmStCurr1.interFrameDelayVariationTwoWayAvg().toMillis());
+
+        assertEquals(212, dmStHist1.interFrameDelayVariationTwoWayAvg().toMillis());
+    }
+
+    @Test
+    public void testInterFrameDelayVariationForwardMin() {
+        assertEquals(113, dmStCurr1.interFrameDelayVariationForwardMin().toMillis());
+
+        assertEquals(213, dmStHist1.interFrameDelayVariationForwardMin().toMillis());
+    }
+
+    @Test
+    public void testInterFrameDelayVariationForwardMax() {
+        assertEquals(114, dmStCurr1.interFrameDelayVariationForwardMax().toMillis());
+
+        assertEquals(214, dmStHist1.interFrameDelayVariationForwardMax().toMillis());
+    }
+
+    @Test
+    public void testInterFrameDelayVariationForwardAvg() {
+        assertEquals(115, dmStCurr1.interFrameDelayVariationForwardAvg().toMillis());
+
+        assertEquals(215, dmStHist1.interFrameDelayVariationForwardAvg().toMillis());
+    }
+
+    @Test
+    public void testInterFrameDelayVariationBackwardMin() {
+        assertEquals(116, dmStCurr1.interFrameDelayVariationBackwardMin().toMillis());
+
+        assertEquals(216, dmStHist1.interFrameDelayVariationBackwardMin().toMillis());
+    }
+
+    @Test
+    public void testInterFrameDelayVariationBackwardMax() {
+        assertEquals(117, dmStCurr1.interFrameDelayVariationBackwardMax().toMillis());
+
+        assertEquals(217, dmStHist1.interFrameDelayVariationBackwardMax().toMillis());
+    }
+
+    @Test
+    public void testInterFrameDelayVariationBackwardAvg() {
+        assertEquals(118, dmStCurr1.interFrameDelayVariationBackwardAvg().toMillis());
+
+        assertEquals(218, dmStHist1.interFrameDelayVariationBackwardAvg().toMillis());
+    }
+
+    @Test
+    public void testFrameDelayRangeTwoWayMax() {
+        assertEquals(119, dmStCurr1.frameDelayRangeTwoWayMax().toMillis());
+
+        assertEquals(219, dmStHist1.frameDelayRangeTwoWayMax().toMillis());
+    }
+
+    @Test
+    public void testFrameDelayRangeTwoWayAvg() {
+        assertEquals(120, dmStCurr1.frameDelayRangeTwoWayAvg().toMillis());
+
+        assertEquals(220, dmStHist1.frameDelayRangeTwoWayAvg().toMillis());
+    }
+
+    @Test
+    public void testFrameDelayRangeForwardMax() {
+        assertEquals(121, dmStCurr1.frameDelayRangeForwardMax().toMillis());
+
+        assertEquals(221, dmStHist1.frameDelayRangeForwardMax().toMillis());
+    }
+
+    @Test
+    public void testFrameDelayRangeForwardAvg() {
+        assertEquals(122, dmStCurr1.frameDelayRangeForwardAvg().toMillis());
+
+        assertEquals(222, dmStHist1.frameDelayRangeForwardAvg().toMillis());
+    }
+
+    @Test
+    public void testFrameDelayRangeBackwardMax() {
+        assertEquals(123, dmStCurr1.frameDelayRangeBackwardMax().toMillis());
+
+        assertEquals(223, dmStHist1.frameDelayRangeBackwardMax().toMillis());
+    }
+
+    @Test
+    public void testFrameDelayRangeBackwardAvg() {
+        assertEquals(124, dmStCurr1.frameDelayRangeBackwardAvg().toMillis());
+
+        assertEquals(224, dmStHist1.frameDelayRangeBackwardAvg().toMillis());
+    }
+
+    @Test
+    public void testSoamPdusSent() {
+        assertEquals(125, dmStCurr1.soamPdusSent().intValue());
+
+        assertEquals(225, dmStHist1.soamPdusSent().intValue());
+    }
+
+    @Test
+    public void testSoamPdusReceived() {
+        assertEquals(126, dmStCurr1.soamPdusReceived().intValue());
+
+        assertEquals(226, dmStHist1.soamPdusReceived().intValue());
+    }
+
+    @Ignore
+    @Test
+    public void testFrameDelayTwoWayBins() {
+        //TODO Add in test
+        fail("Not yet implemented");
+    }
+
+    @Ignore
+    @Test
+    public void testFrameDelayForwardBins() {
+        //TODO Add in test
+        fail("Not yet implemented");
+    }
+
+    @Ignore
+    @Test
+    public void testFrameDelayBackwardBins() {
+        //TODO Add in test
+        fail("Not yet implemented");
+    }
+
+    @Ignore
+    @Test
+    public void testInterFrameDelayVariationTwoWayBins() {
+        //TODO Add in test
+        fail("Not yet implemented");
+    }
+
+    @Ignore
+    @Test
+    public void testInterFrameDelayVariationForwardBins() {
+        //TODO Add in test
+        fail("Not yet implemented");
+    }
+
+    @Ignore
+    @Test
+    public void testInterFrameDelayVariationBackwardBins() {
+        //TODO Add in test
+        fail("Not yet implemented");
+    }
+
+    @Ignore
+    @Test
+    public void testFrameDelayRangeTwoWayBins() {
+        //TODO Add in test
+        fail("Not yet implemented");
+    }
+
+    @Ignore
+    @Test
+    public void testFrameDelayRangeForwardBins() {
+        //TODO Add in test
+        fail("Not yet implemented");
+    }
+
+    @Ignore
+    @Test
+    public void testFrameDelayRangeBackwardBins() {
+        //TODO Add in test
+        fail("Not yet implemented");
+    }
+}
diff --git a/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementThresholdOptionTest.java b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementThresholdOptionTest.java
new file mode 100644
index 0000000..f838143
--- /dev/null
+++ b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/delay/DelayMeasurementThresholdOptionTest.java
@@ -0,0 +1,216 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.delay;
+
+import static org.junit.Assert.*;
+
+import java.time.Duration;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementThreshold.ThresholdOption;
+
+public class DelayMeasurementThresholdOptionTest {
+
+    DelayMeasurementThreshold dmT1;
+
+    @Before
+    public void setUp() throws Exception, SoamConfigException {
+        dmT1 = DefaultDelayMeasurementThreshold.builder(SoamId.valueOf(1))
+                .averageFrameDelayBackward(Duration.ofMillis(101))
+                .averageFrameDelayForward(Duration.ofMillis(102))
+                .averageFrameDelayTwoWay(Duration.ofMillis(103))
+                .averageFrameDelayRangeBackward(Duration.ofMillis(201))
+                .averageFrameDelayRangeForward(Duration.ofMillis(202))
+                .averageFrameDelayRangeTwoWay(Duration.ofMillis(203))
+                .averageInterFrameDelayVariationBackward(Duration.ofMillis(301))
+                .averageInterFrameDelayVariationForward(Duration.ofMillis(302))
+                .averageInterFrameDelayVariationTwoWay(Duration.ofMillis(303))
+                .maxFrameDelayBackward(Duration.ofMillis(401))
+                .maxFrameDelayForward(Duration.ofMillis(402))
+                .maxFrameDelayTwoWay(Duration.ofMillis(403))
+                .maxFrameDelayRangeBackward(Duration.ofMillis(501))
+                .maxFrameDelayRangeForward(Duration.ofMillis(502))
+                .maxFrameDelayRangeTwoWay(Duration.ofMillis(503))
+                .maxInterFrameDelayVariationBackward(Duration.ofMillis(601))
+                .maxInterFrameDelayVariationForward(Duration.ofMillis(602))
+                .maxInterFrameDelayVariationTwoWay(Duration.ofMillis(603))
+                .measuredFrameDelayBackward(Duration.ofMillis(701))
+                .measuredFrameDelayForward(Duration.ofMillis(702))
+                .measuredFrameDelayTwoWay(Duration.ofMillis(703))
+                .measuredInterFrameDelayVariationBackward(Duration.ofMillis(801))
+                .measuredInterFrameDelayVariationForward(Duration.ofMillis(802))
+                .measuredInterFrameDelayVariationTwoWay(Duration.ofMillis(803))
+                .addToThresholdsEnabled(ThresholdOption.MEASURED_FRAME_DELAY_TWO_WAY)
+                .addToThresholdsEnabled(ThresholdOption.MAX_FRAME_DELAY_TWO_WAY)
+                .addToThresholdsEnabled(ThresholdOption.AVERAGE_FRAME_DELAY_TWO_WAY)
+                .addToThresholdsEnabled(ThresholdOption.MEASURED_INTER_FRAME_DELAY_VARIATION_TWO_WAY)
+                .addToThresholdsEnabled(ThresholdOption.MAX_INTER_FRAME_DELAY_VARIATION_TWO_WAY)
+                .addToThresholdsEnabled(ThresholdOption.AVERAGE_INTER_FRAME_DELAY_VARIATION_TWO_WAY)
+                .addToThresholdsEnabled(ThresholdOption.MAX_FRAME_DELAY_RANGE_TWO_WAY)
+                .addToThresholdsEnabled(ThresholdOption.AVERAGE_FRAME_DELAY_RANGE_TWO_WAY)
+                .addToThresholdsEnabled(ThresholdOption.MEASURED_FRAME_DELAY_FORWARD)
+                .addToThresholdsEnabled(ThresholdOption.MAX_FRAME_DELAY_FORWARD)
+                .addToThresholdsEnabled(ThresholdOption.AVERAGE_FRAME_DELAY_FORWARD)
+                .addToThresholdsEnabled(ThresholdOption.MEASURED_INTER_FRAME_DELAY_VARIATION_FORWARD)
+                .addToThresholdsEnabled(ThresholdOption.MAX_INTER_FRAME_DELAY_VARIATION_FORWARD)
+                .addToThresholdsEnabled(ThresholdOption.AVERAGE_INTER_FRAME_DELAY_VARIATION_FORWARD)
+                .addToThresholdsEnabled(ThresholdOption.MAX_FRAME_DELAY_RANGE_FORWARD)
+                .addToThresholdsEnabled(ThresholdOption.AVERAGE_FRAME_DELAY_RANGE_FORWARD)
+                .addToThresholdsEnabled(ThresholdOption.MEASURED_FRAME_DELAY_BACKWARD)
+                .addToThresholdsEnabled(ThresholdOption.MAX_FRAME_DELAY_BACKWARD)
+                .addToThresholdsEnabled(ThresholdOption.AVERAGE_FRAME_DELAY_BACKWARD)
+                .addToThresholdsEnabled(ThresholdOption.MEASURED_INTER_FRAME_DELAY_VARIATION_BACKWARD)
+                .addToThresholdsEnabled(ThresholdOption.MAX_INTER_FRAME_DELAY_VARIATION_BACKWARD)
+                .addToThresholdsEnabled(ThresholdOption.AVERAGE_INTER_FRAME_DELAY_VARIATION_BACKWARD)
+                .addToThresholdsEnabled(ThresholdOption.MAX_FRAME_DELAY_RANGE_BACKWARD)
+                .addToThresholdsEnabled(ThresholdOption.AVERAGE_FRAME_DELAY_RANGE_BACKWARD)
+                .build();
+    }
+
+    @Test
+    public void testThreshId() {
+        assertEquals(1, dmT1.threshId().id().intValue());
+    }
+
+    @Test
+    public void testThresholdsEnabled() {
+        assertEquals(24, dmT1.thresholdsEnabled().size());
+    }
+
+    @Test
+    public void testMeasuredFrameDelayTwoWay() {
+        assertEquals(703, dmT1.measuredFrameDelayTwoWay().toMillis());
+    }
+
+    @Test
+    public void testMaxFrameDelayTwoWay() {
+        assertEquals(403, dmT1.maxFrameDelayTwoWay().toMillis());
+    }
+
+    @Test
+    public void testAverageFrameDelayTwoWay() {
+        assertEquals(103, dmT1.averageFrameDelayTwoWay().toMillis());
+    }
+
+    @Test
+    public void testMeasuredInterFrameDelayVariationTwoWay() {
+        assertEquals(803, dmT1.measuredInterFrameDelayVariationTwoWay().toMillis());
+    }
+
+    @Test
+    public void testMaxInterFrameDelayVariationTwoWay() {
+        assertEquals(603, dmT1.maxInterFrameDelayVariationTwoWay().toMillis());
+    }
+
+    @Test
+    public void testAverageInterFrameDelayVariationTwoWay() {
+        assertEquals(303, dmT1.averageInterFrameDelayVariationTwoWay().toMillis());
+    }
+
+    @Test
+    public void testMaxFrameDelayRangeTwoWay() {
+        assertEquals(503, dmT1.maxFrameDelayRangeTwoWay().toMillis());
+    }
+
+    @Test
+    public void testAverageFrameDelayRangeTwoWay() {
+        assertEquals(203, dmT1.averageFrameDelayRangeTwoWay().toMillis());
+    }
+
+    @Test
+    public void testMeasuredFrameDelayForward() {
+        assertEquals(702, dmT1.measuredFrameDelayForward().toMillis());
+    }
+
+    @Test
+    public void testMaxFrameDelayForward() {
+        assertEquals(402, dmT1.maxFrameDelayForward().toMillis());
+    }
+
+    @Test
+    public void testAverageFrameDelayForward() {
+        assertEquals(102, dmT1.averageFrameDelayForward().toMillis());
+    }
+
+    @Test
+    public void testMeasuredInterFrameDelayVariationForward() {
+        assertEquals(802, dmT1.measuredInterFrameDelayVariationForward().toMillis());
+    }
+
+    @Test
+    public void testMaxInterFrameDelayVariationForward() {
+        assertEquals(602, dmT1.maxInterFrameDelayVariationForward().toMillis());
+    }
+
+    @Test
+    public void testAverageInterFrameDelayVariationForward() {
+        assertEquals(302, dmT1.averageInterFrameDelayVariationForward().toMillis());
+    }
+
+    @Test
+    public void testMaxFrameDelayRangeForward() {
+        assertEquals(502, dmT1.maxFrameDelayRangeForward().toMillis());
+    }
+
+    @Test
+    public void testAverageFrameDelayRangeForward() {
+        assertEquals(202, dmT1.averageFrameDelayRangeForward().toMillis());
+    }
+
+    @Test
+    public void testMeasuredFrameDelayBackward() {
+        assertEquals(701, dmT1.measuredFrameDelayBackward().toMillis());
+    }
+
+    @Test
+    public void testMaxFrameDelayBackward() {
+        assertEquals(401, dmT1.maxFrameDelayBackward().toMillis());
+    }
+
+    @Test
+    public void testAverageFrameDelayBackward() {
+        assertEquals(101, dmT1.averageFrameDelayBackward().toMillis());
+    }
+
+    @Test
+    public void testMeasuredInterFrameDelayVariationBackward() {
+        assertEquals(801, dmT1.measuredInterFrameDelayVariationBackward().toMillis());
+    }
+
+    @Test
+    public void testMaxInterFrameDelayVariationBackward() {
+        assertEquals(601, dmT1.maxInterFrameDelayVariationBackward().toMillis());
+    }
+
+    @Test
+    public void testAverageInterFrameDelayVariationBackward() {
+        assertEquals(301, dmT1.averageInterFrameDelayVariationBackward().toMillis());
+    }
+
+    @Test
+    public void testMaxFrameDelayRangeBackward() {
+        assertEquals(501, dmT1.maxFrameDelayRangeBackward().toMillis());
+    }
+
+    @Test
+    public void testAverageFrameDelayRangeBackward() {
+        assertEquals(201, dmT1.averageFrameDelayRangeBackward().toMillis());
+    }
+
+}
diff --git a/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossAvailabilityStatCurrentTest.java b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossAvailabilityStatCurrentTest.java
new file mode 100644
index 0000000..d65c307
--- /dev/null
+++ b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossAvailabilityStatCurrentTest.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.time.Duration;
+import java.time.Instant;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.incubator.net.l2monitoring.soam.MilliPct;
+import org.onosproject.incubator.net.l2monitoring.soam.loss.LossAvailabilityStatCurrent.LaStatCurrentBuilder;
+
+public class LossAvailabilityStatCurrentTest {
+
+    LossAvailabilityStatCurrent lasc1;
+
+    @Before
+    public void setUp() {
+        LaStatCurrentBuilder builder = DefaultLaStatCurrent.builder(
+                Duration.ofMinutes(13), true, Instant.ofEpochSecond(123456789L));
+        builder = (LaStatCurrentBuilder) builder
+                .backwardAvailable(123456780L)
+                .backwardAverageFrameLossRatio(MilliPct.ofMilliPct(12345))
+                .backwardConsecutiveHighLoss(123456781L)
+                .backwardHighLoss(123456782L)
+                .backwardMaxFrameLossRatio(MilliPct.ofMilliPct(12346))
+                .backwardMinFrameLossRatio(MilliPct.ofMilliPct(12347))
+                .backwardUnavailable(123456783L)
+                .forwardAvailable(123456784L)
+                .forwardAverageFrameLossRatio(MilliPct.ofMilliPct(12348))
+                .forwardConsecutiveHighLoss(123456785L)
+                .forwardHighLoss(123456786L)
+                .forwardMaxFrameLossRatio(MilliPct.ofMilliPct(12349))
+                .forwardMinFrameLossRatio(MilliPct.ofMilliPct(12350))
+                .forwardUnavailable(123456787L);
+
+        lasc1 = builder.build();
+    }
+
+    @Test
+    public void testStartTime() {
+        assertEquals(123456789L, lasc1.startTime().getEpochSecond());
+    }
+
+    @Test
+    public void testElapsedTime() {
+        assertEquals(13, lasc1.elapsedTime().toMinutes());
+    }
+
+    @Test
+    public void testSuspectStatus() {
+        assertTrue(lasc1.suspectStatus());
+    }
+
+    @Test
+    public void testForwardHighLoss() {
+        assertEquals(123456786L, lasc1.forwardHighLoss().longValue());
+    }
+
+    @Test
+    public void testBackwardHighLoss() {
+        assertEquals(123456782L, lasc1.backwardHighLoss().longValue());
+    }
+
+    @Test
+    public void testForwardConsecutiveHighLoss() {
+        assertEquals(123456785L, lasc1.forwardConsecutiveHighLoss().longValue());
+    }
+
+    @Test
+    public void testBackwardConsecutiveHighLoss() {
+        assertEquals(123456781L, lasc1.backwardConsecutiveHighLoss().longValue());
+    }
+
+    @Test
+    public void testForwardAvailable() {
+        assertEquals(123456784L, lasc1.forwardAvailable().longValue());
+    }
+
+    @Test
+    public void testBackwardAvailable() {
+        assertEquals(123456780L, lasc1.backwardAvailable().longValue());
+    }
+
+    @Test
+    public void testForwardUnavailable() {
+        assertEquals(123456787L, lasc1.forwardUnavailable().longValue());
+    }
+
+    @Test
+    public void testBackwardUnavailable() {
+        assertEquals(123456783L, lasc1.backwardUnavailable().longValue());
+    }
+
+    @Test
+    public void testForwardMinFrameLossRatio() {
+        assertEquals(12350, lasc1.forwardMinFrameLossRatio().intValue());
+    }
+
+    @Test
+    public void testForwardMaxFrameLossRatio() {
+        assertEquals(12349, lasc1.forwardMaxFrameLossRatio().intValue());
+    }
+
+    @Test
+    public void testForwardAverageFrameLossRatio() {
+        assertEquals(12348, lasc1.forwardAverageFrameLossRatio().intValue());
+    }
+
+    @Test
+    public void testBackwardMinFrameLossRatio() {
+        assertEquals(12347, lasc1.backwardMinFrameLossRatio().intValue());
+    }
+
+    @Test
+    public void testBackwardMaxFrameLossRatio() {
+        assertEquals(12346, lasc1.backwardMaxFrameLossRatio().intValue());
+    }
+
+    @Test
+    public void testBackwardAverageFrameLossRatio() {
+        assertEquals(12345, lasc1.backwardAverageFrameLossRatio().intValue());
+    }
+
+}
diff --git a/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossAvailabilityStatHistoryTest.java b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossAvailabilityStatHistoryTest.java
new file mode 100644
index 0000000..1b68b6e
--- /dev/null
+++ b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossAvailabilityStatHistoryTest.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.time.Duration;
+import java.time.Instant;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+import org.onosproject.incubator.net.l2monitoring.soam.loss.LossAvailabilityStatHistory.LaStatHistoryBuilder;
+
+public class LossAvailabilityStatHistoryTest {
+    LossAvailabilityStatHistory lash1;
+
+    @Before
+    public void setUp() {
+        LaStatHistoryBuilder builder = DefaultLaStatHistory.builder(
+                Duration.ofMinutes(12), true, SoamId.valueOf(5),
+                Instant.ofEpochSecond(123456789L));
+
+        lash1 = builder.build();
+    }
+
+    @Test
+    public void testHistoryStatsId() {
+        assertEquals(5, lash1.historyStatsId().id().intValue());
+    }
+
+    @Test
+    public void testEndTime() {
+        assertEquals(123456789L, lash1.endTime().getEpochSecond());
+    }
+
+    @Test
+    public void testElapsedTime() {
+        assertEquals(12, lash1.elapsedTime().toMinutes());
+    }
+
+    @Test
+    public void testSuspectStatus() {
+        assertTrue(lash1.suspectStatus());
+    }
+
+}
diff --git a/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementCreateTest.java b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementCreateTest.java
new file mode 100644
index 0000000..c7d1264
--- /dev/null
+++ b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementCreateTest.java
@@ -0,0 +1,194 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import static org.junit.Assert.*;
+
+import java.time.Duration;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.incubator.net.l2monitoring.cfm.Mep.Priority;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId;
+import org.onosproject.incubator.net.l2monitoring.soam.MeasurementCreateBase.SessionType;
+import org.onosproject.incubator.net.l2monitoring.soam.MilliPct;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+import org.onosproject.incubator.net.l2monitoring.soam.StartTime;
+import org.onosproject.incubator.net.l2monitoring.soam.StopTime;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.DataPattern;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.TestTlvPattern;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.Version;
+import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementCreate.CounterOption;
+import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementCreate.LmCreateBuilder;
+import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementCreate.LmType;
+
+public class LossMeasurementCreateTest {
+
+    LossMeasurementCreate lmc1;
+
+    @Before
+    public void setUp() throws SoamConfigException {
+
+        LossMeasurementThreshold lmt1 = DefaultLmThreshold
+                .builder(SoamId.valueOf(4)).build();
+
+
+        LmCreateBuilder builder = (LmCreateBuilder) DefaultLmCreate
+                .builder(Version.Y17312008, MepId.valueOf((short) 10),
+                Priority.PRIO3, LmType.LMLMM)
+                .addToCountersEnabled(CounterOption.AVAILABILITY_FORWARD_AVERAGE_FLR)
+                .addToCountersEnabled(CounterOption.AVAILABILITY_FORWARD_CONSECUTIVE_HIGH_LOSS)
+                .availabilityFlrThreshold(MilliPct.ofRatio(0.201f))
+                .availabilityMeasurementInterval(Duration.ofSeconds(5))
+                .availabilityNumberConsecutiveFlrMeasurements(6)
+                .availabilityNumberConsecutiveHighFlr((short) 7)
+                .availabilityNumberConsecutiveIntervals((short) 8)
+                .addToLossMeasurementThreshold(lmt1)
+                .frameSize((short) 100)
+                .dataPattern(DataPattern.ZEROES)
+                .testTlvIncluded(true)
+                .testTlvPattern(TestTlvPattern.NULL_SIGNAL_WITHOUT_CRC_32)
+                .messagePeriod(Duration.ofMinutes(9))
+                .measurementInterval(Duration.ofMinutes(10))
+                .numberIntervalsStored((short) 11)
+                .alignMeasurementIntervals(true)
+                .alignMeasurementOffset(Duration.ofSeconds(12))
+                .startTime(StartTime.immediate())
+                .stopTime(StopTime.none())
+                .sessionType(SessionType.PROACTIVE);
+
+        lmc1 = builder.build();
+    }
+
+    @Test
+    public void testLmCfgType() {
+        assertEquals(LmType.LMLMM, lmc1.lmCfgType());
+    }
+
+    @Test
+    public void testCountersEnabled() {
+        assertEquals(2, lmc1.countersEnabled().size());
+    }
+
+    @Test
+    public void testAvailabilityMeasurementInterval() {
+        assertEquals(5, lmc1.availabilityMeasurementInterval().getSeconds());
+    }
+
+    @Test
+    public void testAvailabilityNumberConsecutiveFlrMeasurements() {
+        assertEquals(6, lmc1.availabilityNumberConsecutiveFlrMeasurements().intValue());
+    }
+
+    @Test
+    public void testAvailabilityFlrThreshold() {
+        assertEquals(0.201f, lmc1.availabilityFlrThreshold().ratioValue(), 0.0001f);
+    }
+
+    @Test
+    public void testAvailabilityNumberConsecutiveIntervals() {
+        assertEquals(8, lmc1.availabilityNumberConsecutiveIntervals().shortValue());
+    }
+
+    @Test
+    public void testAvailabilityNumberConsecutiveHighFlr() {
+        assertEquals(7, lmc1.availabilityNumberConsecutiveHighFlr().shortValue());
+    }
+
+    @Test
+    public void testLossMeasurementThreshold() {
+        assertEquals(1, lmc1.lossMeasurementThreshold().size());
+    }
+
+    @Test
+    public void testVersion() {
+        assertEquals(Version.Y17312008, lmc1.version());
+    }
+
+    @Test
+    public void testRemoteMepId() {
+        assertEquals(10, lmc1.remoteMepId().id().shortValue());
+    }
+
+    @Test
+    public void testMessagePeriod() {
+        assertEquals(9, lmc1.messagePeriod().toMinutes());
+    }
+
+    @Test
+    public void testPriority() {
+        assertEquals(Priority.PRIO3, lmc1.priority());
+    }
+
+    @Test
+    public void testFrameSize() {
+        assertEquals(100, lmc1.frameSize().shortValue());
+    }
+
+    @Test
+    public void testDataPattern() {
+        assertEquals(DataPattern.ZEROES, lmc1.dataPattern());
+    }
+
+    @Test
+    public void testTestTlvIncluded() {
+        assertEquals(true, lmc1.testTlvIncluded());
+    }
+
+    @Test
+    public void testTestTlvPattern() {
+        assertEquals(TestTlvPattern.NULL_SIGNAL_WITHOUT_CRC_32, lmc1.testTlvPattern());
+    }
+
+    @Test
+    public void testMeasurementInterval() {
+        assertEquals(10, lmc1.measurementInterval().toMinutes());
+    }
+
+    @Test
+    public void testNumberIntervalsStored() {
+        assertEquals(11, lmc1.numberIntervalsStored().shortValue());
+    }
+
+    @Test
+    public void testAlignMeasurementIntervals() {
+        assertEquals(true, lmc1.alignMeasurementIntervals());
+    }
+
+    @Test
+    public void testAlignMeasurementOffset() {
+        assertEquals(12, lmc1.alignMeasurementOffset().getSeconds());
+    }
+
+    @Test
+    public void testStartTime() {
+        assertEquals(StartTime.immediate().option(),
+                lmc1.startTime().option());
+    }
+
+    @Test
+    public void testStopTime() {
+        assertEquals(StopTime.none().option(),
+                lmc1.stopTime().option());
+    }
+
+    @Test
+    public void testSessionType() {
+        assertEquals(SessionType.PROACTIVE, lmc1.sessionType());
+    }
+
+}
diff --git a/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementEntryTest.java b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementEntryTest.java
new file mode 100644
index 0000000..30b637a
--- /dev/null
+++ b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementEntryTest.java
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.time.Duration;
+import java.time.Instant;
+import java.util.ArrayList;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.incubator.net.l2monitoring.cfm.Mep.Priority;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId;
+import org.onosproject.incubator.net.l2monitoring.soam.MilliPct;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.Version;
+import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementCreate.CounterOption;
+import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementCreate.LmType;
+import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementEntry.AvailabilityType;
+import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementEntry.LmEntryBuilder;
+
+public class LossMeasurementEntryTest {
+
+    LossMeasurementEntry lme1;
+
+    @Before
+    public void setUp() throws SoamConfigException {
+        LmEntryBuilder builder = DefaultLmEntry.builder(
+                Version.Y17312008, MepId.valueOf((short) 10),
+                Priority.PRIO3, LmType.LMLMM, SoamId.valueOf(1))
+                .measuredAvailabilityBackwardStatus(AvailabilityType.UNAVAILABLE)
+                .measuredAvailabilityForwardStatus(AvailabilityType.UNKNOWN)
+                .measuredBackwardFlr(MilliPct.ofMilliPct(1600))
+                .measuredBackwardLastTransitionTime(Instant.ofEpochSecond(123456L))
+                .measuredForwardFlr(MilliPct.ofMilliPct(1601))
+                .measuredForwardLastTransitionTime(Instant.ofEpochSecond(123457L))
+
+                .availabilityCurrent(DefaultLaStatCurrent.builder(
+                        Duration.ofMinutes(9), false, Instant.ofEpochSecond(9876543))
+                        .build())
+                .measurementCurrent(DefaultLmStatCurrent.builder(
+                        Duration.ofMinutes(10), true, Instant.ofEpochSecond(9876544))
+                        .build())
+
+                .addToAvailabilityHistories(DefaultLaStatHistory.builder(
+                        Duration.ofMinutes(11), true, SoamId.valueOf(10),
+                        Instant.ofEpochSecond(9876545))
+                        .build())
+                .addToAvailabilityHistories(DefaultLaStatHistory.builder(
+                        Duration.ofMinutes(12), true, SoamId.valueOf(11),
+                        Instant.ofEpochSecond(9876546))
+                        .build())
+
+                .addToMeasurementHistories(DefaultLmStatHistory.builder(
+                        Duration.ofMinutes(13), true, SoamId.valueOf(12),
+                        Instant.ofEpochSecond(9876547))
+                        .build())
+                .addToMeasurementHistories(DefaultLmStatHistory.builder(
+                        Duration.ofMinutes(14), true, SoamId.valueOf(13),
+                        Instant.ofEpochSecond(9876548))
+                        .build());
+
+        builder = (LmEntryBuilder) builder
+                .addToCountersEnabled(CounterOption.AVAILABILITY_BACKWARD_CONSECUTIVE_HIGH_LOSS)
+                .addToCountersEnabled(CounterOption.AVAILABILITY_FORWARD_MAX_FLR)
+                .alignMeasurementIntervals(true)
+                .frameSize((short) 100);
+
+        lme1 = builder.build();
+    }
+
+    @Test
+    public void testLmId() {
+        assertEquals(1, lme1.lmId().id().intValue());
+    }
+
+    @Test
+    public void testMeasuredForwardFlr() {
+        assertEquals(1601, lme1.measuredForwardFlr().intValue());
+    }
+
+    @Test
+    public void testMeasuredBackwardFlr() {
+        assertEquals(1600, lme1.measuredBackwardFlr().intValue());
+    }
+
+    @Test
+    public void testMeasuredAvailabilityForwardStatus() {
+        assertEquals(AvailabilityType.UNKNOWN, lme1.measuredAvailabilityForwardStatus());
+    }
+
+    @Test
+    public void testMeasuredAvailabilityBackwardStatus() {
+        assertEquals(AvailabilityType.UNAVAILABLE, lme1.measuredAvailabilityBackwardStatus());
+    }
+
+    @Test
+    public void testMeasuredForwardLastTransitionTime() {
+        assertEquals(123457L, lme1.measuredForwardLastTransitionTime().getEpochSecond());
+    }
+
+    @Test
+    public void testMeasuredBackwardLastTransitionTime() {
+        assertEquals(123456L, lme1.measuredBackwardLastTransitionTime().getEpochSecond());
+    }
+
+    @Test
+    public void testMeasurementCurrent() {
+        assertEquals(10, lme1.measurementCurrent().elapsedTime().toMinutes());
+    }
+
+    @Test
+    public void testMeasurementHistories() {
+        assertEquals(2, lme1.measurementHistories().size());
+        ArrayList<LossMeasurementStatHistory> histories = new ArrayList<>();
+        lme1.measurementHistories().forEach(histories::add);
+        assertEquals(14, histories.get(1).elapsedTime().toMinutes());
+    }
+
+    @Test
+    public void testAvailabilityCurrent() {
+        assertEquals(9, lme1.availabilityCurrent().elapsedTime().toMinutes());
+    }
+
+    @Test
+    public void testAvailabilityHistories() {
+        assertEquals(2, lme1.measurementHistories().size());
+        ArrayList<LossAvailabilityStatHistory> histories = new ArrayList<>();
+        lme1.availabilityHistories().forEach(histories::add);
+        assertEquals(11, histories.get(0).elapsedTime().toMinutes());
+    }
+
+    @Test
+    public void testLmCfgType() {
+        assertEquals(LmType.LMLMM, lme1.lmCfgType());
+    }
+
+    @Test
+    public void testAlignMeasurementIntervals() {
+        assertTrue(lme1.alignMeasurementIntervals());
+    }
+}
diff --git a/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementStatCurrentTest.java b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementStatCurrentTest.java
new file mode 100644
index 0000000..76e8246
--- /dev/null
+++ b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementStatCurrentTest.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.time.Duration;
+import java.time.Instant;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.incubator.net.l2monitoring.soam.MilliPct;
+import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementStatCurrent.LmStatCurrentBuilder;
+
+public class LossMeasurementStatCurrentTest {
+    LossMeasurementStatCurrent lmsc1;
+
+    @Before
+    public void setUp() {
+        LmStatCurrentBuilder builder = DefaultLmStatCurrent
+                .builder(Duration.ofMinutes(14),
+                        true, Instant.ofEpochSecond(12345678L));
+        builder = (LmStatCurrentBuilder) builder
+                .backwardAverageFrameLossRatio(MilliPct.ofMilliPct(301))
+                .backwardMaxFrameLossRatio(MilliPct.ofMilliPct(302))
+                .backwardMinFrameLossRatio(MilliPct.ofMilliPct(303))
+                .backwardReceivedFrames(123456780L)
+                .backwardTransmittedFrames(123456781L)
+                .forwardAverageFrameLossRatio(MilliPct.ofMilliPct(304))
+                .forwardMaxFrameLossRatio(MilliPct.ofMilliPct(305))
+                .forwardMinFrameLossRatio(MilliPct.ofMilliPct(306))
+                .forwardReceivedFrames(123456782L)
+                .forwardTransmittedFrames(123456783L)
+                .soamPdusReceived(123456784L)
+                .soamPdusSent(123456785L);
+
+        lmsc1 = builder.build();
+    }
+
+    @Test
+    public void testStartTime() {
+        assertEquals(12345678L, lmsc1.startTime().getEpochSecond());
+    }
+
+    @Test
+    public void testElapsedTime() {
+        assertEquals(14, lmsc1.elapsedTime().toMinutes());
+    }
+
+    @Test
+    public void testSuspectStatus() {
+        assertTrue(lmsc1.suspectStatus());
+    }
+
+    @Test
+    public void testForwardTransmittedFrames() {
+        assertEquals(123456783L, lmsc1.forwardTransmittedFrames().longValue());
+    }
+
+    @Test
+    public void testForwardReceivedFrames() {
+        assertEquals(123456782L, lmsc1.forwardReceivedFrames().longValue());
+    }
+
+    @Test
+    public void testForwardMinFrameLossRatio() {
+        assertEquals(306, lmsc1.forwardMinFrameLossRatio().intValue());
+    }
+
+    @Test
+    public void testForwardMaxFrameLossRatio() {
+        assertEquals(305, lmsc1.forwardMaxFrameLossRatio().intValue());
+    }
+
+    @Test
+    public void testForwardAverageFrameLossRatio() {
+        assertEquals(304, lmsc1.forwardAverageFrameLossRatio().intValue());
+    }
+
+    @Test
+    public void testBackwardTransmittedFrames() {
+        assertEquals(123456781L, lmsc1.backwardTransmittedFrames().longValue());
+    }
+
+    @Test
+    public void testBackwardReceivedFrames() {
+        assertEquals(123456780L, lmsc1.backwardReceivedFrames().longValue());
+    }
+
+    @Test
+    public void testBackwardMinFrameLossRatio() {
+        assertEquals(303, lmsc1.backwardMinFrameLossRatio().intValue());
+    }
+
+    @Test
+    public void testBackwardMaxFrameLossRatio() {
+        assertEquals(302, lmsc1.backwardMaxFrameLossRatio().intValue());
+    }
+
+    @Test
+    public void testBackwardAverageFrameLossRatio() {
+        assertEquals(301, lmsc1.backwardAverageFrameLossRatio().intValue());
+    }
+
+    @Test
+    public void testSoamPdusSent() {
+        assertEquals(123456785L, lmsc1.soamPdusSent().longValue());
+    }
+
+    @Test
+    public void testSoamPdusReceived() {
+        assertEquals(123456784L, lmsc1.soamPdusReceived().longValue());
+    }
+
+}
diff --git a/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementStatHistoryTest.java b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementStatHistoryTest.java
new file mode 100644
index 0000000..46de87c
--- /dev/null
+++ b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementStatHistoryTest.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.time.Duration;
+import java.time.Instant;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementStatHistory.LmStatHistoryBuilder;
+
+public class LossMeasurementStatHistoryTest {
+    LossMeasurementStatHistory lmsh1;
+
+    @Before
+    public void setUp() {
+        LmStatHistoryBuilder builder = DefaultLmStatHistory.builder(
+                Duration.ofMinutes(11), true, SoamId.valueOf(6),
+                Instant.ofEpochSecond(123456789L));
+
+        lmsh1 = builder.build();
+    }
+
+    @Test
+    public void testHistoryStatsId() {
+        assertEquals(6, lmsh1.historyStatsId().id().intValue());
+    }
+
+    @Test
+    public void testEndTime() {
+        assertEquals(123456789L, lmsh1.endTime().getEpochSecond());
+    }
+
+    @Test
+    public void testElapsedTime() {
+        assertEquals(11, lmsh1.elapsedTime().toMinutes());
+    }
+
+    @Test
+    public void testSuspectStatus() {
+        assertTrue(lmsh1.suspectStatus());
+    }
+
+}
diff --git a/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementThresholdOptionTest.java b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementThresholdOptionTest.java
new file mode 100644
index 0000000..0882268
--- /dev/null
+++ b/incubator/api/src/test/java/org/onosproject/incubator/net/l2monitoring/soam/loss/LossMeasurementThresholdOptionTest.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.l2monitoring.soam.loss;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.incubator.net.l2monitoring.soam.MilliPct;
+import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
+import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementThreshold.ThresholdOption;
+
+public class LossMeasurementThresholdOptionTest {
+
+    LossMeasurementThreshold lmt1;
+
+    @Before
+    public void setUp() throws Exception {
+        lmt1 = DefaultLmThreshold
+                .builder(SoamId.valueOf(4))
+                .addToThreshold(ThresholdOption.BACKWARD_CONSECUTIVE_HIGH_LOSS)
+                .addToThreshold(ThresholdOption.MAX_FLR_BACKWARD)
+                .averageFlrBackward(MilliPct.ofMilliPct(301))
+                .averageFlrForward(MilliPct.ofMilliPct(302))
+                .backwardAvailableRatio(MilliPct.ofMilliPct(303))
+                .backwardConsecutiveHighLoss(123451L)
+                .backwardHighLoss(123452L)
+                .backwardUnavailableCount(123453L)
+                .forwardAvailableRatio(MilliPct.ofMilliPct(304))
+                .forwardConsecutiveHighLoss(123454L)
+                .forwardHighLoss(123455L)
+                .forwardUnavailableCount(123456L)
+                .maxFlrBackward(MilliPct.ofMilliPct(305))
+                .maxFlrForward(MilliPct.ofMilliPct(306))
+                .measuredFlrBackward(MilliPct.ofMilliPct(307))
+                .measuredFlrForward(MilliPct.ofMilliPct(308))
+                .build();
+    }
+
+    @Test
+    public void testThresholdId() {
+        assertEquals(4, lmt1.thresholdId().id().intValue());
+    }
+
+    @Test
+    public void testThreshold() {
+        assertEquals(2, lmt1.thresholds().size());
+        ArrayList<ThresholdOption> list = new ArrayList<>();
+        lmt1.thresholds().forEach(list::add);
+        assertEquals(ThresholdOption.BACKWARD_CONSECUTIVE_HIGH_LOSS, list.get(0));
+        assertEquals(ThresholdOption.MAX_FLR_BACKWARD, list.get(1));
+    }
+
+    @Test
+    public void testMeasuredFlrForward() {
+        assertEquals(308, lmt1.measuredFlrForward().intValue());
+    }
+
+    @Test
+    public void testMaxFlrForward() {
+        assertEquals(306, lmt1.maxFlrForward().intValue());
+    }
+
+    @Test
+    public void testAverageFlrForward() {
+        assertEquals(302, lmt1.averageFlrForward().intValue());
+    }
+
+    @Test
+    public void testMeasuredFlrBackward() {
+        assertEquals(307, lmt1.measuredFlrBackward().intValue());
+    }
+
+    @Test
+    public void testMaxFlrBackward() {
+        assertEquals(305, lmt1.maxFlrBackward().intValue());
+    }
+
+    @Test
+    public void testAverageFlrBackward() {
+        assertEquals(301, lmt1.averageFlrBackward().intValue());
+    }
+
+    @Test
+    public void testForwardHighLoss() {
+        assertEquals(123455L, lmt1.forwardHighLoss().longValue());
+    }
+
+    @Test
+    public void testForwardConsecutiveHighLoss() {
+        assertEquals(123454L, lmt1.forwardConsecutiveHighLoss().longValue());
+    }
+
+    @Test
+    public void testBackwardHighLoss() {
+        assertEquals(123452L, lmt1.backwardHighLoss().longValue());
+    }
+
+    @Test
+    public void testBackwardConsecutiveHighLoss() {
+        assertEquals(123451L, lmt1.backwardConsecutiveHighLoss().longValue());
+    }
+
+    @Test
+    public void testForwardUnavailableCount() {
+        assertEquals(123456L, lmt1.forwardUnavailableCount().longValue());
+    }
+
+    @Test
+    public void testForwardAvailableRatio() {
+        assertEquals(304, lmt1.forwardAvailableRatio().intValue());
+    }
+
+    @Test
+    public void testBackwardUnavailableCount() {
+        assertEquals(123453L, lmt1.backwardUnavailableCount().longValue());
+    }
+
+    @Test
+    public void testBackwardAvailableRatio() {
+        assertEquals(303, lmt1.backwardAvailableRatio().intValue());
+    }
+}