Bug 584: Increate test coverage in binding-generator-util 76/11476/3
authorLadislav Borak <lborak@cisco.com>
Tue, 23 Sep 2014 06:30:26 +0000 (08:30 +0200)
committerLadislav Borak <lborak@cisco.com>
Mon, 27 Oct 2014 14:48:02 +0000 (15:48 +0100)
Change-Id: I3b6d4b5d579b77b89fc6acf058c5bce277609027
Signed-off-by: Ladislav Borak <lborak@cisco.com>
code-generator/binding-generator-util/src/test/java/org/opendaylight/yangtools/binding/generator/util/AbstractBaseTypeTest.java
code-generator/binding-generator-util/src/test/java/org/opendaylight/yangtools/binding/generator/util/BindingGeneratorUtilTest.java
code-generator/binding-generator-util/src/test/java/org/opendaylight/yangtools/binding/generator/util/BindingTypesTest.java
code-generator/binding-generator-util/src/test/java/org/opendaylight/yangtools/binding/generator/util/TypesTest.java
code-generator/binding-generator-util/src/test/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractTypeMemberTest.java
code-generator/binding-generator-util/src/test/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AnnotationBuilderTest.java
code-generator/binding-generator-util/src/test/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/ConstantImplTest.java
code-generator/binding-generator-util/src/test/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/EnumerationBuilderImplTest.java
code-generator/binding-generator-util/src/test/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedTypeBuilderTest.java
code-generator/binding-generator-util/src/test/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/MethodParameterImplTest.java

