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.stmt.retest;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertTrue;
14 import com.google.common.base.Optional;
16 import java.net.URISyntaxException;
17 import java.util.Date;
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
21 import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleIdentifierImpl;
23 public class ModuleIdentifierTest {
25 private ModuleIdentifier moduleIdentifier;
26 private ModuleIdentifier moduleIdentifier2;
27 private ModuleIdentifier moduleIdentifier3;
28 private ModuleIdentifier moduleIdentifier4;
29 private ModuleIdentifier moduleIdentifier5;
32 public void init() throws URISyntaxException {
33 Optional<URI> uri = Optional.of(new URI("testURI"));
34 Optional<URI> uri2 = Optional.of(new URI("testURI2"));
35 Optional<Date> revision = Optional.absent();
36 moduleIdentifier = new ModuleIdentifierImpl("test-modulue", uri, revision);
37 moduleIdentifier2 = new ModuleIdentifierImpl("test-modulue2", uri, revision);
38 moduleIdentifier3 = moduleIdentifier;
39 moduleIdentifier4 = new ModuleIdentifierImpl("test-modulue", uri2, revision);
40 moduleIdentifier5 = new ModuleIdentifierImpl("test-modulue", uri, revision);
44 public void testGetQNameModule() {
45 assertEquals(null, moduleIdentifier.getQNameModule().getRevision());
49 public void testGetRevision() {
50 assertEquals(null, moduleIdentifier.getRevision());
54 public void testGetName() {
55 assertEquals("test-modulue", moduleIdentifier.getName());
59 public void getNamespace() throws URISyntaxException {
60 assertEquals(new URI("testURI"), moduleIdentifier.getNamespace());
64 public void toStringTest() {
65 assertTrue(moduleIdentifier.toString().contains("ModuleIdentifier"));
69 public void testHashCode() {
70 assertFalse(moduleIdentifier.hashCode() == moduleIdentifier2.hashCode());
74 public void testEquals() {
75 assertTrue(moduleIdentifier.equals(moduleIdentifier3));
76 assertFalse(moduleIdentifier.equals(null));
77 assertFalse(moduleIdentifier.equals("test"));
78 assertFalse(moduleIdentifier.equals(moduleIdentifier2));
79 assertFalse(moduleIdentifier.equals(moduleIdentifier4));
80 assertTrue(moduleIdentifier.equals(moduleIdentifier5));