fix #123 allow to specify extra annotations on repositories/methods
[yosql.git] / yosql-models / yosql-models-configuration / src / test / java / wtf / metio / yosql / models / configuration / AnnotationTest.java
blob023bbb5754eb181693a759c11db30874ed258b76
1 /*
2 * This file is part of yosql. It is subject to the license terms in the LICENSE file found in the top-level
3 * directory of this distribution and at https://creativecommons.org/publicdomain/zero/1.0/. No part of yosql,
4 * including this file, may be copied, modified, propagated, or distributed except according to the terms contained
5 * in the LICENSE file.
6 */
8 package wtf.metio.yosql.models.configuration;
10 import org.junit.jupiter.api.Test;
12 import java.util.List;
14 import static org.junit.jupiter.api.Assertions.assertIterableEquals;
16 class AnnotationTest {
18 @Test
19 void mergeAnnotationsFirst() {
20 final List<Annotation> first = List.of(Annotation.builder().setType("com.example.MyAnnotation").build());
21 final List<Annotation> second = List.of();
23 final var merged = Annotation.mergeAnnotations(first, second);
25 assertIterableEquals(first, merged);
28 @Test
29 void mergeAnnotationsSecond() {
30 final List<Annotation> first = List.of();
31 final List<Annotation> second = List.of(Annotation.builder().setType("com.example.MyAnnotation").build());
33 final var merged = Annotation.mergeAnnotations(first, second);
35 assertIterableEquals(second, merged);
38 @Test
39 void mergeAnnotationsDuplicates() {
40 final List<Annotation> first = List.of(Annotation.builder().setType("com.example.MyAnnotation").build());
41 final List<Annotation> second = List.of(Annotation.builder().setType("com.example.MyAnnotation").build());
43 final var merged = Annotation.mergeAnnotations(first, second);
45 assertIterableEquals(first, merged);
46 assertIterableEquals(second, merged);
49 @Test
50 void mergeAnnotationsWithMembersFirst() {
51 final List<Annotation> first = List.of(Annotation.builder()
52 .setType("com.example.MyAnnotation")
53 .addMembers(AnnotationMember.builder().setKey("value").setValue("some").build())
54 .build());
55 final List<Annotation> second = List.of(Annotation.builder()
56 .setType("com.example.MyAnnotation")
57 .build());
59 final var merged = Annotation.mergeAnnotations(first, second);
61 assertIterableEquals(first, merged);
64 @Test
65 void mergeAnnotationsWithMembersSecond() {
66 final List<Annotation> first = List.of(Annotation.builder()
67 .setType("com.example.MyAnnotation")
68 .build());
69 final List<Annotation> second = List.of(Annotation.builder()
70 .setType("com.example.MyAnnotation")
71 .addMembers(AnnotationMember.builder().setKey("value").setValue("some").build())
72 .build());
74 final var merged = Annotation.mergeAnnotations(first, second);
76 assertIterableEquals(second, merged);