2 * Copyright (c) 2016 Cisco Systems, 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.mdsal.eos.common.api;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertNotEquals;
13 import static org.junit.Assert.assertTrue;
15 import javax.annotation.Nonnull;
16 import org.junit.Test;
17 import org.opendaylight.mdsal.eos.common.api.GenericEntity;
18 import org.opendaylight.yangtools.concepts.Path;
20 public class GenericEntityTest {
23 public void basicTest() throws Exception {
24 final TestClass testClass = new TestClass();
25 final GenericEntity genericEntity = new GenericEntity<>("testType", testClass);
26 final GenericEntity genericEntityDiff = new GenericEntity<>("differentTestType", new TestClassDiff());
28 assertEquals(TestClass.class, genericEntity.getIdentifier().getClass());
29 assertEquals("testType", genericEntity.getType());
30 assertTrue(genericEntity.toString().contains("testType"));
31 assertNotEquals(genericEntity.hashCode(), genericEntityDiff.hashCode());
32 assertTrue(genericEntity.equals(genericEntity));
33 assertTrue(genericEntity.equals(new GenericEntity<>("testType", testClass)));
34 assertFalse(genericEntity.equals(genericEntityDiff));
35 assertFalse(genericEntity.equals(new String()));
36 assertFalse(genericEntity.equals(new GenericEntity<>("differentTestType", testClass)));
39 private final class TestClass implements Path {
41 public boolean contains(@Nonnull Path other) {
46 private final class TestClassDiff implements Path {
48 public boolean contains(@Nonnull Path other) {