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.mdsal.binding.model.util.generated.type.builder;
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.assertTrue;
15 import org.junit.Test;
16 import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
18 public class ConstantImplTest {
20 public void testMethodsOfConstantImpl() {
21 final CodegenGeneratedTypeBuilder type = new CodegenGeneratedTypeBuilder(
22 JavaTypeName.create("org.opendaylight.yangtools.test.v1", "BaseType"));
23 final ConstantImpl constImpl = new ConstantImpl(type, "IpAddress", "127.0.0.1");
24 final ConstantImpl constImpl2 = new ConstantImpl(type, "IpAddress", "127.0.0.1");
25 final ConstantImpl constImpl3 = new ConstantImpl(type, "IpAddress", "127.0.0.0");
26 final ConstantImpl constImpl4 = constImpl;
27 final ConstantImpl constImpl5 = new ConstantImpl(type, null, "127.0.0.0");
28 final ConstantImpl constImpl6 = new ConstantImpl(type, "IpAddress", null);
30 assertEquals("BaseType", constImpl.getType().getName());
31 assertEquals("IpAddress", constImpl.getName());
32 assertEquals("127.0.0.1", constImpl.getValue());
34 "Constant [type=CodegenGeneratedTypeBuilder{identifier=org.opendaylight.yangtools.test.v1.BaseType, "
35 + "constants=[], enumerations=[], methods=[], annotations=[], implements=[]}, name=IpAddress, "
36 + "value=127.0.0.1]", constImpl.toString());
37 assertEquals(constImpl.hashCode(), constImpl2.hashCode());
38 assertNotNull(constImpl.getType());
39 assertNotNull(constImpl.getName());
40 assertNotNull(constImpl.getValue());
41 assertNotNull(constImpl.hashCode());
42 assertFalse(constImpl.equals(null));
43 assertFalse(constImpl.equals("test"));
45 assertTrue(constImpl.equals(constImpl2));
46 assertFalse(constImpl.equals(constImpl3));
47 assertTrue(constImpl.equals(constImpl4));
48 assertFalse(constImpl5.equals(constImpl));
49 assertFalse(constImpl6.equals(constImpl));