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.ri.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.assertNull;
14 import static org.junit.Assert.assertSame;
15 import static org.junit.Assert.assertThrows;
16 import static org.junit.Assert.assertTrue;
18 import java.util.ArrayList;
19 import java.util.List;
20 import org.junit.Test;
21 import org.opendaylight.mdsal.binding.model.api.AnnotationType;
22 import org.opendaylight.mdsal.binding.model.api.AnnotationType.Parameter;
23 import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject;
24 import org.opendaylight.mdsal.binding.model.api.GeneratedType;
25 import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
26 import org.opendaylight.mdsal.binding.model.api.type.builder.AnnotationTypeBuilder;
27 import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedPropertyBuilder;
28 import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTOBuilder;
29 import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilder;
30 import org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder;
31 import org.opendaylight.mdsal.binding.model.ri.Types;
33 public class AnnotationBuilderTest {
36 public void generatedTypeAnnotationTest() {
37 final GeneratedTypeBuilder genTypeBuilder = new CodegenGeneratedTypeBuilder(
38 JavaTypeName.create("org.opendaylight.controller", "AnnotInterface"));
40 genTypeBuilder.addAnnotation("javax.management", "MXBean");
41 final AnnotationTypeBuilder annotDesc = genTypeBuilder.addAnnotation("javax.management", "Description");
42 annotDesc.addParameter("description", "some sort of interface");
44 final GeneratedType genType = genTypeBuilder.build();
46 assertNotNull(genType);
47 assertNotNull(genType.getAnnotations());
48 assertEquals(2, genType.getAnnotations().size());
51 for (final AnnotationType annotation : genType.getAnnotations()) {
52 if (annotation.getPackageName().equals("javax.management") && annotation.getName().equals("MXBean")) {
54 assertEquals(0, annotation.getParameters().size());
56 if (annotation.getPackageName().equals("javax.management") && annotation.getName().equals("Description")) {
58 assertEquals(1, annotation.getParameters().size());
59 AnnotationType.Parameter param = annotation.getParameter("description");
61 assertEquals("description", param.getName());
62 assertNotNull(param.getValue());
63 assertEquals("some sort of interface", param.getValue());
64 assertNotNull(param.getValues());
65 assertTrue(param.getValues().isEmpty());
68 assertEquals(2, annotCount);
72 public void methodSignatureAnnotationTest() {
73 final GeneratedTypeBuilder genTypeBuilder = new CodegenGeneratedTypeBuilder(
74 JavaTypeName.create("org.opendaylight.controller", "TransferObject"));
76 final MethodSignatureBuilder methodBuilder = genTypeBuilder.addMethod("simpleMethod");
77 methodBuilder.setReturnType(Types.typeForClass(Integer.class));
78 final AnnotationTypeBuilder annotManAttr = methodBuilder.addAnnotation(
79 "org.springframework.jmx.export.annotation", "ManagedAttribute");
81 annotManAttr.addParameter("description", "\"The Name Attribute\"");
82 annotManAttr.addParameter("currencyTimeLimit", "20");
83 annotManAttr.addParameter("defaultValue", "\"bar\"");
84 annotManAttr.addParameter("persistPolicy", "\"OnUpdate\"");
86 final AnnotationTypeBuilder annotManProp = methodBuilder.addAnnotation(
87 "org.springframework.jmx.export.annotation", "ManagedOperation");
89 final List<String> typeValues = new ArrayList<>();
90 typeValues.add("\"val1\"");
91 typeValues.add("\"val2\"");
92 typeValues.add("\"val3\"");
93 annotManProp.addParameters("types", typeValues);
95 final GeneratedType genType = genTypeBuilder.build();
97 assertNotNull(genType);
98 assertNotNull(genType.getAnnotations());
99 assertNotNull(genType.getMethodDefinitions());
100 assertNotNull(genType.getMethodDefinitions().get(0));
101 assertNotNull(genType.getMethodDefinitions().get(0).getAnnotations());
102 final List<AnnotationType> annotations = genType.getMethodDefinitions().get(0).getAnnotations();
103 assertEquals(2, annotations.size());
106 for (final AnnotationType annotation : annotations) {
107 if (annotation.getPackageName().equals("org.springframework.jmx.export.annotation")
108 && annotation.getName().equals("ManagedAttribute")) {
110 assertEquals(4, annotation.getParameters().size());
112 assertNotNull(annotation.getParameter("description"));
113 assertNotNull(annotation.getParameter("currencyTimeLimit"));
114 assertNotNull(annotation.getParameter("defaultValue"));
115 assertNotNull(annotation.getParameter("persistPolicy"));
116 assertEquals("\"The Name Attribute\"", annotation.getParameter("description").getValue());
117 assertEquals("20", annotation.getParameter("currencyTimeLimit").getValue());
118 assertEquals("\"bar\"", annotation.getParameter("defaultValue").getValue());
119 assertEquals("\"OnUpdate\"", annotation.getParameter("persistPolicy").getValue());
121 if (annotation.getPackageName().equals("org.springframework.jmx.export.annotation")
122 && annotation.getName().equals("ManagedOperation")) {
125 assertEquals(1, annotation.getParameters().size());
126 assertNotNull(annotation.getParameter("types"));
127 assertEquals(3, annotation.getParameter("types").getValues().size());
130 assertEquals(2, annotCount);
134 public void generatedPropertyAnnotationTest() {
135 final GeneratedTOBuilder genTOBuilder = new CodegenGeneratedTOBuilder(
136 JavaTypeName.create("org.opendaylight.controller", "AnnotInterface"));
138 final GeneratedPropertyBuilder propertyBuilder = genTOBuilder.addProperty("simpleProperty");
139 propertyBuilder.setReturnType(Types.typeForClass(Integer.class));
140 final AnnotationTypeBuilder annotManAttr = propertyBuilder.addAnnotation(
141 "org.springframework.jmx.export.annotation", "ManagedAttribute");
143 annotManAttr.addParameter("description", "\"The Name Attribute\"");
144 annotManAttr.addParameter("currencyTimeLimit", "20");
145 annotManAttr.addParameter("defaultValue", "\"bar\"");
146 annotManAttr.addParameter("persistPolicy", "\"OnUpdate\"");
148 final AnnotationTypeBuilder annotManProp = propertyBuilder.addAnnotation(
149 "org.springframework.jmx.export.annotation", "ManagedOperation");
151 final List<String> typeValues = new ArrayList<>();
152 typeValues.add("\"val1\"");
153 typeValues.add("\"val2\"");
154 typeValues.add("\"val3\"");
155 annotManProp.addParameters("types", typeValues);
157 final GeneratedTransferObject genTransObj = genTOBuilder.build();
159 assertNotNull(genTransObj);
160 assertNotNull(genTransObj.getAnnotations());
161 assertNotNull(genTransObj.getProperties());
162 assertNotNull(genTransObj.getProperties().get(0));
163 assertNotNull(genTransObj.getProperties().get(0).getAnnotations());
164 final List<AnnotationType> annotations = genTransObj.getProperties().get(0).getAnnotations();
165 assertEquals(2, annotations.size());
168 for (final AnnotationType annotation : annotations) {
169 if (annotation.getPackageName().equals("org.springframework.jmx.export.annotation")
170 && annotation.getName().equals("ManagedAttribute")) {
172 assertEquals(4, annotation.getParameters().size());
174 assertNotNull(annotation.getParameter("description"));
175 assertNotNull(annotation.getParameter("currencyTimeLimit"));
176 assertNotNull(annotation.getParameter("defaultValue"));
177 assertNotNull(annotation.getParameter("persistPolicy"));
178 assertEquals("\"The Name Attribute\"", annotation.getParameter("description").getValue());
179 assertEquals("20", annotation.getParameter("currencyTimeLimit").getValue());
180 assertEquals("\"bar\"", annotation.getParameter("defaultValue").getValue());
181 assertEquals("\"OnUpdate\"", annotation.getParameter("persistPolicy").getValue());
183 if (annotation.getPackageName().equals("org.springframework.jmx.export.annotation")
184 && annotation.getName().equals("ManagedOperation")) {
187 assertEquals(1, annotation.getParameters().size());
188 assertNotNull(annotation.getParameter("types"));
189 assertEquals(3, annotation.getParameter("types").getValues().size());
192 assertEquals(2, annotCount);
196 public void generatedTransfeObjectAnnotationTest() {
197 final GeneratedTOBuilder genTypeBuilder = new CodegenGeneratedTOBuilder(
198 JavaTypeName.create("org.opendaylight.controller", "AnnotClassCache"));
200 genTypeBuilder.addAnnotation("javax.management", "MBean");
201 final AnnotationTypeBuilder annotNotify = genTypeBuilder.addAnnotation("javax.management", "NotificationInfo");
203 final List<String> notifyList = new ArrayList<>();
204 notifyList.add("\"my.notif.type\"");
205 annotNotify.addParameters("types", notifyList);
206 annotNotify.addParameter("description", "@Description(\"my notification\")");
208 GeneratedTransferObject genTO = genTypeBuilder.build();
210 assertNotNull(genTO);
211 assertNotNull(genTO.getAnnotations());
212 assertEquals(2, genTO.getAnnotations().size());
215 for (final AnnotationType annotation : genTO.getAnnotations()) {
216 if (annotation.getPackageName().equals("javax.management") && annotation.getName().equals("MBean")) {
218 assertEquals(0, annotation.getParameters().size());
220 if (annotation.getPackageName().equals("javax.management")
221 && annotation.getName().equals("NotificationInfo")) {
223 assertEquals(2, annotation.getParameters().size());
224 AnnotationType.Parameter param = annotation.getParameter("types");
225 assertNotNull(param);
226 assertEquals("types", param.getName());
227 assertNull(param.getValue());
228 assertNotNull(param.getValues());
229 assertEquals(1, param.getValues().size());
230 assertEquals("\"my.notif.type\"", param.getValues().get(0));
232 param = annotation.getParameter("description");
233 assertNotNull(param);
234 assertEquals("description", param.getName());
235 assertNotNull(param.getValue());
236 assertEquals("@Description(\"my notification\")", param.getValue());
239 assertEquals(2, annotCount);
243 public void annotationTypeBuilderAddAnnotationTest() {
244 AnnotationTypeBuilder annotationTypeBuilder = new AnnotationTypeBuilderImpl(
245 JavaTypeName.create("my.package", "MyName"));
247 assertThrows(NullPointerException.class, () -> annotationTypeBuilder.addAnnotation("my.package", null));
248 assertThrows(NullPointerException.class, () -> annotationTypeBuilder.addAnnotation(null, "MyName"));
250 assertNotNull(annotationTypeBuilder.addAnnotation("java.lang", "Deprecated"));
252 final var builder = annotationTypeBuilder.addAnnotation("my.package2", "MyName2");
253 assertNotNull(builder);
254 assertSame(builder, annotationTypeBuilder.addAnnotation("my.package2", "MyName2"));
256 AnnotationType annotationTypeInstance = annotationTypeBuilder.build();
258 assertEquals(2, annotationTypeInstance.getAnnotations().size());
260 assertEquals("my.package", annotationTypeInstance.getPackageName());
261 assertEquals("MyName", annotationTypeInstance.getName());
266 public void annotationTypeBuilderEqualsTest() {
267 final AnnotationTypeBuilder annotationTypeBuilder = new AnnotationTypeBuilderImpl(
268 JavaTypeName.create("my.package", "MyName"));
269 final AnnotationTypeBuilder annotationTypeBuilder2 = new AnnotationTypeBuilderImpl(
270 JavaTypeName.create("my.package2", "MyName"));
271 final AnnotationTypeBuilder annotationTypeBuilder3 = new AnnotationTypeBuilderImpl(
272 JavaTypeName.create("my.package", "MyName2"));
273 final AnnotationTypeBuilder annotationTypeBuilder4 = new AnnotationTypeBuilderImpl(
274 JavaTypeName.create("my.package", "MyName"));
276 assertFalse(annotationTypeBuilder.equals(null));
277 assertFalse(annotationTypeBuilder.equals(new Object()));
279 assertTrue(annotationTypeBuilder.equals(annotationTypeBuilder));
281 assertTrue(annotationTypeBuilder.equals(annotationTypeBuilder4));
282 assertFalse(annotationTypeBuilder.equals(annotationTypeBuilder2));
283 assertFalse(annotationTypeBuilder.equals(annotationTypeBuilder3));
285 AnnotationType instance = annotationTypeBuilder.build();
286 assertFalse(instance.equals(null));
287 assertFalse(instance.equals(new Object()));
288 assertTrue(instance.equals(instance));
290 AnnotationType instance2 = annotationTypeBuilder2.build();
291 assertFalse(instance.equals(instance2));
293 final AnnotationType instance3 = annotationTypeBuilder3.build();
294 assertFalse(instance.equals(instance3));
295 final AnnotationType instance4 = annotationTypeBuilder4.build();
296 assertTrue(instance.equals(instance4));
298 annotationTypeBuilder.addParameter("myName", "myValue1");
299 annotationTypeBuilder.addParameter("myName2", "myValue2");
300 annotationTypeBuilder2.addParameter("myName", "myValue3");
302 instance = annotationTypeBuilder.build();
303 instance2 = annotationTypeBuilder2.build();
305 final Parameter parameter = instance.getParameter("myName");
306 final Parameter parameter2 = instance.getParameter("myName2");
307 final Parameter parameter3 = instance2.getParameter("myName");
309 assertFalse(parameter.equals(null));
310 assertFalse(parameter.equals(new Object()));
311 assertTrue(parameter.equals(parameter));
312 assertTrue(parameter.equals(parameter3));
313 assertFalse(parameter.equals(parameter2));
317 public void annotationTypeBuilderHashCodeTest() {
318 AnnotationTypeBuilder annotationTypeBuilder = new AnnotationTypeBuilderImpl(
319 JavaTypeName.create("my.package", "MyName"));
320 AnnotationTypeBuilder annotationTypeBuilder2 = new AnnotationTypeBuilderImpl(
321 JavaTypeName.create("my.package2", "MyName"));
322 AnnotationTypeBuilder annotationTypeBuilder3 = new AnnotationTypeBuilderImpl(
323 JavaTypeName.create("my.package", "MyName2"));
324 AnnotationTypeBuilder annotationTypeBuilder4 = new AnnotationTypeBuilderImpl(
325 JavaTypeName.create("my.package", "MyName"));
327 assertFalse(annotationTypeBuilder.hashCode() == annotationTypeBuilder2.hashCode());
328 assertFalse(annotationTypeBuilder.hashCode() == annotationTypeBuilder3.hashCode());
330 assertTrue(annotationTypeBuilder.hashCode() == annotationTypeBuilder4.hashCode());
331 assertTrue(annotationTypeBuilder.hashCode() == annotationTypeBuilder.hashCode());
333 AnnotationType instance = annotationTypeBuilder.build();
334 AnnotationType instance2 = annotationTypeBuilder2.build();
335 AnnotationType instance3 = annotationTypeBuilder3.build();
336 AnnotationType instance4 = annotationTypeBuilder4.build();
338 assertFalse(instance.hashCode() == instance2.hashCode());
339 assertFalse(instance.hashCode() == instance3.hashCode());
341 assertTrue(instance.hashCode() == instance4.hashCode());
342 assertTrue(instance.hashCode() == instance.hashCode());
344 annotationTypeBuilder.addParameter("myName", "myValue1");
345 annotationTypeBuilder.addParameter("myName2", "myValue2");
346 annotationTypeBuilder2.addParameter("myName", "myValue3");
348 instance = annotationTypeBuilder.build();
349 instance2 = annotationTypeBuilder2.build();
351 Parameter parameter = instance.getParameter("myName");
352 Parameter parameter2 = instance.getParameter("myName2");
353 Parameter parameter3 = instance2.getParameter("myName");
355 assertTrue(parameter.hashCode() == parameter.hashCode());
356 assertTrue(parameter.hashCode() == parameter3.hashCode());
357 assertFalse(parameter.hashCode() == parameter2.hashCode());
362 public void annotationTypeBuilderAddParameterTest() {
363 AnnotationTypeBuilder annotationTypeBuilder = new AnnotationTypeBuilderImpl(
364 JavaTypeName.create("my.package", "MyName"));
366 assertFalse(annotationTypeBuilder.addParameter(null, "myValue"));
367 assertFalse(annotationTypeBuilder.addParameter("myName", null));
369 assertFalse(annotationTypeBuilder.addParameters(null, new ArrayList<String>()));
370 assertFalse(annotationTypeBuilder.addParameters("myName", null));
372 assertTrue(annotationTypeBuilder.addParameter("myName", "myValue"));
373 assertFalse(annotationTypeBuilder.addParameter("myName", "myValue"));
374 assertFalse(annotationTypeBuilder.addParameters("myName", new ArrayList<String>()));
376 ArrayList<String> values = new ArrayList<>();
377 values.add("myValue");
378 assertTrue(annotationTypeBuilder.addParameters("myName2", values));
380 AnnotationType annotationTypeInstance = annotationTypeBuilder.build();
381 assertTrue(annotationTypeInstance.containsParameters());
382 assertEquals(2, annotationTypeInstance.getParameters().size());
383 assertEquals(2, annotationTypeInstance.getParameterNames().size());
384 assertTrue(annotationTypeInstance.getParameterNames().contains("myName"));
385 assertTrue(annotationTypeInstance.getParameterNames().contains("myName2"));
386 assertFalse(annotationTypeInstance.getParameterNames().contains("myName3"));
388 Parameter parameter = annotationTypeInstance.getParameter("myName");
389 Parameter parameter2 = annotationTypeInstance.getParameter("myName2");
390 Parameter parameter3 = annotationTypeInstance.getParameter("myName3");
392 assertNotNull(parameter);
393 assertNotNull(parameter2);
394 assertNull(parameter3);
396 assertEquals(parameter.getValue(), "myValue");
397 assertTrue(parameter.getValues().isEmpty());
399 assertEquals(1, parameter2.getValues().size());
400 assertTrue(parameter2.getValues().contains("myValue"));
405 public void annotationTypeBuilderToStringTest() {
406 AnnotationTypeBuilder annotationTypeBuilder = new AnnotationTypeBuilderImpl(
407 JavaTypeName.create("my.package", "MyAnnotationName"));
408 annotationTypeBuilder.addAnnotation("my.package", "MySubAnnotationName");
409 annotationTypeBuilder.addParameter("MyParameter", "myValue");
411 assertEquals("AnnotationTypeBuilderImpl{identifier=my.package.MyAnnotationName, "
412 + "annotationBuilders=[AnnotationTypeBuilderImpl{identifier=my.package.MySubAnnotationName, "
413 + "annotationBuilders=[], parameters=[]}], parameters=[ParameterImpl [name=MyParameter, value=myValue, "
414 + "values=[]]]}", annotationTypeBuilder.toString());
416 AnnotationType annotationTypeInstance = annotationTypeBuilder.build();
418 assertEquals("my.package.MyAnnotationName", annotationTypeInstance.getFullyQualifiedName());
419 assertEquals("AnnotationTypeImpl{identifier=my.package.MyAnnotationName, "
420 + "annotations=[AnnotationTypeImpl{identifier=my.package.MySubAnnotationName, annotations=[], "
421 + "parameters=[]}], parameters=[ParameterImpl [name=MyParameter, value=myValue, values=[]]]}",
422 annotationTypeInstance.toString());
426 public void testAddAnnotation() {
427 final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl(
428 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest"));
429 annotBuilderImpl.addAnnotation("org.opedaylight.yangtools.test.v1", "AnnotationTest2");
430 annotBuilderImpl.addAnnotation(null, "AnnotationTest2");
431 assertFalse(annotBuilderImpl.build().getAnnotations().isEmpty());
435 public void testAddParameterMethod() {
436 final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl(
437 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest"));
438 annotBuilderImpl.addParameter("testParam", "test value");
439 annotBuilderImpl.addParameter(null, "test value");
440 final AnnotationType annotType = annotBuilderImpl.build();
441 assertEquals(1, annotType.getParameters().size());
445 public void testAddParametersMethod() {
446 final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl(
447 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest"));
449 final List<String> values = new ArrayList<>();
453 annotBuilderImpl.addParameters("testParam", values);
455 AnnotationType annotType = annotBuilderImpl.build();
456 assertEquals(1, annotType.getParameters().size());
458 annotBuilderImpl.addParameters("testParam", null);
460 annotType = annotBuilderImpl.build();
461 assertEquals(1, annotType.getParameters().size());
465 public void testHashCode() {
466 final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl(
467 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest"));
468 final AnnotationTypeBuilderImpl annotBuilderImpl2 = new AnnotationTypeBuilderImpl(
469 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest2"));
470 assertFalse(annotBuilderImpl.hashCode() == annotBuilderImpl2.hashCode());
474 public void testEquals() {
475 final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl(
476 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest"));
477 final AnnotationTypeBuilderImpl annotBuilderImpl2 = new AnnotationTypeBuilderImpl(
478 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest"));
479 final AnnotationTypeBuilderImpl annotBuilderImpl3 = annotBuilderImpl2;
481 assertTrue(annotBuilderImpl.equals(annotBuilderImpl2));
482 assertTrue(annotBuilderImpl2.equals(annotBuilderImpl3));
483 assertFalse(annotBuilderImpl2.equals(null));
484 assertFalse(annotBuilderImpl2.equals("test"));
488 public void testToString() {
489 final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl(
490 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest"));
491 assertNotNull(annotBuilderImpl.toString());
495 public void testMethodsForAnnotationTypeImpl() {
496 final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl(
497 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest"));
498 annotBuilderImpl.addParameter("testParam", "test value");
499 final AnnotationType annotationType = annotBuilderImpl.build();
501 final AnnotationTypeBuilderImpl annotBuilderImpl2 = new AnnotationTypeBuilderImpl(
502 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest"));
503 final AnnotationType annotationType2 = annotBuilderImpl2.build();
505 assertTrue(annotationType.containsParameters());
506 assertTrue(annotationType.getAnnotations().isEmpty());
507 assertNotNull(annotationType.getFullyQualifiedName());
508 assertNotNull(annotationType.getName());
509 assertNotNull(annotationType.getPackageName());
510 assertNull(annotationType.getParameter(null));
511 assertNotNull(annotationType.getParameter("testParam"));
512 assertFalse(annotationType.getParameterNames().isEmpty());
513 assertFalse(annotationType.getParameters().isEmpty());
515 assertTrue(annotationType.hashCode() == annotationType2.hashCode());
516 assertTrue(annotationType.equals(annotationType2));
517 assertNotNull(annotationType.toString());
521 public void testMethodsForParameterImpl() {
522 final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl(
523 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest"));
524 annotBuilderImpl.addParameter("testParam", "test value");
525 annotBuilderImpl.addParameter("testParam", "test value");
526 annotBuilderImpl.addParameter("", "test value");
527 annotBuilderImpl.addParameter(null, "test value");
528 annotBuilderImpl.addParameter("", null);
529 final AnnotationType annotationType = annotBuilderImpl.build();
531 final Parameter testParam = annotationType.getParameter("testParam");
532 assertEquals("testParam", testParam.getName());
533 assertEquals("test value", testParam.getValue());
534 assertEquals(0, testParam.getValues().size());
536 final List<Parameter> testParams = annotationType.getParameters();
537 final Parameter sameParam = testParams.get(0);
539 assertFalse(testParams.get(0).equals(testParams.get(1)));
540 assertFalse(testParams.get(0).equals(null));
541 assertFalse(testParams.get(0).equals("test"));
542 assertTrue(testParams.get(0).equals(sameParam));
543 assertFalse(testParams.get(0).hashCode() == testParams.get(1).hashCode());
544 assertTrue(testParams.get(0).hashCode() == testParams.get(0).hashCode());