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 org.junit.Test;
16 import org.opendaylight.yangtools.concepts.Path;
18 public class GenericEntityTest {
21 public void basicTest() throws Exception {
22 final TestClass testClass = new TestClass();
23 final GenericEntity genericEntity = new GenericEntity<>("testType", testClass);
24 final GenericEntity genericEntityDiff = new GenericEntity<>("differentTestType", new TestClassDiff());
26 assertEquals(TestClass.class, genericEntity.getIdentifier().getClass());
27 assertEquals("testType", genericEntity.getType());
28 assertTrue(genericEntity.toString().contains("testType"));
29 assertNotEquals(genericEntity.hashCode(), genericEntityDiff.hashCode());
30 assertTrue(genericEntity.equals(genericEntity));
31 assertTrue(genericEntity.equals(new GenericEntity<>("testType", testClass)));
32 assertFalse(genericEntity.equals(genericEntityDiff));
33 assertFalse(genericEntity.equals(""));
34 assertFalse(genericEntity.equals(new GenericEntity<>("differentTestType", testClass)));
37 private final class TestClass implements Path {
39 public boolean contains(final Path other) {
44 private final class TestClassDiff implements Path {
46 public boolean contains(final Path other) {