Sean Condon | 0e89bda | 2017-03-21 14:23:19 +0000 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.incubator.net.l2monitoring.soam.loss; |
| 17 | |
| 18 | import static org.junit.Assert.assertEquals; |
| 19 | import static org.junit.Assert.assertTrue; |
| 20 | |
| 21 | import java.time.Duration; |
| 22 | import java.time.Instant; |
| 23 | |
| 24 | import org.junit.Before; |
| 25 | import org.junit.Test; |
| 26 | import org.onosproject.incubator.net.l2monitoring.soam.MilliPct; |
| 27 | import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementStatCurrent.LmStatCurrentBuilder; |
| 28 | |
| 29 | public class LossMeasurementStatCurrentTest { |
| 30 | LossMeasurementStatCurrent lmsc1; |
| 31 | |
| 32 | @Before |
| 33 | public void setUp() { |
| 34 | LmStatCurrentBuilder builder = DefaultLmStatCurrent |
| 35 | .builder(Duration.ofMinutes(14), |
| 36 | true, Instant.ofEpochSecond(12345678L)); |
| 37 | builder = (LmStatCurrentBuilder) builder |
| 38 | .backwardAverageFrameLossRatio(MilliPct.ofMilliPct(301)) |
| 39 | .backwardMaxFrameLossRatio(MilliPct.ofMilliPct(302)) |
| 40 | .backwardMinFrameLossRatio(MilliPct.ofMilliPct(303)) |
| 41 | .backwardReceivedFrames(123456780L) |
| 42 | .backwardTransmittedFrames(123456781L) |
| 43 | .forwardAverageFrameLossRatio(MilliPct.ofMilliPct(304)) |
| 44 | .forwardMaxFrameLossRatio(MilliPct.ofMilliPct(305)) |
| 45 | .forwardMinFrameLossRatio(MilliPct.ofMilliPct(306)) |
| 46 | .forwardReceivedFrames(123456782L) |
| 47 | .forwardTransmittedFrames(123456783L) |
| 48 | .soamPdusReceived(123456784L) |
| 49 | .soamPdusSent(123456785L); |
| 50 | |
| 51 | lmsc1 = builder.build(); |
| 52 | } |
| 53 | |
| 54 | @Test |
| 55 | public void testStartTime() { |
| 56 | assertEquals(12345678L, lmsc1.startTime().getEpochSecond()); |
| 57 | } |
| 58 | |
| 59 | @Test |
| 60 | public void testElapsedTime() { |
| 61 | assertEquals(14, lmsc1.elapsedTime().toMinutes()); |
| 62 | } |
| 63 | |
| 64 | @Test |
| 65 | public void testSuspectStatus() { |
| 66 | assertTrue(lmsc1.suspectStatus()); |
| 67 | } |
| 68 | |
| 69 | @Test |
| 70 | public void testForwardTransmittedFrames() { |
| 71 | assertEquals(123456783L, lmsc1.forwardTransmittedFrames().longValue()); |
| 72 | } |
| 73 | |
| 74 | @Test |
| 75 | public void testForwardReceivedFrames() { |
| 76 | assertEquals(123456782L, lmsc1.forwardReceivedFrames().longValue()); |
| 77 | } |
| 78 | |
| 79 | @Test |
| 80 | public void testForwardMinFrameLossRatio() { |
| 81 | assertEquals(306, lmsc1.forwardMinFrameLossRatio().intValue()); |
| 82 | } |
| 83 | |
| 84 | @Test |
| 85 | public void testForwardMaxFrameLossRatio() { |
| 86 | assertEquals(305, lmsc1.forwardMaxFrameLossRatio().intValue()); |
| 87 | } |
| 88 | |
| 89 | @Test |
| 90 | public void testForwardAverageFrameLossRatio() { |
| 91 | assertEquals(304, lmsc1.forwardAverageFrameLossRatio().intValue()); |
| 92 | } |
| 93 | |
| 94 | @Test |
| 95 | public void testBackwardTransmittedFrames() { |
| 96 | assertEquals(123456781L, lmsc1.backwardTransmittedFrames().longValue()); |
| 97 | } |
| 98 | |
| 99 | @Test |
| 100 | public void testBackwardReceivedFrames() { |
| 101 | assertEquals(123456780L, lmsc1.backwardReceivedFrames().longValue()); |
| 102 | } |
| 103 | |
| 104 | @Test |
| 105 | public void testBackwardMinFrameLossRatio() { |
| 106 | assertEquals(303, lmsc1.backwardMinFrameLossRatio().intValue()); |
| 107 | } |
| 108 | |
| 109 | @Test |
| 110 | public void testBackwardMaxFrameLossRatio() { |
| 111 | assertEquals(302, lmsc1.backwardMaxFrameLossRatio().intValue()); |
| 112 | } |
| 113 | |
| 114 | @Test |
| 115 | public void testBackwardAverageFrameLossRatio() { |
| 116 | assertEquals(301, lmsc1.backwardAverageFrameLossRatio().intValue()); |
| 117 | } |
| 118 | |
| 119 | @Test |
| 120 | public void testSoamPdusSent() { |
| 121 | assertEquals(123456785L, lmsc1.soamPdusSent().longValue()); |
| 122 | } |
| 123 | |
| 124 | @Test |
| 125 | public void testSoamPdusReceived() { |
| 126 | assertEquals(123456784L, lmsc1.soamPdusReceived().longValue()); |
| 127 | } |
| 128 | |
| 129 | } |