2 * Copyright (c) 2014 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.yangtools.yang.model.util;
10 import static org.junit.Assert.*;
12 import java.util.Date;
14 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
15 import org.junit.Before;
16 import org.junit.Test;
18 public class ModuleImportImplTest {
20 private ModuleImport module1, module2, module3, module4, module5;
21 private int hash1, hash2;
27 module1 = new ModuleImportImpl("myModule", now, "myPrefix");
28 module2 = new ModuleImportImpl(null, null, null);
29 module3 = new ModuleImportImpl("myModule", null, "customPrefix");
30 module4 = new ModuleImportImpl("myModule", now, null);
31 module5 = new ModuleImportImpl("myModule", now, "myPrefix");
32 hash1 = module1.hashCode();
33 hash2 = module2.hashCode();
37 public void testModule() {
38 assertNotNull(module1);
39 assertTrue(module1.getModuleName().equals("myModule"));
40 assertTrue(module1.getPrefix().equals("myPrefix"));
41 assertTrue(module1.getRevision().equals(now));
42 assertFalse(module1.equals(module2));
46 public void testToString() {
47 String toString = module1.toString();
48 assertTrue(toString.contains("ModuleImport"));
52 public void testHashCode() {
53 assertTrue(!(hash1 == hash2));
57 public void testEquals() {
58 assertTrue(module1.equals(module1));
59 assertFalse(module1.equals(module2));
60 assertFalse(module1.equals(""));
61 assertFalse(module2.equals(module1));
62 assertFalse(module1.equals(null));
63 assertFalse(module1.equals(module3));
64 assertFalse(module3.equals(module1));
65 assertFalse(module1.equals(module4));
66 assertFalse(module4.equals(module1));
67 assertTrue(module1.equals(module5));