2 * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.util;
10 import static org.junit.Assert.assertTrue;
12 import com.google.common.base.MoreObjects;
13 import com.google.common.testing.EqualsTester;
14 import java.util.Objects;
15 import org.junit.Test;
17 public class EvenMoreObjectsTest {
20 public void thingPassesEqualsTester() {
22 .addEqualityGroup(new Thing("hello", 123), new Thing("hello", 123))
23 .addEqualityGroup(new Thing("hoi", 123), new Thing("hoi", 123))
24 .addEqualityGroup(new Thing("hoi", null))
25 .addEqualityGroup(new Thing(null, null))
30 public void nullEqualsNull() {
31 assertTrue(EvenMoreObjects.equalsHelper(null, null, (one, another) -> Boolean.TRUE));
34 private static class Thing {
39 public boolean equals(final Object obj) {
40 return EvenMoreObjects.equalsHelper(this, obj,
41 (one, another) -> Objects.equals(one.name, another.name) && Objects.equals(one.age, another.age));
45 public int hashCode() {
46 return Objects.hash(name, age);
50 public String toString() {
51 return MoreObjects.toStringHelper(this).add("name", name).add("age", age).toString();
54 Thing(final String name, final Integer age) {