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.LossAvailabilityStatCurrent.LaStatCurrentBuilder; |
| 28 | |
| 29 | public class LossAvailabilityStatCurrentTest { |
| 30 | |
| 31 | LossAvailabilityStatCurrent lasc1; |
| 32 | |
| 33 | @Before |
| 34 | public void setUp() { |
| 35 | LaStatCurrentBuilder builder = DefaultLaStatCurrent.builder( |
| 36 | Duration.ofMinutes(13), true, Instant.ofEpochSecond(123456789L)); |
| 37 | builder = (LaStatCurrentBuilder) builder |
| 38 | .backwardAvailable(123456780L) |
| 39 | .backwardAverageFrameLossRatio(MilliPct.ofMilliPct(12345)) |
| 40 | .backwardConsecutiveHighLoss(123456781L) |
| 41 | .backwardHighLoss(123456782L) |
| 42 | .backwardMaxFrameLossRatio(MilliPct.ofMilliPct(12346)) |
| 43 | .backwardMinFrameLossRatio(MilliPct.ofMilliPct(12347)) |
| 44 | .backwardUnavailable(123456783L) |
| 45 | .forwardAvailable(123456784L) |
| 46 | .forwardAverageFrameLossRatio(MilliPct.ofMilliPct(12348)) |
| 47 | .forwardConsecutiveHighLoss(123456785L) |
| 48 | .forwardHighLoss(123456786L) |
| 49 | .forwardMaxFrameLossRatio(MilliPct.ofMilliPct(12349)) |
| 50 | .forwardMinFrameLossRatio(MilliPct.ofMilliPct(12350)) |
| 51 | .forwardUnavailable(123456787L); |
| 52 | |
| 53 | lasc1 = builder.build(); |
| 54 | } |
| 55 | |
| 56 | @Test |
| 57 | public void testStartTime() { |
| 58 | assertEquals(123456789L, lasc1.startTime().getEpochSecond()); |
| 59 | } |
| 60 | |
| 61 | @Test |
| 62 | public void testElapsedTime() { |
| 63 | assertEquals(13, lasc1.elapsedTime().toMinutes()); |
| 64 | } |
| 65 | |
| 66 | @Test |
| 67 | public void testSuspectStatus() { |
| 68 | assertTrue(lasc1.suspectStatus()); |
| 69 | } |
| 70 | |
| 71 | @Test |
| 72 | public void testForwardHighLoss() { |
| 73 | assertEquals(123456786L, lasc1.forwardHighLoss().longValue()); |
| 74 | } |
| 75 | |
| 76 | @Test |
| 77 | public void testBackwardHighLoss() { |
| 78 | assertEquals(123456782L, lasc1.backwardHighLoss().longValue()); |
| 79 | } |
| 80 | |
| 81 | @Test |
| 82 | public void testForwardConsecutiveHighLoss() { |
| 83 | assertEquals(123456785L, lasc1.forwardConsecutiveHighLoss().longValue()); |
| 84 | } |
| 85 | |
| 86 | @Test |
| 87 | public void testBackwardConsecutiveHighLoss() { |
| 88 | assertEquals(123456781L, lasc1.backwardConsecutiveHighLoss().longValue()); |
| 89 | } |
| 90 | |
| 91 | @Test |
| 92 | public void testForwardAvailable() { |
| 93 | assertEquals(123456784L, lasc1.forwardAvailable().longValue()); |
| 94 | } |
| 95 | |
| 96 | @Test |
| 97 | public void testBackwardAvailable() { |
| 98 | assertEquals(123456780L, lasc1.backwardAvailable().longValue()); |
| 99 | } |
| 100 | |
| 101 | @Test |
| 102 | public void testForwardUnavailable() { |
| 103 | assertEquals(123456787L, lasc1.forwardUnavailable().longValue()); |
| 104 | } |
| 105 | |
| 106 | @Test |
| 107 | public void testBackwardUnavailable() { |
| 108 | assertEquals(123456783L, lasc1.backwardUnavailable().longValue()); |
| 109 | } |
| 110 | |
| 111 | @Test |
| 112 | public void testForwardMinFrameLossRatio() { |
| 113 | assertEquals(12350, lasc1.forwardMinFrameLossRatio().intValue()); |
| 114 | } |
| 115 | |
| 116 | @Test |
| 117 | public void testForwardMaxFrameLossRatio() { |
| 118 | assertEquals(12349, lasc1.forwardMaxFrameLossRatio().intValue()); |
| 119 | } |
| 120 | |
| 121 | @Test |
| 122 | public void testForwardAverageFrameLossRatio() { |
| 123 | assertEquals(12348, lasc1.forwardAverageFrameLossRatio().intValue()); |
| 124 | } |
| 125 | |
| 126 | @Test |
| 127 | public void testBackwardMinFrameLossRatio() { |
| 128 | assertEquals(12347, lasc1.backwardMinFrameLossRatio().intValue()); |
| 129 | } |
| 130 | |
| 131 | @Test |
| 132 | public void testBackwardMaxFrameLossRatio() { |
| 133 | assertEquals(12346, lasc1.backwardMaxFrameLossRatio().intValue()); |
| 134 | } |
| 135 | |
| 136 | @Test |
| 137 | public void testBackwardAverageFrameLossRatio() { |
| 138 | assertEquals(12345, lasc1.backwardAverageFrameLossRatio().intValue()); |
| 139 | } |
| 140 | |
| 141 | } |