X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fsal%2Fyang-prototype%2Fcode-generator%2Fbinding-generator-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Fgenerator%2Fimpl%2FAnnotationBuilderTest.java;fp=opendaylight%2Fsal%2Fyang-prototype%2Fcode-generator%2Fbinding-generator-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Fgenerator%2Fimpl%2FAnnotationBuilderTest.java;h=0000000000000000000000000000000000000000;hb=7ca1c91122b68d3d7c3ef403114cf4af95174230;hp=f08b77ff7b368b186b5da4f4a1ac51d57f0fd88a;hpb=4221068644c7e8d08880b4d54e2a099a646796b9;p=controller.git diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/AnnotationBuilderTest.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/AnnotationBuilderTest.java deleted file mode 100644 index f08b77ff7b..0000000000 --- a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/AnnotationBuilderTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2013 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.controller.sal.binding.generator.impl; - -import static org.junit.Assert.assertEquals; -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.controller.sal.binding.model.api.AnnotationType; -import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject; -import org.opendaylight.controller.sal.binding.model.api.GeneratedType; -import org.opendaylight.controller.sal.binding.model.api.type.builder.AnnotationTypeBuilder; -import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTOBuilder; -import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTypeBuilder; - -public class AnnotationBuilderTest { - - @Test - public void generatedTypeAnnotationTest() { - GeneratedTypeBuilder genTypeBuilder = new GeneratedTOBuilderImpl( - "org.opendaylight.controller", "AnnotInterface"); - - genTypeBuilder.addAnnotation("javax.management", "MXBean"); - final AnnotationTypeBuilder annotDesc = genTypeBuilder.addAnnotation( - "javax.management", "Description"); - annotDesc.addParameter("description", "some sort of interface"); - - final GeneratedType genType = genTypeBuilder.toInstance(); - - assertNotNull(genType); - assertNotNull(genType.getAnnotations()); - assertEquals(2, genType.getAnnotations().size()); - - int annotCount = 0; - for (final AnnotationType annotation : genType.getAnnotations()) { - if (annotation.getPackageName().equals("javax.management") - && annotation.getName().equals("MXBean")) { - annotCount++; - assertEquals(0, annotation.getParameters().size()); - } - if (annotation.getPackageName().equals("javax.management") - && annotation.getName().equals("Description")) { - annotCount++; - assertEquals(1, annotation.getParameters().size()); - AnnotationType.Parameter param = annotation.getParameter("description"); - assertNotNull(param); - assertEquals("description", param.getName()); - assertNotNull(param.getValue()); - assertEquals("some sort of interface", param.getValue()); - assertNotNull(param.getValues()); - assertTrue(param.getValues().isEmpty()); - } - } - assertEquals(2, annotCount); - } - - @Test - public void methodSignatureAnnotationTest() { - //TODO add test for method annotations - } - - @Test - public void generatedPropertyAnnotationTest() { - //TODO add test for property annotations - } - - @Test - public void generatedTransfeObjectAnnotationTest() { - final GeneratedTOBuilder genTypeBuilder = new GeneratedTOBuilderImpl( - "org.opendaylight.controller", "AnnotClassCache"); - - genTypeBuilder.addAnnotation("javax.management", "MBean"); - final AnnotationTypeBuilder annotNotify = genTypeBuilder.addAnnotation( - "javax.management", "NotificationInfo"); - - final List notifyList = new ArrayList(); - notifyList.add("\"my.notif.type\""); - annotNotify.addParameters("types", notifyList); - annotNotify.addParameter("description", - "@Description(\"my notification\")"); - - GeneratedTransferObject genTO = genTypeBuilder.toInstance(); - - assertNotNull(genTO); - assertNotNull(genTO.getAnnotations()); - assertEquals(2, genTO.getAnnotations().size()); - - int annotCount = 0; - for (final AnnotationType annotation : genTO.getAnnotations()) { - if (annotation.getPackageName().equals("javax.management") - && annotation.getName().equals("MBean")) { - annotCount++; - assertEquals(0, annotation.getParameters().size()); - } - if (annotation.getPackageName().equals("javax.management") - && annotation.getName().equals("NotificationInfo")) { - annotCount++; - assertEquals(2, annotation.getParameters().size()); - AnnotationType.Parameter param = annotation.getParameter("types"); - assertNotNull(param); - assertEquals("types", param.getName()); - assertNull(param.getValue()); - assertNotNull(param.getValues()); - assertEquals(1, param.getValues().size()); - assertEquals("\"my.notif.type\"", param.getValues().get(0)); - - param = annotation.getParameter("description"); - assertNotNull(param); - assertEquals("description", param.getName()); - assertNotNull(param.getValue()); - assertEquals("@Description(\"my notification\")", param.getValue()); - } - } - assertEquals(2, annotCount); - } -}