Ray Milkey | dbf59f0 | 2016-08-19 12:54:16 -0700 | [diff] [blame] | 1 | package org.onosproject.net.config.basics; |
| 2 | |
| 3 | import java.time.Duration; |
| 4 | |
| 5 | import org.junit.Test; |
| 6 | import org.onosproject.net.Link; |
| 7 | import org.onosproject.net.LinkKey; |
| 8 | import org.onosproject.net.NetTestTools; |
| 9 | import org.onosproject.net.config.ConfigApplyDelegate; |
| 10 | |
| 11 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 12 | import com.fasterxml.jackson.databind.node.JsonNodeFactory; |
| 13 | |
| 14 | import static java.lang.Boolean.FALSE; |
| 15 | import static org.hamcrest.MatcherAssert.assertThat; |
| 16 | import static org.hamcrest.Matchers.is; |
| 17 | |
| 18 | /** |
| 19 | * Unit tests for the BasicLinkConfig class. |
| 20 | */ |
| 21 | |
| 22 | public class BasicLinkConfigTest { |
| 23 | private static final long BANDWIDTH = 11; |
| 24 | private static final double METRIC = 3.0; |
| 25 | private static final Duration LATENCY = Duration.ofNanos(5555); |
| 26 | |
| 27 | /** |
| 28 | * Tests construction, setters and getters of a BasicLinkConfig object. |
| 29 | */ |
| 30 | @Test |
| 31 | public void testConstruction() { |
| 32 | BasicLinkConfig config = new BasicLinkConfig(); |
| 33 | ConfigApplyDelegate delegate = configApply -> { }; |
| 34 | ObjectMapper mapper = new ObjectMapper(); |
| 35 | LinkKey linkKey = LinkKey.linkKey( |
| 36 | NetTestTools.connectPoint("device1", 1), |
| 37 | NetTestTools.connectPoint("device2", 2)); |
| 38 | |
| 39 | config.init(linkKey, "KEY", JsonNodeFactory.instance.objectNode(), mapper, delegate); |
| 40 | |
| 41 | |
| 42 | config.bandwidth(BANDWIDTH) |
| 43 | .isDurable(FALSE) |
| 44 | .metric(METRIC) |
| 45 | .type(Link.Type.DIRECT) |
| 46 | .latency(LATENCY); |
| 47 | |
| 48 | assertThat(config.bandwidth(), is(BANDWIDTH)); |
| 49 | assertThat(config.isDurable(), is(FALSE)); |
| 50 | assertThat(config.metric(), is(METRIC)); |
| 51 | assertThat(config.type(), is(Link.Type.DIRECT)); |
| 52 | assertThat(config.latency(), is(LATENCY)); |
| 53 | assertThat(config.isValid(), is(true)); |
| 54 | } |
| 55 | } |