Committed by
Ray Milkey
Added unit tests for MapEvent class.
Change-Id: I3c1c8091da01fbeaabf66d68d7c6cc1f2c2a2455
Showing
1 changed file
with
61 additions
and
0 deletions
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; | ||
19 | +import junit.framework.TestCase; | ||
20 | +import org.junit.Test; | ||
21 | + | ||
22 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
23 | +import static org.hamcrest.Matchers.is; | ||
24 | + | ||
25 | +/** | ||
26 | + * MapEvent unit tests. | ||
27 | + */ | ||
28 | +public 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 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment