Rename package in EosCommonApi
[mdsal.git] / entityownership / mdsal-eos-common-api / src / test / java / org / opendaylight / mdsal / eos / common / api / GenericEntityTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, 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.mdsal.eos.common.api;
9
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;
14
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;
19
20 public class GenericEntityTest {
21
22     @Test
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());
27
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)));
37     }
38
39     private final class TestClass implements Path {
40         @Override
41         public boolean contains(@Nonnull Path other) {
42             return false;
43         }
44     }
45
46     private final class TestClassDiff implements Path {
47         @Override
48         public boolean contains(@Nonnull Path other) {
49             return false;
50         }
51     }
52 }