index 044adce194d02966d97370acf8ffffe8f67282d2..ef8204191cc80ddd5aed33037dd97357cc53fbb2 100644 (file)
@@ -30,14 +30,14 @@ public class AbstractBaseTypeTest {
     public void testCreateAbstractBaseTypeWithNullPackagename() {
         expException.expect(IllegalArgumentException.class);
         expException.expectMessage("Package Name for Generated Type cannot be null!");
-        AbstractBaseType baseTypeNullpackagename = new AbstractBaseType(null, "Test");
+        new AbstractBaseType(null, "Test");
     }
 
     @Test
     public void testCreateAbstractBaseTypeWithNullTypeName() {
         expException.expect(IllegalArgumentException.class);
         expException.expectMessage("Name of Generated Type cannot be null!");
-        AbstractBaseType baseTypeNullTypeName = new AbstractBaseType("org.opendaylight.yangtools.test", null);
+        new AbstractBaseType("org.opendaylight.yangtools.test", null);
     }
 
     @Test
index 413856eb65493b61125a4bd1f225aadf869dd23a..91e93ed1b8f7407de49d9647c57024e1bd9d1392 100644 (file)
@@ -7,8 +7,14 @@
  */
 package org.opendaylight.yangtools.binding.generator.util;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
+import com.google.common.base.Optional;
 import java.io.File;
 import java.io.IOException;
 import java.io.Serializable;
@@ -17,13 +23,13 @@ import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
-
-import com.google.common.base.Optional;
-
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.GeneratedTypeBuilderImpl;
 import org.opendaylight.yangtools.sal.binding.model.api.AccessModifier;
 import org.opendaylight.yangtools.sal.binding.model.api.Restrictions;
+import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTypeBuilder;
 import org.opendaylight.yangtools.sal.binding.model.api.type.builder.MethodSignatureBuilder;
 import org.opendaylight.yangtools.yang.binding.BindingMapping;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -51,6 +57,9 @@ import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 public class BindingGeneratorUtilTest {
 
+    @Rule
+    public ExpectedException expectedEx = ExpectedException.none();
+
     private static List<File> loadTestResources(String testFile) {
         final List<File> testModels = new ArrayList<File>();
         File listModelFile;
@@ -110,9 +119,12 @@ public class BindingGeneratorUtilTest {
         // test of the method packageNameForTypeDefinition
         Set<TypeDefinition<?>> typeDefinitions = module.getTypeDefinitions();
         String subPackageNameForTypeDefinition = "";
+        TypeDefinition<?> firstTypeDef = null;
+
         for (TypeDefinition<?> tpDef : typeDefinitions) {
             if (tpDef.getQName().getLocalName().equals("tpdf")) {
                 subPackageNameForTypeDefinition = BindingGeneratorUtil.packageNameForTypeDefinition(packageName, tpDef);
+                firstTypeDef = tpDef;
                 break;
             }
         }
@@ -120,6 +132,24 @@ public class BindingGeneratorUtilTest {
                 "org.opendaylight.yang.gen.v1.urn.m.o.d.u.l.e.n.a.m.e.t.e.s.t._case._1digit.rev130910",
                 subPackageNameForTypeDefinition);
 
+        // test method getRestrictions
+        Restrictions restriction = BindingGeneratorUtil.getRestrictions(firstTypeDef);
+        assertNotNull(restriction);
+
+        // test method computeDefaultSUID
+        GeneratedTypeBuilder genTypeBuilder = new GeneratedTypeBuilderImpl("org.opendaylight.yangtools.test", "TestType");
+        genTypeBuilder.addMethod("testMethod");
+        genTypeBuilder.addAnnotation("org.opendaylight.yangtools.test.annotation", "AnnotationTest");
+        genTypeBuilder.addEnclosingTransferObject("testObject");
+        genTypeBuilder.addProperty("newProp");
+        GeneratedTypeBuilder genType = new GeneratedTypeBuilderImpl("org.opendaylight.yangtools.test", "Type2");
+        genTypeBuilder.addImplementsType(genType);
+        long computedSUID = BindingGeneratorUtil.computeDefaultSUID(genTypeBuilder);
+
+        GeneratedTypeBuilder genTypeBuilder2 = new GeneratedTypeBuilderImpl("org.opendaylight.yangtools.test2", "TestType2");
+        long computedSUID2 = BindingGeneratorUtil.computeDefaultSUID(genTypeBuilder2);
+        assertNotEquals(computedSUID, computedSUID2);
+
         // test of exception part of the method moduleNamespaceToPackageName()
         ModuleBuilder moduleBuilder = new ModuleBuilder("module-withut-revision", null);
         moduleBuilder.setSource("");
@@ -134,6 +164,96 @@ public class BindingGeneratorUtilTest {
 
     }
 
+    /**
+     * Test for the method
+     * <ul>
+     * <li>{@link BindingGeneratorUtil#packageNameForTypeDefinition()
+     * packageNameForTypeDefinition()}</li>
+     * </ul>
+     */
+    @Test
+    public void testPackageNameForTypeDefinitionNullBasePackageName() {
+        expectedEx.expect(IllegalArgumentException.class);
+        expectedEx.expectMessage("Base Package Name cannot be NULL!");
+        BindingGeneratorUtil.packageNameForTypeDefinition(null, null);
+    }
+
+    /**
+     * Test for the method
+     * <ul>
+     * <li>{@link BindingGeneratorUtil#packageNameForTypeDefinition()
+     * packageNameForTypeDefinition()}</li>
+     * </ul>
+     */
+    @Test
+    public void testPackageNameForTypeDefinitionNullTypeDefinition() {
+        expectedEx.expect(IllegalArgumentException.class);
+        expectedEx.expectMessage("Type Definition reference cannot be NULL!");
+        BindingGeneratorUtil.packageNameForTypeDefinition("test.package", null);
+    }
+
+    /**
+     * Test for the method
+     * <ul>
+     * <li>{@link BindingGeneratorUtil#packageNameForGeneratedType()
+     * packageNameForGeneratedType()}</li>
+     * </ul>
+     */
+    @Test
+    public void testPackageNameForGeneratedTypeNullBasePackageName() {
+        expectedEx.expect(IllegalArgumentException.class);
+        expectedEx.expectMessage("Base Package Name cannot be NULL!");
+        BindingGeneratorUtil.packageNameForGeneratedType(null, null);
+    }
+
+    /**
+     * Test for the method
+     * <ul>
+     * <li>{@link BindingGeneratorUtil#packageNameForGeneratedType()
+     * packageNameForGeneratedType()}</li>
+     * </ul>
+     */
+    @Test
+    public void testPackageNameForGeneratedTypeNullSchemaPath() {
+        expectedEx.expect(IllegalArgumentException.class);
+        expectedEx.expectMessage("Schema Path cannot be NULL!");
+        BindingGeneratorUtil.packageNameForGeneratedType("test.package", null);
+    }
+
+    /**
+     * Test for the method
+     * <ul>
+     * <li>{@link BindingGeneratorUtil#parseToClassName()
+     * parseToClassName()}</li>
+     * </ul>
+     */
+    @Test
+    public void testParseToClassNameNullValue() {
+        String className = BindingGeneratorUtil.parseToClassName("test-class-name");
+        assertEquals("TestClassName", className);
+
+        expectedEx.expect(IllegalArgumentException.class);
+        expectedEx.expectMessage("Name can not be null");
+        className = BindingGeneratorUtil.parseToClassName(null);
+    }
+
+    /**
+     * Test for the method
+     * <ul>
+     * <li>{@link BindingGeneratorUtil#parseToClassName()
+     * parseToClassName()}</li>
+     * </ul>
+     */
+    @Test
+    public void testParseToClassNameEmptyValue() {
+        String className = BindingGeneratorUtil.parseToClassName("test-class-name");
+        assertEquals("TestClassName", className);
+
+        expectedEx.expect(IllegalArgumentException.class);
+        expectedEx.expectMessage("Name can not be empty");
+        className = BindingGeneratorUtil.parseToClassName("");
+    }
+
     /**
      * Test for the method
      * <ul>
index a2518e703d9a113c9d8d3e7a51dcb3447306bb64..3ebcf4e3f250a979396e816f12ed06733d890bd4 100644 (file)
@@ -7,12 +7,24 @@
  */
 package org.opendaylight.yangtools.binding.generator.util;
 
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.binding.*;
-
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.opendaylight.yangtools.binding.generator.util.Types.typeForClass;
 
+import org.junit.Test;
+import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;
+import org.opendaylight.yangtools.yang.binding.Augmentable;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.DataRoot;
+import org.opendaylight.yangtools.yang.binding.Identifiable;
+import org.opendaylight.yangtools.yang.binding.Identifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.Notification;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
 public class BindingTypesTest {
 
     @Test
@@ -29,4 +41,16 @@ public class BindingTypesTest {
         assertEquals("NOTIFICATION_LISTENER", typeForClass(NotificationListener.class), BindingTypes.NOTIFICATION_LISTENER);
         assertEquals("RPC_SERVICE", typeForClass(RpcService.class), BindingTypes.RPC_SERVICE);
     }
+
+    @Test
+    public void testAugmentable() {
+        ParameterizedType augmentType = BindingTypes.augmentable(null);
+        assertNotNull(augmentType);
+    }
+
+    @Test
+    public void testChildOf() {
+        ParameterizedType childOfType = BindingTypes.childOf(null);
+        assertNotNull(childOfType);
+    }
 }
\ No newline at end of file
index 0da84d8777723de19f8f8fc077b139ad06d7243f..5595e23ccf0ac4b276afcaeaf9b2b50ec69749f5 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.binding.generator.util;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 import org.junit.Test;
 import org.opendaylight.yangtools.sal.binding.model.api.ConcreteType;
@@ -21,36 +22,42 @@ public class TypesTest {
     public void testVoidType() {
         final ConcreteType voidType = Types.voidType();
         assertEquals("Void", voidType.getName());
+        assertNotNull(voidType);
     }
 
     @Test
     public void testPrimitiveType() {
         final Type primitiveType = Types.primitiveType("newType", null);
         assertEquals("newType", primitiveType.getName());
+        assertNotNull(primitiveType);
     }
 
     @Test
     public void testMapTypeFor() {
         final ParameterizedType mapType = Types.mapTypeFor(null, null);
         assertEquals("Map", mapType.getName());
+        assertNotNull(mapType);
     }
 
     @Test
     public void testSetTypeFor() {
         final ParameterizedType setType = Types.setTypeFor(null);
         assertEquals("Set", setType.getName());
+        assertNotNull(setType);
     }
 
     @Test
     public void testListTypeFor() {
         final ParameterizedType listType = Types.listTypeFor(null);
         assertEquals("List", listType.getName());
+        assertNotNull(listType);
     }
 
     @Test
     public void testWildcardTypeFor() {
         final WildcardType wildcardType = Types.wildcardTypeFor("org.opendaylight.yangtools.test", "WildcardTypeTest");
         assertEquals("WildcardTypeTest", wildcardType.getName());
+        assertNotNull(wildcardType);
     }
 
     @Test
index 41d516fcad3432085d1cc9fbe0d2a6c3923861bb..88f03ff5a86a45ec3dbeeb43e0885961bf1d7e2f 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.yangtools.binding.generator.util.generated.type.builder
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
@@ -31,8 +32,8 @@ public class AbstractTypeMemberTest {
         assertTrue(genProperty.isFinal());
         assertTrue(genProperty.isStatic());
         assertEquals(genProperty.hashCode(), genProperty2.hashCode());
-        String pom = genProperty.toString();
         assertTrue(genProperty.toString().contains("org.opendaylight.yangtools.test.TestType"));
+        assertNotNull(genProperty.toString());
         assertTrue(genProperty.equals(genProperty2));
         assertFalse(genProperty.equals(null));
 
index d8668dd50cf74b14e3567ec967809dcaacbb9cbf..6e9e85af52e115924bb80e711ef3031b42d88c50 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -7,11 +7,14 @@
  */
 package org.opendaylight.yangtools.binding.generator.util.generated.type.builder;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
 import java.util.List;
-
 import org.junit.Test;
 import org.opendaylight.yangtools.binding.generator.util.Types;
 import org.opendaylight.yangtools.sal.binding.model.api.AnnotationType;
@@ -403,4 +406,113 @@ public class AnnotationBuilderTest {
 
     }
 
+    public void testAddAnnotation() {
+        final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl("org.opedaylight.yangtools.test", "AnnotationTest");
+        annotBuilderImpl.addAnnotation("org.opedaylight.yangtools.test.v1", "AnnotationTest2");
+        annotBuilderImpl.addAnnotation(null, "AnnotationTest2");
+        assertFalse(annotBuilderImpl.toInstance().getAnnotations().isEmpty());
+    }
+
+    @Test
+    public void testAddParameterMethod() {
+        final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl("org.opedaylight.yangtools.test", "AnnotationTest");
+        annotBuilderImpl.addParameter("testParam", "test value");
+        annotBuilderImpl.addParameter(null, "test value");
+        final AnnotationType annotType = annotBuilderImpl.toInstance();
+        assertEquals(1, annotType.getParameters().size());
+    }
+
+    @Test
+    public void testAddParametersMethod() {
+        final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl("org.opedaylight.yangtools.test", "AnnotationTest");
+
+        final List<String> values = new ArrayList<>();
+        values.add("test1");
+        values.add("test2");
+        values.add("test3");
+        annotBuilderImpl.addParameters("testParam", values);
+
+        AnnotationType annotType = annotBuilderImpl.toInstance();
+        assertEquals(1, annotType.getParameters().size());
+
+        annotBuilderImpl.addParameters("testParam", null);
+
+        annotType = annotBuilderImpl.toInstance();
+        assertEquals(1, annotType.getParameters().size());
+    }
+
+    @Test
+    public void testHashCode() {
+        final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl("org.opedaylight.yangtools.test", "AnnotationTest");
+        final AnnotationTypeBuilderImpl annotBuilderImpl2 = new AnnotationTypeBuilderImpl("org.opedaylight.yangtools.test", "AnnotationTest2");
+        assertFalse(annotBuilderImpl.hashCode() == annotBuilderImpl2.hashCode());
+    }
+
+    @Test
+    public void testEquals() {
+        final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl("org.opedaylight.yangtools.test", "AnnotationTest");
+        final AnnotationTypeBuilderImpl annotBuilderImpl2 = new AnnotationTypeBuilderImpl("org.opedaylight.yangtools.test", "AnnotationTest");
+        final AnnotationTypeBuilderImpl annotBuilderImpl3 = annotBuilderImpl2;
+
+        assertTrue(annotBuilderImpl.equals(annotBuilderImpl2));
+        assertTrue(annotBuilderImpl2.equals(annotBuilderImpl3));
+        assertFalse(annotBuilderImpl2.equals(null));
+        assertFalse(annotBuilderImpl2.equals("test"));
+    }
+
+    @Test
+    public void testToString() {
+        final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl("org.opedaylight.yangtools.test", "AnnotationTest");
+        assertNotNull(annotBuilderImpl.toString());
+    }
+
+    @Test
+    public void testMethodsForAnnotationTypeImpl() {
+        final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl("org.opedaylight.yangtools.test", "AnnotationTest");
+        annotBuilderImpl.addParameter("testParam", "test value");
+        final AnnotationType annotationType = annotBuilderImpl.toInstance();
+
+        final AnnotationTypeBuilderImpl annotBuilderImpl2 = new AnnotationTypeBuilderImpl("org.opedaylight.yangtools.test", "AnnotationTest");
+        final AnnotationType annotationType2 = annotBuilderImpl2.toInstance();
+
+        assertTrue(annotationType.containsParameters());
+        assertTrue(annotationType.getAnnotations().isEmpty());
+        assertNotNull(annotationType.getFullyQualifiedName());
+        assertNotNull(annotationType.getName());
+        assertNotNull(annotationType.getPackageName());
+        assertNull(annotationType.getParameter(null));
+        assertNotNull(annotationType.getParameter("testParam"));
+        assertFalse(annotationType.getParameterNames().isEmpty());
+        assertFalse(annotationType.getParameters().isEmpty());
+
+        assertTrue(annotationType.hashCode() == annotationType2.hashCode());
+        assertTrue(annotationType.equals(annotationType2));
+        assertNotNull(annotationType.toString());
+    }
+
+    @Test
+    public void testMethodsForParameterImpl() {
+        final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl("org.opedaylight.yangtools.test", "AnnotationTest");
+        annotBuilderImpl.addParameter("testParam", "test value");
+        annotBuilderImpl.addParameter("testParam", "test value");
+        annotBuilderImpl.addParameter("", "test value");
+        annotBuilderImpl.addParameter(null, "test value");
+        annotBuilderImpl.addParameter("", null);
+        final AnnotationType annotationType = annotBuilderImpl.toInstance();
+
+        final Parameter testParam = annotationType.getParameter("testParam");
+        assertEquals("testParam", testParam.getName());
+        assertEquals("test value", testParam.getValue());
+        assertEquals(0, testParam.getValues().size());
+
+        final List<Parameter> testParams = annotationType.getParameters();
+        final Parameter sameParam = testParams.get(0);
+
+        assertFalse(testParams.get(0).equals(testParams.get(1)));
+        assertFalse(testParams.get(0).equals(null));
+        assertFalse(testParams.get(0).equals("test"));
+        assertTrue(testParams.get(0).equals(sameParam));
+        assertFalse(testParams.get(0).hashCode() == testParams.get(1).hashCode());
+        assertTrue(testParams.get(0).hashCode() == testParams.get(0).hashCode());
+    }
 }
index 7a025c1c8882704dd1a926bbfc2877853a3d29de..b545cc30677aa25aa5ab1e817f68777aebb91c62 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.yangtools.binding.generator.util.generated.type.builder
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
@@ -16,7 +17,7 @@ import org.junit.Test;
 public class ConstantImplTest {
 
     @Test
-    public void testAllMethods() {
+    public void testMethodsOfConstantImpl() {
         final GeneratedTypeBuilderImpl definingType = new GeneratedTypeBuilderImpl("org.opendaylight.yangtools.test",
                 "DefiningType");
         final GeneratedTypeBuilderImpl type = new GeneratedTypeBuilderImpl("org.opendaylight.yangtools.test.v1",
@@ -35,6 +36,13 @@ public class ConstantImplTest {
         assertTrue(constImpl.toFormattedString().contains("GeneratedTransferObject"));
         assertTrue(constImpl.toString().contains("GeneratedTransferObject"));
         assertEquals(constImpl.hashCode(), constImpl2.hashCode());
+        assertNotNull(constImpl.getDefiningType());
+        assertNotNull(constImpl.getType());
+        assertNotNull(constImpl.getName());
+        assertNotNull(constImpl.getValue());
+        assertNotNull(constImpl.toFormattedString());
+        assertNotNull(constImpl.toString());
+        assertNotNull(constImpl.hashCode());
         assertFalse(constImpl.equals(null));
         assertFalse(constImpl.equals("test"));
 
index bddfd421013626ceb27f4016c30a47cf67b73443..f866ad8e347b14e56b5694374f9203e649ed2850 100644 (file)
@@ -7,7 +7,16 @@
  */
 package org.opendaylight.yangtools.binding.generator.util.generated.type.builder;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
 import com.google.common.base.Optional;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.sal.binding.model.api.Enumeration;
@@ -18,16 +27,6 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.EnumerationType;
 
-import java.util.Collections;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
 public class EnumerationBuilderImplTest {
 
     private EnumerationBuilderImpl enumerationBuilder;
@@ -41,9 +40,9 @@ public class EnumerationBuilderImplTest {
     private final String reference = "TestRef";
     private final String valueName = "TestValue";
     private final String valueDescription = "Value used for test";
-    private int value = 12;
+    private final int value = 12;
     private Enumeration enumeration;
-    private QName  qName = QName.create("TestQName", "10-10-2014", "TestLocalQName");
+    private final QName  qName = QName.create("TestQName", "10-10-2014", "TestLocalQName");
 
 
     @Before
@@ -153,14 +152,14 @@ public class EnumerationBuilderImplTest {
      * Internal implementation of EnumPair.
      */
     private static class EnumPairImpl implements EnumTypeDefinition.EnumPair {
-        private QName qname;
-        private SchemaPath path;
-        private String description;
-        private String reference;
-        private Status status;
+        private final QName qname;
+        private final SchemaPath path;
+        private final String description;
+        private final String reference;
+        private final Status status;
         private final List<UnknownSchemaNode> unknownNodes = Collections.emptyList();
-        private String name;
-        private Integer value;
+        private final String name;
+        private final Integer value;
 
         private EnumPairImpl(QName qName) {
             qname = qName;
@@ -283,4 +282,4 @@ public class EnumerationBuilderImplTest {
             return EnumTypeDefinition.EnumPair.class.getSimpleName() + "[name=" + name + ", value=" + value + "]";
         }
     }
-}
\ No newline at end of file
+}
index 36e329c9511d581d793b436bf458db8673d2e9cc..98139dbffbfbe4cfba4ca75f0bc97e981ba768ac 100644 (file)
@@ -1,13 +1,19 @@
-/**
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 package org.opendaylight.yangtools.binding.generator.util.generated.type.builder;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.Serializable;
 import java.util.List;
-
 import org.junit.Test;
 import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil;
 import org.opendaylight.yangtools.binding.generator.util.Types;
@@ -95,15 +101,13 @@ public class GeneratedTypeBuilderTest {
     @Test(expected = IllegalArgumentException.class)
     public void addConstantIllegalArgumentTest() {
         GeneratedTypeBuilder generatedTypeBuilder = new GeneratedTypeBuilderImpl("my.package", "MyName");
-
-        Constant constant = generatedTypeBuilder.addConstant(Types.typeForClass(String.class), null, "myConstantValue");
+        generatedTypeBuilder.addConstant(Types.typeForClass(String.class), null, "myConstantValue");
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void addConstantIllegalArgumentTest2() {
         GeneratedTypeBuilder generatedTypeBuilder = new GeneratedTypeBuilderImpl("my.package", "MyName");
-
-        Constant constant = generatedTypeBuilder.addConstant(null, "myConstantName", "myConstantValue");
+        generatedTypeBuilder.addConstant(null, "myConstantName", "myConstantValue");
     }
 
     @Test
@@ -157,7 +161,6 @@ public class GeneratedTypeBuilderTest {
     @Test(expected = IllegalArgumentException.class)
     public void addMethodIllegalArgumentTest() {
         GeneratedTypeBuilderImpl generatedTypeBuilder = new GeneratedTypeBuilderImpl("my.package", "MyName");
-
         generatedTypeBuilder.addMethod(null);
     }
 
@@ -302,5 +305,4 @@ public class GeneratedTypeBuilderTest {
         assertEquals(SchemaPath.create(true, QName.create("/path")).getPathFromRoot(), instance.getSchemaPath());
         assertEquals("My comment..", instance.getComment());
     }
-
 }