blob: 47fba6c9e6123ceffdd497ea7ece1174c1a204f6 [file] [log] [blame]
samanwita pald1acfd82015-06-24 11:18:43 -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 com.google.common.testing.EqualsTester;
samanwita pald1acfd82015-06-24 11:18:43 -070019import org.junit.Test;
20
21import static org.hamcrest.MatcherAssert.assertThat;
22import static org.hamcrest.Matchers.is;
23
24/**
25 * MapEvent unit tests.
26 */
Sho SHIMIZU8dc81ea2015-09-10 10:59:43 -070027public class MapEventTest {
samanwita pald1acfd82015-06-24 11:18:43 -070028
29 private final Versioned<Integer> vStats = new Versioned<>(2, 1);
30
31 private final MapEvent<String, Integer> stats1 = new MapEvent<>("a", MapEvent.Type.INSERT, "1", vStats);
32
33 private final MapEvent<String, Integer> stats2 = new MapEvent<>("a", MapEvent.Type.REMOVE, "1", vStats);
34
35 private final MapEvent<String, Integer> stats3 = new MapEvent<>("a", MapEvent.Type.UPDATE, "1", vStats);
36
37 /**
38 * Tests the creation of the MapEvent object.
39 */
40 @Test
41 public void testConstruction() {
42 assertThat(stats1.name(), is("a"));
43 assertThat(stats1.type(), is(MapEvent.Type.INSERT));
44 assertThat(stats1.key(), is("1"));
45 assertThat(stats1.value(), is(vStats));
46 }
47
48 /**
49 * Tests the equals, hashCode and toString methods using Guava EqualsTester.
50 */
51 @Test
52 public void testEquals() {
53 new EqualsTester()
54 .addEqualityGroup(stats1, stats1)
55 .addEqualityGroup(stats2)
56 .addEqualityGroup(stats3)
57 .testEquals();
58 }
59
Sho SHIMIZU8dc81ea2015-09-10 10:59:43 -070060}