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.assertTrue;
16 import java.util.ArrayList;
17 import java.util.List;
18 import org.junit.Test;
19 import org.opendaylight.mdsal.binding.model.api.AnnotationType;
20 import org.opendaylight.mdsal.binding.model.api.AnnotationType.Parameter;
21 import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject;
22 import org.opendaylight.mdsal.binding.model.api.GeneratedType;
23 import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
24 import org.opendaylight.mdsal.binding.model.api.type.builder.AnnotationTypeBuilder;
25 import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedPropertyBuilder;
26 import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTOBuilder;
27 import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilder;
28 import org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder;
29 import org.opendaylight.mdsal.binding.model.ri.Types;
31 public class AnnotationBuilderTest {
34 public void generatedTypeAnnotationTest() {
35 final GeneratedTypeBuilder genTypeBuilder = new CodegenGeneratedTypeBuilder(
36 JavaTypeName.create("org.opendaylight.controller", "AnnotInterface"));
38 genTypeBuilder.addAnnotation("javax.management", "MXBean");
39 final AnnotationTypeBuilder annotDesc = genTypeBuilder.addAnnotation("javax.management", "Description");
40 annotDesc.addParameter("description", "some sort of interface");
42 final GeneratedType genType = genTypeBuilder.build();
44 assertNotNull(genType);
45 assertNotNull(genType.getAnnotations());
46 assertEquals(2, genType.getAnnotations().size());
49 for (final AnnotationType annotation : genType.getAnnotations()) {
50 if (annotation.getPackageName().equals("javax.management") && annotation.getName().equals("MXBean")) {
52 assertEquals(0, annotation.getParameters().size());
54 if (annotation.getPackageName().equals("javax.management") && annotation.getName().equals("Description")) {
56 assertEquals(1, annotation.getParameters().size());
57 AnnotationType.Parameter param = annotation.getParameter("description");
59 assertEquals("description", param.getName());
60 assertNotNull(param.getValue());
61 assertEquals("some sort of interface", param.getValue());
62 assertNotNull(param.getValues());
63 assertTrue(param.getValues().isEmpty());
66 assertEquals(2, annotCount);
70 public void methodSignatureAnnotationTest() {
71 final GeneratedTypeBuilder genTypeBuilder = new CodegenGeneratedTypeBuilder(
72 JavaTypeName.create("org.opendaylight.controller", "TransferObject"));
74 final MethodSignatureBuilder methodBuilder = genTypeBuilder.addMethod("simpleMethod");
75 methodBuilder.setReturnType(Types.typeForClass(Integer.class));
76 final AnnotationTypeBuilder annotManAttr = methodBuilder.addAnnotation(
77 "org.springframework.jmx.export.annotation", "ManagedAttribute");
79 annotManAttr.addParameter("description", "\"The Name Attribute\"");
80 annotManAttr.addParameter("currencyTimeLimit", "20");
81 annotManAttr.addParameter("defaultValue", "\"bar\"");
82 annotManAttr.addParameter("persistPolicy", "\"OnUpdate\"");
84 final AnnotationTypeBuilder annotManProp = methodBuilder.addAnnotation(
85 "org.springframework.jmx.export.annotation", "ManagedOperation");
87 final List<String> typeValues = new ArrayList<>();
88 typeValues.add("\"val1\"");
89 typeValues.add("\"val2\"");
90 typeValues.add("\"val3\"");
91 annotManProp.addParameters("types", typeValues);
93 final GeneratedType genType = genTypeBuilder.build();
95 assertNotNull(genType);
96 assertNotNull(genType.getAnnotations());
97 assertNotNull(genType.getMethodDefinitions());
98 assertNotNull(genType.getMethodDefinitions().get(0));
99 assertNotNull(genType.getMethodDefinitions().get(0).getAnnotations());
100 final List<AnnotationType> annotations = genType.getMethodDefinitions().get(0).getAnnotations();
101 assertEquals(2, annotations.size());
104 for (final AnnotationType annotation : annotations) {
105 if (annotation.getPackageName().equals("org.springframework.jmx.export.annotation")
106 && annotation.getName().equals("ManagedAttribute")) {
108 assertEquals(4, annotation.getParameters().size());
110 assertNotNull(annotation.getParameter("description"));
111 assertNotNull(annotation.getParameter("currencyTimeLimit"));
112 assertNotNull(annotation.getParameter("defaultValue"));
113 assertNotNull(annotation.getParameter("persistPolicy"));
114 assertEquals("\"The Name Attribute\"", annotation.getParameter("description").getValue());
115 assertEquals("20", annotation.getParameter("currencyTimeLimit").getValue());
116 assertEquals("\"bar\"", annotation.getParameter("defaultValue").getValue());
117 assertEquals("\"OnUpdate\"", annotation.getParameter("persistPolicy").getValue());
119 if (annotation.getPackageName().equals("org.springframework.jmx.export.annotation")
120 && annotation.getName().equals("ManagedOperation")) {
123 assertEquals(1, annotation.getParameters().size());
124 assertNotNull(annotation.getParameter("types"));
125 assertEquals(3, annotation.getParameter("types").getValues().size());
128 assertEquals(2, annotCount);
132 public void generatedPropertyAnnotationTest() {
133 final GeneratedTOBuilder genTOBuilder = new CodegenGeneratedTOBuilder(
134 JavaTypeName.create("org.opendaylight.controller", "AnnotInterface"));
136 final GeneratedPropertyBuilder propertyBuilder = genTOBuilder.addProperty("simpleProperty");
137 propertyBuilder.setReturnType(Types.typeForClass(Integer.class));
138 final AnnotationTypeBuilder annotManAttr = propertyBuilder.addAnnotation(
139 "org.springframework.jmx.export.annotation", "ManagedAttribute");
141 annotManAttr.addParameter("description", "\"The Name Attribute\"");
142 annotManAttr.addParameter("currencyTimeLimit", "20");
143 annotManAttr.addParameter("defaultValue", "\"bar\"");
144 annotManAttr.addParameter("persistPolicy", "\"OnUpdate\"");
146 final AnnotationTypeBuilder annotManProp = propertyBuilder.addAnnotation(
147 "org.springframework.jmx.export.annotation", "ManagedOperation");
149 final List<String> typeValues = new ArrayList<>();
150 typeValues.add("\"val1\"");
151 typeValues.add("\"val2\"");
152 typeValues.add("\"val3\"");
153 annotManProp.addParameters("types", typeValues);
155 final GeneratedTransferObject genTransObj = genTOBuilder.build();
157 assertNotNull(genTransObj);
158 assertNotNull(genTransObj.getAnnotations());
159 assertNotNull(genTransObj.getProperties());
160 assertNotNull(genTransObj.getProperties().get(0));
161 assertNotNull(genTransObj.getProperties().get(0).getAnnotations());
162 final List<AnnotationType> annotations = genTransObj.getProperties().get(0).getAnnotations();
163 assertEquals(2, annotations.size());
166 for (final AnnotationType annotation : annotations) {
167 if (annotation.getPackageName().equals("org.springframework.jmx.export.annotation")
168 && annotation.getName().equals("ManagedAttribute")) {
170 assertEquals(4, annotation.getParameters().size());
172 assertNotNull(annotation.getParameter("description"));
173 assertNotNull(annotation.getParameter("currencyTimeLimit"));
174 assertNotNull(annotation.getParameter("defaultValue"));
175 assertNotNull(annotation.getParameter("persistPolicy"));
176 assertEquals("\"The Name Attribute\"", annotation.getParameter("description").getValue());
177 assertEquals("20", annotation.getParameter("currencyTimeLimit").getValue());
178 assertEquals("\"bar\"", annotation.getParameter("defaultValue").getValue());
179 assertEquals("\"OnUpdate\"", annotation.getParameter("persistPolicy").getValue());
181 if (annotation.getPackageName().equals("org.springframework.jmx.export.annotation")
182 && annotation.getName().equals("ManagedOperation")) {
185 assertEquals(1, annotation.getParameters().size());
186 assertNotNull(annotation.getParameter("types"));
187 assertEquals(3, annotation.getParameter("types").getValues().size());
190 assertEquals(2, annotCount);
194 public void generatedTransfeObjectAnnotationTest() {
195 final GeneratedTOBuilder genTypeBuilder = new CodegenGeneratedTOBuilder(
196 JavaTypeName.create("org.opendaylight.controller", "AnnotClassCache"));
198 genTypeBuilder.addAnnotation("javax.management", "MBean");
199 final AnnotationTypeBuilder annotNotify = genTypeBuilder.addAnnotation("javax.management", "NotificationInfo");
201 final List<String> notifyList = new ArrayList<>();
202 notifyList.add("\"my.notif.type\"");
203 annotNotify.addParameters("types", notifyList);
204 annotNotify.addParameter("description", "@Description(\"my notification\")");
206 GeneratedTransferObject genTO = genTypeBuilder.build();
208 assertNotNull(genTO);
209 assertNotNull(genTO.getAnnotations());
210 assertEquals(2, genTO.getAnnotations().size());
213 for (final AnnotationType annotation : genTO.getAnnotations()) {
214 if (annotation.getPackageName().equals("javax.management") && annotation.getName().equals("MBean")) {
216 assertEquals(0, annotation.getParameters().size());
218 if (annotation.getPackageName().equals("javax.management")
219 && annotation.getName().equals("NotificationInfo")) {
221 assertEquals(2, annotation.getParameters().size());
222 AnnotationType.Parameter param = annotation.getParameter("types");
223 assertNotNull(param);
224 assertEquals("types", param.getName());
225 assertNull(param.getValue());
226 assertNotNull(param.getValues());
227 assertEquals(1, param.getValues().size());
228 assertEquals("\"my.notif.type\"", param.getValues().get(0));
230 param = annotation.getParameter("description");
231 assertNotNull(param);
232 assertEquals("description", param.getName());
233 assertNotNull(param.getValue());
234 assertEquals("@Description(\"my notification\")", param.getValue());
237 assertEquals(2, annotCount);
241 public void annotationTypeBuilderAddAnnotationTest() {
242 AnnotationTypeBuilder annotationTypeBuilder = new AnnotationTypeBuilderImpl(
243 JavaTypeName.create("my.package", "MyName"));
245 assertNull(annotationTypeBuilder.addAnnotation("my.package", null));
246 assertNull(annotationTypeBuilder.addAnnotation(null, "MyName"));
248 assertNotNull(annotationTypeBuilder.addAnnotation("java.lang", "Deprecated"));
250 assertNotNull(annotationTypeBuilder.addAnnotation("my.package2", "MyName2"));
251 assertNull(annotationTypeBuilder.addAnnotation("my.package2", "MyName2"));
253 AnnotationType annotationTypeInstance = annotationTypeBuilder.build();
255 assertEquals(2, annotationTypeInstance.getAnnotations().size());
257 assertEquals("my.package", annotationTypeInstance.getPackageName());
258 assertEquals("MyName", annotationTypeInstance.getName());
263 public void annotationTypeBuilderEqualsTest() {
264 final AnnotationTypeBuilder annotationTypeBuilder = new AnnotationTypeBuilderImpl(
265 JavaTypeName.create("my.package", "MyName"));
266 final AnnotationTypeBuilder annotationTypeBuilder2 = new AnnotationTypeBuilderImpl(
267 JavaTypeName.create("my.package2", "MyName"));
268 final AnnotationTypeBuilder annotationTypeBuilder3 = new AnnotationTypeBuilderImpl(
269 JavaTypeName.create("my.package", "MyName2"));
270 final AnnotationTypeBuilder annotationTypeBuilder4 = new AnnotationTypeBuilderImpl(
271 JavaTypeName.create("my.package", "MyName"));
273 assertFalse(annotationTypeBuilder.equals(null));
274 assertFalse(annotationTypeBuilder.equals(new Object()));
276 assertTrue(annotationTypeBuilder.equals(annotationTypeBuilder));
278 assertTrue(annotationTypeBuilder.equals(annotationTypeBuilder4));
279 assertFalse(annotationTypeBuilder.equals(annotationTypeBuilder2));
280 assertFalse(annotationTypeBuilder.equals(annotationTypeBuilder3));
282 AnnotationType instance = annotationTypeBuilder.build();
283 assertFalse(instance.equals(null));
284 assertFalse(instance.equals(new Object()));
285 assertTrue(instance.equals(instance));
287 AnnotationType instance2 = annotationTypeBuilder2.build();
288 assertFalse(instance.equals(instance2));
290 final AnnotationType instance3 = annotationTypeBuilder3.build();
291 assertFalse(instance.equals(instance3));
292 final AnnotationType instance4 = annotationTypeBuilder4.build();
293 assertTrue(instance.equals(instance4));
295 annotationTypeBuilder.addParameter("myName", "myValue1");
296 annotationTypeBuilder.addParameter("myName2", "myValue2");
297 annotationTypeBuilder2.addParameter("myName", "myValue3");
299 instance = annotationTypeBuilder.build();
300 instance2 = annotationTypeBuilder2.build();
302 final Parameter parameter = instance.getParameter("myName");
303 final Parameter parameter2 = instance.getParameter("myName2");
304 final Parameter parameter3 = instance2.getParameter("myName");
306 assertFalse(parameter.equals(null));
307 assertFalse(parameter.equals(new Object()));
308 assertTrue(parameter.equals(parameter));
309 assertTrue(parameter.equals(parameter3));
310 assertFalse(parameter.equals(parameter2));
314 public void annotationTypeBuilderHashCodeTest() {
315 AnnotationTypeBuilder annotationTypeBuilder = new AnnotationTypeBuilderImpl(
316 JavaTypeName.create("my.package", "MyName"));
317 AnnotationTypeBuilder annotationTypeBuilder2 = new AnnotationTypeBuilderImpl(
318 JavaTypeName.create("my.package2", "MyName"));
319 AnnotationTypeBuilder annotationTypeBuilder3 = new AnnotationTypeBuilderImpl(
320 JavaTypeName.create("my.package", "MyName2"));
321 AnnotationTypeBuilder annotationTypeBuilder4 = new AnnotationTypeBuilderImpl(
322 JavaTypeName.create("my.package", "MyName"));
324 assertFalse(annotationTypeBuilder.hashCode() == annotationTypeBuilder2.hashCode());
325 assertFalse(annotationTypeBuilder.hashCode() == annotationTypeBuilder3.hashCode());
327 assertTrue(annotationTypeBuilder.hashCode() == annotationTypeBuilder4.hashCode());
328 assertTrue(annotationTypeBuilder.hashCode() == annotationTypeBuilder.hashCode());
330 AnnotationType instance = annotationTypeBuilder.build();
331 AnnotationType instance2 = annotationTypeBuilder2.build();
332 AnnotationType instance3 = annotationTypeBuilder3.build();
333 AnnotationType instance4 = annotationTypeBuilder4.build();
335 assertFalse(instance.hashCode() == instance2.hashCode());
336 assertFalse(instance.hashCode() == instance3.hashCode());
338 assertTrue(instance.hashCode() == instance4.hashCode());
339 assertTrue(instance.hashCode() == instance.hashCode());
341 annotationTypeBuilder.addParameter("myName", "myValue1");
342 annotationTypeBuilder.addParameter("myName2", "myValue2");
343 annotationTypeBuilder2.addParameter("myName", "myValue3");
345 instance = annotationTypeBuilder.build();
346 instance2 = annotationTypeBuilder2.build();
348 Parameter parameter = instance.getParameter("myName");
349 Parameter parameter2 = instance.getParameter("myName2");
350 Parameter parameter3 = instance2.getParameter("myName");
352 assertTrue(parameter.hashCode() == parameter.hashCode());
353 assertTrue(parameter.hashCode() == parameter3.hashCode());
354 assertFalse(parameter.hashCode() == parameter2.hashCode());
359 public void annotationTypeBuilderAddParameterTest() {
360 AnnotationTypeBuilder annotationTypeBuilder = new AnnotationTypeBuilderImpl(
361 JavaTypeName.create("my.package", "MyName"));
363 assertFalse(annotationTypeBuilder.addParameter(null, "myValue"));
364 assertFalse(annotationTypeBuilder.addParameter("myName", null));
366 assertFalse(annotationTypeBuilder.addParameters(null, new ArrayList<String>()));
367 assertFalse(annotationTypeBuilder.addParameters("myName", null));
369 assertTrue(annotationTypeBuilder.addParameter("myName", "myValue"));
370 assertFalse(annotationTypeBuilder.addParameter("myName", "myValue"));
371 assertFalse(annotationTypeBuilder.addParameters("myName", new ArrayList<String>()));
373 ArrayList<String> values = new ArrayList<>();
374 values.add("myValue");
375 assertTrue(annotationTypeBuilder.addParameters("myName2", values));
377 AnnotationType annotationTypeInstance = annotationTypeBuilder.build();
378 assertTrue(annotationTypeInstance.containsParameters());
379 assertEquals(2, annotationTypeInstance.getParameters().size());
380 assertEquals(2, annotationTypeInstance.getParameterNames().size());
381 assertTrue(annotationTypeInstance.getParameterNames().contains("myName"));
382 assertTrue(annotationTypeInstance.getParameterNames().contains("myName2"));
383 assertFalse(annotationTypeInstance.getParameterNames().contains("myName3"));
385 Parameter parameter = annotationTypeInstance.getParameter("myName");
386 Parameter parameter2 = annotationTypeInstance.getParameter("myName2");
387 Parameter parameter3 = annotationTypeInstance.getParameter("myName3");
389 assertNotNull(parameter);
390 assertNotNull(parameter2);
391 assertNull(parameter3);
393 assertEquals(parameter.getValue(), "myValue");
394 assertTrue(parameter.getValues().isEmpty());
396 assertEquals(1, parameter2.getValues().size());
397 assertTrue(parameter2.getValues().contains("myValue"));
402 public void annotationTypeBuilderToStringTest() {
403 AnnotationTypeBuilder annotationTypeBuilder = new AnnotationTypeBuilderImpl(
404 JavaTypeName.create("my.package", "MyAnnotationName"));
405 annotationTypeBuilder.addAnnotation("my.package", "MySubAnnotationName");
406 annotationTypeBuilder.addParameter("MyParameter", "myValue");
408 assertEquals("AnnotationTypeBuilderImpl{identifier=my.package.MyAnnotationName, "
409 + "annotationBuilders=[AnnotationTypeBuilderImpl{identifier=my.package.MySubAnnotationName, "
410 + "annotationBuilders=[], parameters=[]}], parameters=[ParameterImpl [name=MyParameter, value=myValue, "
411 + "values=[]]]}", annotationTypeBuilder.toString());
413 AnnotationType annotationTypeInstance = annotationTypeBuilder.build();
415 assertEquals("my.package.MyAnnotationName", annotationTypeInstance.getFullyQualifiedName());
416 assertEquals("AnnotationTypeImpl{identifier=my.package.MyAnnotationName, "
417 + "annotations=[AnnotationTypeImpl{identifier=my.package.MySubAnnotationName, annotations=[], "
418 + "parameters=[]}], parameters=[ParameterImpl [name=MyParameter, value=myValue, values=[]]]}",
419 annotationTypeInstance.toString());
423 public void testAddAnnotation() {
424 final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl(
425 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest"));
426 annotBuilderImpl.addAnnotation("org.opedaylight.yangtools.test.v1", "AnnotationTest2");
427 annotBuilderImpl.addAnnotation(null, "AnnotationTest2");
428 assertFalse(annotBuilderImpl.build().getAnnotations().isEmpty());
432 public void testAddParameterMethod() {
433 final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl(
434 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest"));
435 annotBuilderImpl.addParameter("testParam", "test value");
436 annotBuilderImpl.addParameter(null, "test value");
437 final AnnotationType annotType = annotBuilderImpl.build();
438 assertEquals(1, annotType.getParameters().size());
442 public void testAddParametersMethod() {
443 final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl(
444 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest"));
446 final List<String> values = new ArrayList<>();
450 annotBuilderImpl.addParameters("testParam", values);
452 AnnotationType annotType = annotBuilderImpl.build();
453 assertEquals(1, annotType.getParameters().size());
455 annotBuilderImpl.addParameters("testParam", null);
457 annotType = annotBuilderImpl.build();
458 assertEquals(1, annotType.getParameters().size());
462 public void testHashCode() {
463 final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl(
464 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest"));
465 final AnnotationTypeBuilderImpl annotBuilderImpl2 = new AnnotationTypeBuilderImpl(
466 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest2"));
467 assertFalse(annotBuilderImpl.hashCode() == annotBuilderImpl2.hashCode());
471 public void testEquals() {
472 final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl(
473 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest"));
474 final AnnotationTypeBuilderImpl annotBuilderImpl2 = new AnnotationTypeBuilderImpl(
475 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest"));
476 final AnnotationTypeBuilderImpl annotBuilderImpl3 = annotBuilderImpl2;
478 assertTrue(annotBuilderImpl.equals(annotBuilderImpl2));
479 assertTrue(annotBuilderImpl2.equals(annotBuilderImpl3));
480 assertFalse(annotBuilderImpl2.equals(null));
481 assertFalse(annotBuilderImpl2.equals("test"));
485 public void testToString() {
486 final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl(
487 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest"));
488 assertNotNull(annotBuilderImpl.toString());
492 public void testMethodsForAnnotationTypeImpl() {
493 final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl(
494 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest"));
495 annotBuilderImpl.addParameter("testParam", "test value");
496 final AnnotationType annotationType = annotBuilderImpl.build();
498 final AnnotationTypeBuilderImpl annotBuilderImpl2 = new AnnotationTypeBuilderImpl(
499 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest"));
500 final AnnotationType annotationType2 = annotBuilderImpl2.build();
502 assertTrue(annotationType.containsParameters());
503 assertTrue(annotationType.getAnnotations().isEmpty());
504 assertNotNull(annotationType.getFullyQualifiedName());
505 assertNotNull(annotationType.getName());
506 assertNotNull(annotationType.getPackageName());
507 assertNull(annotationType.getParameter(null));
508 assertNotNull(annotationType.getParameter("testParam"));
509 assertFalse(annotationType.getParameterNames().isEmpty());
510 assertFalse(annotationType.getParameters().isEmpty());
512 assertTrue(annotationType.hashCode() == annotationType2.hashCode());
513 assertTrue(annotationType.equals(annotationType2));
514 assertNotNull(annotationType.toString());
518 public void testMethodsForParameterImpl() {
519 final AnnotationTypeBuilderImpl annotBuilderImpl = new AnnotationTypeBuilderImpl(
520 JavaTypeName.create("org.opedaylight.yangtools.test", "AnnotationTest"));
521 annotBuilderImpl.addParameter("testParam", "test value");
522 annotBuilderImpl.addParameter("testParam", "test value");
523 annotBuilderImpl.addParameter("", "test value");
524 annotBuilderImpl.addParameter(null, "test value");
525 annotBuilderImpl.addParameter("", null);
526 final AnnotationType annotationType = annotBuilderImpl.build();
528 final Parameter testParam = annotationType.getParameter("testParam");
529 assertEquals("testParam", testParam.getName());
530 assertEquals("test value", testParam.getValue());
531 assertEquals(0, testParam.getValues().size());
533 final List<Parameter> testParams = annotationType.getParameters();
534 final Parameter sameParam = testParams.get(0);
536 assertFalse(testParams.get(0).equals(testParams.get(1)));
537 assertFalse(testParams.get(0).equals(null));
538 assertFalse(testParams.get(0).equals("test"));
539 assertTrue(testParams.get(0).equals(sameParam));
540 assertFalse(testParams.get(0).hashCode() == testParams.get(1).hashCode());
541 assertTrue(testParams.get(0).hashCode() == testParams.get(0).hashCode());