Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 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.net.driver; |
| 17 | |
| 18 | import com.google.common.collect.ImmutableMap; |
| 19 | import org.junit.Before; |
| 20 | import org.junit.Test; |
| 21 | |
Andrea Campanella | 80520b8 | 2016-01-05 17:55:29 -0800 | [diff] [blame] | 22 | import java.util.ArrayList; |
| 23 | |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 24 | import static org.junit.Assert.assertSame; |
| 25 | import static org.junit.Assert.assertTrue; |
| 26 | |
| 27 | public class DefaultDriverHandlerTest { |
| 28 | |
| 29 | DefaultDriver ddc; |
| 30 | DefaultDriverData data; |
| 31 | DefaultDriverHandler handler; |
| 32 | |
| 33 | @Before |
| 34 | public void setUp() { |
Andrea Campanella | 80520b8 | 2016-01-05 17:55:29 -0800 | [diff] [blame] | 35 | ddc = new DefaultDriver("foo.bar", new ArrayList<>(), "Circus", "lux", "1.2a", |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 36 | ImmutableMap.of(TestBehaviour.class, |
| 37 | TestBehaviourImpl.class, |
| 38 | TestBehaviourTwo.class, |
| 39 | TestBehaviourTwoImpl.class), |
| 40 | ImmutableMap.of("foo", "bar")); |
Thomas Vachuska | 80b0a80 | 2015-07-17 08:43:30 -0700 | [diff] [blame] | 41 | data = new DefaultDriverData(ddc, DefaultDriverDataTest.DEVICE_ID); |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 42 | 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 | } |