blob: c241c0e06d9b57229e474637f1e9799d51d1ddb1 [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;
19import junit.framework.TestCase;
20import org.junit.Test;
21
22import static org.hamcrest.MatcherAssert.assertThat;
23import static org.hamcrest.Matchers.is;
24
25/**
26 * MapEvent unit tests.
27 */
28public class MapEventTest extends TestCase {
29
30 private final Versioned<Integer> vStats = new Versioned<>(2, 1);
31
32 private final MapEvent<String, Integer> stats1 = new MapEvent<>("a", MapEvent.Type.INSERT, "1", vStats);
33
34 private final MapEvent<String, Integer> stats2 = new MapEvent<>("a", MapEvent.Type.REMOVE, "1", vStats);
35
36 private final MapEvent<String, Integer> stats3 = new MapEvent<>("a", MapEvent.Type.UPDATE, "1", vStats);
37
38 /**
39 * Tests the creation of the MapEvent object.
40 */
41 @Test
42 public void testConstruction() {
43 assertThat(stats1.name(), is("a"));
44 assertThat(stats1.type(), is(MapEvent.Type.INSERT));
45 assertThat(stats1.key(), is("1"));
46 assertThat(stats1.value(), is(vStats));
47 }
48
49 /**
50 * Tests the equals, hashCode and toString methods using Guava EqualsTester.
51 */
52 @Test
53 public void testEquals() {
54 new EqualsTester()
55 .addEqualityGroup(stats1, stats1)
56 .addEqualityGroup(stats2)
57 .addEqualityGroup(stats3)
58 .testEquals();
59 }
60
61}