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.SoamId; |
| 27 | import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementStatHistory.LmStatHistoryBuilder; |
| 28 | |
| 29 | public class LossMeasurementStatHistoryTest { |
| 30 | LossMeasurementStatHistory lmsh1; |
| 31 | |
| 32 | @Before |
| 33 | public void setUp() { |
| 34 | LmStatHistoryBuilder builder = DefaultLmStatHistory.builder( |
| 35 | Duration.ofMinutes(11), true, SoamId.valueOf(6), |
| 36 | Instant.ofEpochSecond(123456789L)); |
| 37 | |
| 38 | lmsh1 = builder.build(); |
| 39 | } |
| 40 | |
| 41 | @Test |
| 42 | public void testHistoryStatsId() { |
| 43 | assertEquals(6, lmsh1.historyStatsId().id().intValue()); |
| 44 | } |
| 45 | |
| 46 | @Test |
| 47 | public void testEndTime() { |
| 48 | assertEquals(123456789L, lmsh1.endTime().getEpochSecond()); |
| 49 | } |
| 50 | |
| 51 | @Test |
| 52 | public void testElapsedTime() { |
| 53 | assertEquals(11, lmsh1.elapsedTime().toMinutes()); |
| 54 | } |
| 55 | |
| 56 | @Test |
| 57 | public void testSuspectStatus() { |
| 58 | assertTrue(lmsh1.suspectStatus()); |
| 59 | } |
| 60 | |
| 61 | } |