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.binding.generator.util.generated.type.builder;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertTrue;
14 import org.junit.Test;
16 public class ConstantImplTest {
19 public void testAllMethods() {
20 final GeneratedTypeBuilderImpl definingType = new GeneratedTypeBuilderImpl("org.opendaylight.yangtools.test",
22 final GeneratedTypeBuilderImpl type = new GeneratedTypeBuilderImpl("org.opendaylight.yangtools.test.v1",
24 final ConstantImpl constImpl = new ConstantImpl(definingType, type, "IpAddress", "127.0.0.1");
25 final ConstantImpl constImpl2 = new ConstantImpl(definingType, type, "IpAddress", "127.0.0.1");
26 final ConstantImpl constImpl3 = new ConstantImpl(definingType, type, "IpAddress", "127.0.0.0");
27 final ConstantImpl constImpl4 = constImpl;
28 final ConstantImpl constImpl5 = new ConstantImpl(definingType, type, null, "127.0.0.0");
29 final ConstantImpl constImpl6 = new ConstantImpl(definingType, type, "IpAddress", null);
31 assertEquals("DefiningType", constImpl.getDefiningType().getName());
32 assertEquals("BaseType", constImpl.getType().getName());
33 assertEquals("IpAddress", constImpl.getName());
34 assertEquals("127.0.0.1", constImpl.getValue());
35 assertTrue(constImpl.toFormattedString().contains("GeneratedTransferObject"));
36 assertTrue(constImpl.toString().contains("GeneratedTransferObject"));
37 assertEquals(constImpl.hashCode(), constImpl2.hashCode());
38 assertFalse(constImpl.equals(null));
39 assertFalse(constImpl.equals("test"));
41 assertTrue(constImpl.equals(constImpl2));
42 assertFalse(constImpl.equals(constImpl3));
43 assertTrue(constImpl.equals(constImpl4));
44 assertFalse(constImpl5.equals(constImpl));
45 assertFalse(constImpl6.equals(constImpl));