blob: 21bd896d1943c982aa450830b5d8d19c64411cbd [file] [log] [blame]
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -08003 *
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 */
16package org.onosproject.net.driver;
17
18import com.google.common.collect.ImmutableMap;
19import org.junit.Before;
20import org.junit.Test;
21
Andrea Campanella80520b82016-01-05 17:55:29 -080022import java.util.ArrayList;
23
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080024import static org.junit.Assert.assertSame;
25import static org.junit.Assert.assertTrue;
26
27public class DefaultDriverHandlerTest {
28
29 DefaultDriver ddc;
30 DefaultDriverData data;
31 DefaultDriverHandler handler;
32
33 @Before
34 public void setUp() {
Andrea Campanella80520b82016-01-05 17:55:29 -080035 ddc = new DefaultDriver("foo.bar", new ArrayList<>(), "Circus", "lux", "1.2a",
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080036 ImmutableMap.of(TestBehaviour.class,
37 TestBehaviourImpl.class,
38 TestBehaviourTwo.class,
39 TestBehaviourTwoImpl.class),
40 ImmutableMap.of("foo", "bar"));
Thomas Vachuska80b0a802015-07-17 08:43:30 -070041 data = new DefaultDriverData(ddc, DefaultDriverDataTest.DEVICE_ID);
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080042 handler = new DefaultDriverHandler(data);
43 }
44
45 @Test
46 public void basics() {
47 assertSame("incorrect data", data, handler.data());
48 assertTrue("incorrect toString", handler.toString().contains("1.2a"));
49 }
50
51 @Test
52 public void behaviour() {
53 TestBehaviourTwo behaviour = handler.behaviour(TestBehaviourTwo.class);
54 assertTrue("incorrect behaviour", behaviour instanceof TestBehaviourTwoImpl);
55 }
56
57}