samanwita pal | d1acfd8 | 2015-06-24 11:18:43 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.store.service; |
| 17 | |
| 18 | import com.google.common.testing.EqualsTester; |
samanwita pal | d1acfd8 | 2015-06-24 11:18:43 -0700 | [diff] [blame] | 19 | import org.junit.Test; |
| 20 | |
| 21 | import static org.hamcrest.MatcherAssert.assertThat; |
| 22 | import static org.hamcrest.Matchers.is; |
| 23 | |
| 24 | /** |
| 25 | * MapEvent unit tests. |
| 26 | */ |
Sho SHIMIZU | 8dc81ea | 2015-09-10 10:59:43 -0700 | [diff] [blame] | 27 | public class MapEventTest { |
samanwita pal | d1acfd8 | 2015-06-24 11:18:43 -0700 | [diff] [blame] | 28 | |
| 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 SHIMIZU | 8dc81ea | 2015-09-10 10:59:43 -0700 | [diff] [blame] | 60 | } |