Remove getValue() methods from model.api.stmt interfaces
[yangtools.git] / common / util / src / test / java / org / opendaylight / yangtools / util / EvenMoreObjectsTest.java
1 /*
2  * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.util;
9
10 import static org.junit.Assert.assertTrue;
11
12 import com.google.common.base.MoreObjects;
13 import com.google.common.testing.EqualsTester;
14 import java.util.Objects;
15 import org.junit.Test;
16
17 @Deprecated(since = "11.0.0", forRemoval = true)
18 public class EvenMoreObjectsTest {
19
20     @Test
21     public void thingPassesEqualsTester() {
22         new EqualsTester()
23                 .addEqualityGroup(new Thing("hello", 123), new Thing("hello", 123))
24                 .addEqualityGroup(new Thing("hoi", 123), new Thing("hoi", 123))
25                 .addEqualityGroup(new Thing("hoi", null))
26                 .addEqualityGroup(new Thing(null, null))
27                 .testEquals();
28     }
29
30     @Test
31     public void nullEqualsNull() {
32         assertTrue(EvenMoreObjects.equalsHelper(null, null, (one, another) -> Boolean.TRUE));
33     }
34
35     private static class Thing {
36         String name;
37         Integer age;
38
39         @Override
40         public boolean equals(final Object obj) {
41             return EvenMoreObjects.equalsHelper(this, obj,
42                 (one, another) -> Objects.equals(one.name, another.name) && Objects.equals(one.age, another.age));
43         }
44
45         @Override
46         public int hashCode() {
47             return Objects.hash(name, age);
48         }
49
50         @Override
51         public String toString() {
52             return MoreObjects.toStringHelper(this).add("name", name).add("age", age).toString();
53         }
54
55         Thing(final String name, final Integer age) {
56             this.name = name;
57             this.age = age;
58         }
59     }
60 }