Sho SHIMIZU | 047f5b7 | 2016-06-08 12:00:19 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Sho SHIMIZU | 047f5b7 | 2016-06-08 12:00:19 -0700 | [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 | |
| 17 | package org.onosproject.store.resource.impl; |
| 18 | |
| 19 | import com.google.common.collect.ImmutableSet; |
| 20 | import org.junit.Test; |
Sho SHIMIZU | 8f4f7af | 2016-07-06 15:03:39 -0700 | [diff] [blame] | 21 | import org.onlab.packet.VlanId; |
Sho SHIMIZU | 047f5b7 | 2016-06-08 12:00:19 -0700 | [diff] [blame] | 22 | import org.onosproject.net.DeviceId; |
| 23 | import org.onosproject.net.resource.DiscreteResource; |
| 24 | import org.onosproject.net.resource.Resources; |
| 25 | |
| 26 | import java.util.Optional; |
| 27 | |
| 28 | import static org.hamcrest.Matchers.is; |
| 29 | import static org.junit.Assert.*; |
| 30 | |
| 31 | public class EmptyDiscreteResourcesTest { |
| 32 | private EmptyDiscreteResources sut = EmptyDiscreteResources.INSTANCE; |
| 33 | |
| 34 | @Test |
| 35 | public void testLookup() { |
| 36 | assertThat(sut.lookup(Resources.discrete(DeviceId.deviceId("a")).id()), is(Optional.empty())); |
| 37 | } |
| 38 | |
| 39 | @Test |
| 40 | public void testDifference() { |
| 41 | DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a")).resource(); |
| 42 | DiscreteResource res2 = Resources.discrete(DeviceId.deviceId("b")).resource(); |
| 43 | |
| 44 | assertThat(sut.difference(DiscreteResources.of(ImmutableSet.of(res1))), |
| 45 | is(EmptyDiscreteResources.INSTANCE)); |
| 46 | assertThat(sut.difference(DiscreteResources.of(ImmutableSet.of(res2))), |
| 47 | is(EmptyDiscreteResources.INSTANCE)); |
| 48 | } |
| 49 | |
| 50 | @Test |
| 51 | public void testIsEmpty() { |
| 52 | assertThat(sut.isEmpty(), is(true)); |
| 53 | } |
| 54 | |
| 55 | @Test |
Sho SHIMIZU | 8f4f7af | 2016-07-06 15:03:39 -0700 | [diff] [blame] | 56 | public void testValuesOf() { |
| 57 | // doesn't match any types of resources |
| 58 | assertThat(sut.valuesOf(Object.class), is(ImmutableSet.of())); |
| 59 | assertThat(sut.valuesOf(VlanId.class), is(ImmutableSet.of())); |
| 60 | } |
| 61 | |
| 62 | @Test |
Sho SHIMIZU | 047f5b7 | 2016-06-08 12:00:19 -0700 | [diff] [blame] | 63 | public void testContainsAny() { |
| 64 | DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a")).resource(); |
| 65 | DiscreteResource res2 = Resources.discrete(DeviceId.deviceId("b")).resource(); |
| 66 | |
| 67 | assertThat(sut.containsAny(ImmutableSet.of(res1)), is(false)); |
| 68 | assertThat(sut.containsAny(ImmutableSet.of(res2)), is(false)); |
| 69 | } |
| 70 | |
| 71 | @Test |
| 72 | public void testAdd() { |
| 73 | DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a")).resource(); |
| 74 | DiscreteResource res2 = Resources.discrete(DeviceId.deviceId("b")).resource(); |
| 75 | |
| 76 | assertThat(sut.add(DiscreteResources.of(ImmutableSet.of(res1))), |
| 77 | is(DiscreteResources.of(ImmutableSet.of(res1)))); |
| 78 | assertThat(sut.add(DiscreteResources.of(ImmutableSet.of(res2))), |
| 79 | is(DiscreteResources.of(ImmutableSet.of(res2)))); |
| 80 | } |
| 81 | |
| 82 | @Test |
| 83 | public void testValues() { |
| 84 | assertThat(sut.values(), is(ImmutableSet.of())); |
| 85 | } |
| 86 | } |