blob: ad2439a1d83ecd08280393631848b2cd17b0e32b [file] [log] [blame]
Sean Condon0e89bda2017-03-21 14:23:19 +00001/*
2 * Copyright 2017-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.incubator.net.l2monitoring.soam.delay;
17
18import static org.junit.Assert.*;
19
20import java.time.Duration;
21
22import org.junit.Before;
23import org.junit.Test;
24import org.onosproject.incubator.net.l2monitoring.cfm.Mep.Priority;
25import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId;
26import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException;
27import org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException;
28import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
29import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.DmType;
30import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.Version;
31import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementEntry.SessionStatus;
32
33public class DelayMeasurementEntryTest {
34
35 DelayMeasurementEntry dmE1;
36
37 @Before
38 public void setUp() throws Exception, SoamConfigException, CfmConfigException {
39
40 DelayMeasurementStatCurrent dmE1c = (DelayMeasurementStatCurrent)
41 DefaultDelayMeasurementStatCurrent.builder(
42 Duration.ofMinutes(6), false)
43 .build();
44
45 DelayMeasurementStatHistory dmE1h1 = (DelayMeasurementStatHistory)
46 DefaultDelayMeasurementStatHistory.builder(
47 SoamId.valueOf(1), Duration.ofMinutes(15), false)
48 .build();
49
50 DelayMeasurementStatHistory dmE1h2 = (DelayMeasurementStatHistory)
51 DefaultDelayMeasurementStatHistory.builder(
52 SoamId.valueOf(2), Duration.ofMinutes(15), false)
53 .build();
54
55 dmE1 = DefaultDelayMeasurementEntry.builder(
56 SoamId.valueOf(1),
57 DmType.DMDMM,
58 Version.Y17312011,
59 MepId.valueOf((short) 10),
60 Priority.PRIO3)
61 .sessionStatus(SessionStatus.NOT_ACTIVE)
62 .frameDelayTwoWay(Duration.ofMillis(1))
63 .frameDelayForward(Duration.ofMillis(2))
64 .frameDelayBackward(Duration.ofMillis(3))
65 .interFrameDelayVariationTwoWay(Duration.ofMillis(4))
66 .interFrameDelayVariationForward(Duration.ofMillis(5))
67 .interFrameDelayVariationBackward(Duration.ofMillis(6))
68 .currentResult(dmE1c)
69 .addToHistoricalResults(dmE1h1)
70 .addToHistoricalResults(dmE1h2)
71 .build();
72 }
73
74 @Test
75 public void testDmId() {
76 assertEquals(1, dmE1.dmId().id().shortValue());
77 }
78
79 @Test
80 public void testSessionStatus() {
81 assertEquals(SessionStatus.NOT_ACTIVE.name(),
82 dmE1.sessionStatus().name());
83 }
84
85 @Test
86 public void testFrameDelayTwoWay() {
87 assertEquals(1, dmE1.frameDelayTwoWay().toMillis());
88 }
89
90 @Test
91 public void testFrameDelayForward() {
92 assertEquals(2, dmE1.frameDelayForward().toMillis());
93 }
94
95 @Test
96 public void testFrameDelayBackward() {
97 assertEquals(3, dmE1.frameDelayBackward().toMillis());
98 }
99
100 @Test
101 public void testInterFrameDelayVariationTwoWay() {
102 assertEquals(4, dmE1.interFrameDelayVariationTwoWay().toMillis());
103 }
104
105 @Test
106 public void testInterFrameDelayVariationForward() {
107 assertEquals(5, dmE1.interFrameDelayVariationForward().toMillis());
108 }
109
110 @Test
111 public void testInterFrameDelayVariationBackward() {
112 assertEquals(6, dmE1.interFrameDelayVariationBackward().toMillis());
113 }
114
115 @Test
116 public void testCurrentResult() {
117 assertEquals(360, dmE1.currentResult().elapsedTime().getSeconds());
118 }
119
120 @Test
121 public void testHistoricalResults() {
122 assertEquals(2, dmE1.historicalResults().size());
123 }
124
125}