Skip to content

Commit dd04a64

Browse files
CopilotthomasturrellCopilot
authored
Fix Lombok annotation processing failure in xapi-model-spring-boot-starter (#456)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: thomasturrell <1552612+thomasturrell@users.noreply.github.com> Co-authored-by: Thomas Turrell-Croft <thomasturrell@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 59c465b commit dd04a64

File tree

3 files changed

+123
-0
lines changed

3 files changed

+123
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Suppress code coverage on Lombok annotations
2+
lombok.addLombokGeneratedAnnotation = true
3+
lombok.builder.className = Builder
4+

xapi-model-spring-boot-starter/pom.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@
3939
<groupId>dev.learning.xapi</groupId>
4040
<artifactId>xapi-model</artifactId>
4141
</dependency>
42+
<dependency>
43+
<groupId>org.projectlombok</groupId>
44+
<artifactId>lombok</artifactId>
45+
<scope>provided</scope>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.springframework.boot</groupId>
49+
<artifactId>spring-boot-starter-test</artifactId>
50+
<scope>test</scope>
51+
</dependency>
4252
</dependencies>
4353

4454
<build>
@@ -47,6 +57,19 @@
4757
<groupId>org.jacoco</groupId>
4858
<artifactId>jacoco-maven-plugin</artifactId>
4959
</plugin>
60+
<plugin>
61+
<groupId>org.apache.maven.plugins</groupId>
62+
<artifactId>maven-compiler-plugin</artifactId>
63+
<configuration>
64+
<annotationProcessorPaths>
65+
<path>
66+
<groupId>org.projectlombok</groupId>
67+
<artifactId>lombok</artifactId>
68+
<version>${lombok.version}</version>
69+
</path>
70+
</annotationProcessorPaths>
71+
</configuration>
72+
</plugin>
5073
</plugins>
5174
</build>
5275

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* Copyright 2016-2025 Berry Cloud Ltd. All rights reserved.
3+
*/
4+
5+
package dev.learning.xapi.autoconfigure.model;
6+
7+
import static org.hamcrest.MatcherAssert.assertThat;
8+
import static org.hamcrest.Matchers.is;
9+
import static org.hamcrest.Matchers.notNullValue;
10+
11+
import lombok.Builder;
12+
import lombok.Getter;
13+
import lombok.Setter;
14+
import lombok.Value;
15+
import org.junit.jupiter.api.DisplayName;
16+
import org.junit.jupiter.api.Test;
17+
18+
/**
19+
* Tests that Lombok annotation processing works correctly with xapi-model-spring-boot-starter. This
20+
* test ensures that third-party projects can use Lombok annotations without additional
21+
* configuration.
22+
*
23+
* @author GitHub Copilot
24+
*/
25+
class LombokProcessingTests {
26+
27+
/** Test class using Lombok @Getter and @Setter annotations. */
28+
@Getter
29+
@Setter
30+
static class Person {
31+
private String name;
32+
private int age;
33+
private boolean active;
34+
}
35+
36+
/** Test class using Lombok @Builder annotation. */
37+
@Builder
38+
@Getter
39+
static class Cat {
40+
private String name;
41+
private String breed;
42+
private int age;
43+
}
44+
45+
/** Test class using Lombok @Value annotation for immutability. */
46+
@Value
47+
@Builder
48+
static class Dog {
49+
String name;
50+
String breed;
51+
int weight;
52+
}
53+
54+
@Test
55+
@DisplayName("When Using Getter And Setter Then Lombok Processing Works")
56+
void testGetterSetterProcessing() {
57+
// Given
58+
Person person = new Person();
59+
60+
// When
61+
person.setName("John Doe");
62+
person.setAge(30);
63+
person.setActive(true);
64+
65+
// Then
66+
assertThat(person.getName(), is("John Doe"));
67+
assertThat(person.getAge(), is(30));
68+
assertThat(person.isActive(), is(true));
69+
}
70+
71+
@Test
72+
@DisplayName("When Using Builder Then Lombok Processing Works")
73+
void testBuilderProcessing() {
74+
// When
75+
Cat cat = Cat.builder().name("Whiskers").breed("Siamese").age(3).build();
76+
77+
// Then
78+
assertThat(cat, is(notNullValue()));
79+
assertThat(cat.getName(), is("Whiskers"));
80+
assertThat(cat.getBreed(), is("Siamese"));
81+
assertThat(cat.getAge(), is(3));
82+
}
83+
84+
@Test
85+
@DisplayName("When Using Value Then Lombok Processing Works")
86+
void testValueProcessing() {
87+
// When
88+
Dog dog = Dog.builder().name("Buddy").breed("Golden Retriever").weight(65).build();
89+
90+
// Then
91+
assertThat(dog, is(notNullValue()));
92+
assertThat(dog.getName(), is("Buddy"));
93+
assertThat(dog.getBreed(), is("Golden Retriever"));
94+
assertThat(dog.getWeight(), is(65));
95+
}
96+
}

0 commit comments

Comments
 (0)