blob: 39481ca046c0e055ab3dc9ec1accd1f72faafe95 [file] [log] [blame]
Ray Milkey67d53cc2015-07-23 16:32:36 -07001/*
2 * Copyright 2015 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 */
16package org.onosproject.store.service;
17
18import org.junit.Test;
19
20import com.google.common.testing.EqualsTester;
21
22import static org.hamcrest.MatcherAssert.assertThat;
23import static org.hamcrest.Matchers.is;
24import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
25import static org.onosproject.store.service.AtomicValueEvent.Type.UPDATE;
26
27/**
28 * Unit tests for the AtomicValueEvent class.
29 */
30public class AtomicValueEventTest {
31
32 AtomicValueEvent<String> event1 =
33 new AtomicValueEvent<>("map1", UPDATE, "e1");
34 AtomicValueEvent<String> event2 =
35 new AtomicValueEvent<>("map1", UPDATE, "e2");
36 AtomicValueEvent<String> sameAsEvent2 =
37 new AtomicValueEvent<>("map1", UPDATE, "e2");
38 AtomicValueEvent<String> event3 =
39 new AtomicValueEvent<>("map2", UPDATE, "e2");
40
41 /**
42 * Checks that the SetEvent class is immutable.
43 */
44 @Test
45 public void testImmutability() {
46 assertThatClassIsImmutable(AtomicValueEvent.class);
47 }
48
49 /**
50 * Checks the equals(), hashCode() and toString() operations.
51 */
52 @Test
53 public void testEquals() {
54 new EqualsTester()
55 .addEqualityGroup(event1)
56 .addEqualityGroup(event2, sameAsEvent2)
57 .addEqualityGroup(event3)
58 .testEquals();
59 }
60
61 /**
62 * Checks that construction of the object is correct.
63 */
64 @Test
65 public void testConstruction() {
66 assertThat(event1.type(), is(UPDATE));
67 assertThat(event1.value(), is("e1"));
68 assertThat(event1.name(), is("map1"));
69 }
70
71}