|
24 | 24 | */ |
25 | 25 | class LombokProcessingTests { |
26 | 26 |
|
27 | | - /** |
28 | | - * Test class using Lombok @Getter and @Setter annotations. This simulates the Subscription class |
29 | | - * mentioned in the issue. |
30 | | - */ |
| 27 | + /** Test class using Lombok @Getter and @Setter annotations. */ |
31 | 28 | @Getter |
32 | 29 | @Setter |
33 | | - static class TestSubscription { |
34 | | - private String id; |
35 | | - private String topic; |
| 30 | + static class Person { |
| 31 | + private String name; |
| 32 | + private int age; |
36 | 33 | private boolean active; |
37 | 34 | } |
38 | 35 |
|
39 | | - /** |
40 | | - * Test class using Lombok @Builder annotation. This simulates the SubscriptionProperties class |
41 | | - * mentioned in the issue. |
42 | | - */ |
| 36 | + /** Test class using Lombok @Builder annotation. */ |
43 | 37 | @Builder |
44 | 38 | @Getter |
45 | | - static class TestSubscriptionProperties { |
46 | | - private String endpoint; |
47 | | - private int maxRetries; |
48 | | - private long timeout; |
| 39 | + static class Cat { |
| 40 | + private String name; |
| 41 | + private String breed; |
| 42 | + private int age; |
49 | 43 | } |
50 | 44 |
|
51 | 45 | /** Test class using Lombok @Value annotation for immutability. */ |
52 | 46 | @Value |
53 | 47 | @Builder |
54 | | - static class TestImmutableSubscription { |
55 | | - String id; |
56 | | - String topic; |
57 | | - boolean active; |
| 48 | + static class Dog { |
| 49 | + String name; |
| 50 | + String breed; |
| 51 | + int weight; |
58 | 52 | } |
59 | 53 |
|
60 | 54 | @Test |
61 | 55 | @DisplayName("When Using Getter And Setter Then Lombok Processing Works") |
62 | 56 | void testGetterSetterProcessing() { |
63 | 57 | // Given |
64 | | - TestSubscription subscription = new TestSubscription(); |
| 58 | + Person person = new Person(); |
65 | 59 |
|
66 | 60 | // When |
67 | | - subscription.setId("sub-123"); |
68 | | - subscription.setTopic("xapi-events"); |
69 | | - subscription.setActive(true); |
| 61 | + person.setName("John Doe"); |
| 62 | + person.setAge(30); |
| 63 | + person.setActive(true); |
70 | 64 |
|
71 | 65 | // Then |
72 | | - assertThat(subscription.getId(), is("sub-123")); |
73 | | - assertThat(subscription.getTopic(), is("xapi-events")); |
74 | | - assertThat(subscription.isActive(), is(true)); |
| 66 | + assertThat(person.getName(), is("John Doe")); |
| 67 | + assertThat(person.getAge(), is(30)); |
| 68 | + assertThat(person.isActive(), is(true)); |
75 | 69 | } |
76 | 70 |
|
77 | 71 | @Test |
78 | 72 | @DisplayName("When Using Builder Then Lombok Processing Works") |
79 | 73 | void testBuilderProcessing() { |
80 | 74 | // When |
81 | | - TestSubscriptionProperties properties = |
82 | | - TestSubscriptionProperties.builder() |
83 | | - .endpoint("https://example.com/webhook") |
84 | | - .maxRetries(3) |
85 | | - .timeout(5000L) |
86 | | - .build(); |
| 75 | + Cat cat = Cat.builder().name("Whiskers").breed("Siamese").age(3).build(); |
87 | 76 |
|
88 | 77 | // Then |
89 | | - assertThat(properties, is(notNullValue())); |
90 | | - assertThat(properties.getEndpoint(), is("https://example.com/webhook")); |
91 | | - assertThat(properties.getMaxRetries(), is(3)); |
92 | | - assertThat(properties.getTimeout(), is(5000L)); |
| 78 | + assertThat(cat, is(notNullValue())); |
| 79 | + assertThat(cat.getName(), is("Whiskers")); |
| 80 | + assertThat(cat.getBreed(), is("Siamese")); |
| 81 | + assertThat(cat.getAge(), is(3)); |
93 | 82 | } |
94 | 83 |
|
95 | 84 | @Test |
96 | 85 | @DisplayName("When Using Value Then Lombok Processing Works") |
97 | 86 | void testValueProcessing() { |
98 | 87 | // When |
99 | | - TestImmutableSubscription subscription = |
100 | | - TestImmutableSubscription.builder() |
101 | | - .id("sub-456") |
102 | | - .topic("xapi-statements") |
103 | | - .active(false) |
104 | | - .build(); |
| 88 | + Dog dog = Dog.builder().name("Buddy").breed("Golden Retriever").weight(65).build(); |
105 | 89 |
|
106 | 90 | // Then |
107 | | - assertThat(subscription, is(notNullValue())); |
108 | | - assertThat(subscription.getId(), is("sub-456")); |
109 | | - assertThat(subscription.getTopic(), is("xapi-statements")); |
110 | | - assertThat(subscription.isActive(), is(false)); |
| 91 | + assertThat(dog, is(notNullValue())); |
| 92 | + assertThat(dog.getName(), is("Buddy")); |
| 93 | + assertThat(dog.getBreed(), is("Golden Retriever")); |
| 94 | + assertThat(dog.getWeight(), is(65)); |
111 | 95 | } |
112 | 96 | } |
0 commit comments