blob: 146930be16b0bdcc2aae742d444d6cfa12ecbd42 [file] [log] [blame]
Ray Milkeyd29bc1c2018-03-13 11:57:11 -07001/*
2 * Copyright 2018-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
17package org.onosproject.net.config.basics;
18
19import com.fasterxml.jackson.databind.ObjectMapper;
20import com.fasterxml.jackson.databind.node.JsonNodeFactory;
21import org.junit.Test;
22import org.onlab.util.Bandwidth;
23import org.onosproject.net.ConnectPoint;
24import org.onosproject.net.NetTestTools;
25import org.onosproject.net.config.ConfigApplyDelegate;
26
27import static org.hamcrest.MatcherAssert.assertThat;
28import static org.hamcrest.Matchers.containsString;
29import static org.hamcrest.Matchers.is;
30
31public class BandwidthCapacityTest {
32
33 @Test
34 public void testConstruction() {
35 BandwidthCapacity config = new BandwidthCapacity();
36 ConfigApplyDelegate delegate = configApply -> { };
37 ObjectMapper mapper = new ObjectMapper();
38 ConnectPoint cp = NetTestTools.connectPoint("cp1", 3);
39
40 config.init(cp, "KEY", JsonNodeFactory.instance.objectNode(), mapper, delegate);
41
42 double expectedBw = 1.0;
43 config.capacity(Bandwidth.mbps(expectedBw));
44 assertThat(config.isValid(), is(true));
45 assertThat(config.toString(), containsString("capacity"));
46
47 }
48
49}