blob: 78440dcc0fd7a8659929c876226bb0d64eed3b75 [file] [log] [blame]
Sho SHIMIZU047f5b72016-06-08 12:00:19 -07001/*
2 * Copyright 2016-present Open Networking Laboratory
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.store.resource.impl;
18
19import com.google.common.collect.ImmutableSet;
20import org.junit.Test;
21import org.onosproject.net.DeviceId;
22import org.onosproject.net.resource.DiscreteResource;
23import org.onosproject.net.resource.Resources;
24
25import java.util.Optional;
26
27import static org.hamcrest.Matchers.is;
28import static org.junit.Assert.*;
29
30public class EmptyDiscreteResourcesTest {
31 private EmptyDiscreteResources sut = EmptyDiscreteResources.INSTANCE;
32
33 @Test
34 public void testLookup() {
35 assertThat(sut.lookup(Resources.discrete(DeviceId.deviceId("a")).id()), is(Optional.empty()));
36 }
37
38 @Test
39 public void testDifference() {
40 DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a")).resource();
41 DiscreteResource res2 = Resources.discrete(DeviceId.deviceId("b")).resource();
42
43 assertThat(sut.difference(DiscreteResources.of(ImmutableSet.of(res1))),
44 is(EmptyDiscreteResources.INSTANCE));
45 assertThat(sut.difference(DiscreteResources.of(ImmutableSet.of(res2))),
46 is(EmptyDiscreteResources.INSTANCE));
47 }
48
49 @Test
50 public void testIsEmpty() {
51 assertThat(sut.isEmpty(), is(true));
52 }
53
54 @Test
55 public void testContainsAny() {
56 DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a")).resource();
57 DiscreteResource res2 = Resources.discrete(DeviceId.deviceId("b")).resource();
58
59 assertThat(sut.containsAny(ImmutableSet.of(res1)), is(false));
60 assertThat(sut.containsAny(ImmutableSet.of(res2)), is(false));
61 }
62
63 @Test
64 public void testAdd() {
65 DiscreteResource res1 = Resources.discrete(DeviceId.deviceId("a")).resource();
66 DiscreteResource res2 = Resources.discrete(DeviceId.deviceId("b")).resource();
67
68 assertThat(sut.add(DiscreteResources.of(ImmutableSet.of(res1))),
69 is(DiscreteResources.of(ImmutableSet.of(res1))));
70 assertThat(sut.add(DiscreteResources.of(ImmutableSet.of(res2))),
71 is(DiscreteResources.of(ImmutableSet.of(res2))));
72 }
73
74 @Test
75 public void testValues() {
76 assertThat(sut.values(), is(ImmutableSet.of()));
77 }
78}