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.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertNull;
14 import static org.junit.Assert.assertTrue;
16 import java.sql.Types;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
20 import org.opendaylight.yangtools.yang.model.api.Status;
22 public class StringTypeTest {
24 private StringType string;
29 string = StringType.getInstance();
30 hash = string.hashCode();
34 public void testGetBaseTypeShouldReturnNull() {
35 assertTrue(string.getBaseType() == null);
39 public void testGetters() {
40 assertEquals(string.getUnits(), "");
41 assertNull(string.getDefaultValue());
42 assertEquals(string.getDescription(), "");
43 assertEquals(string.getReference(), "");
44 assertEquals(string.getQName(), BaseTypes.STRING_QNAME);
45 assertEquals(string.getStatus(), Status.CURRENT);
47 SchemaPath path = SchemaPath.create(true, string.getQName());
48 assertEquals(string.getPath(), path);
50 assertNotNull(string.getLengthConstraints());
51 assertNotNull(string.getPatternConstraints());
52 assertNotNull(string.getUnknownSchemaNodes());
56 public void testToString() {
57 String toString = string.toString();
58 assertTrue(toString.contains("StringType"));
62 public void testEquals() {
63 assertTrue(string.equals(string));
64 assertFalse(string.equals(null));
65 assertFalse(string.equals(Types.DOUBLE));