From 3a026972f9335362e9d074cfdc4bcb905435e342 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Fri, 12 Apr 2024 15:55:26 +0200 Subject: [PATCH] Add lombok Data object --- pom.xml | 43 ++++++++++++++++++- .../java/org/simplify4u/test/LombokData.java | 31 +++++++++++++ .../org/simplify4u/test/LombokDataTest.java | 42 ++++++++++++++++++ 3 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 src/main/java/org/simplify4u/test/LombokData.java create mode 100644 src/test/java/org/simplify4u/test/LombokDataTest.java diff --git a/pom.xml b/pom.xml index 635bbbe..76b2669 100644 --- a/pom.xml +++ b/pom.xml @@ -51,15 +51,54 @@ false + + + + org.junit + junit-bom + 5.10.1 + import + pom + + + org.projectlombok + lombok + 1.18.32 + + + + org.junit.jupiter - junit-jupiter - 5.10.2 + junit-jupiter-api test + + org.projectlombok + lombok + provided + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + org.projectlombok + lombok + + + + + + + diff --git a/src/main/java/org/simplify4u/test/LombokData.java b/src/main/java/org/simplify4u/test/LombokData.java new file mode 100644 index 0000000..c89fe45 --- /dev/null +++ b/src/main/java/org/simplify4u/test/LombokData.java @@ -0,0 +1,31 @@ +/* + * Copyright 2021 Slawomir Jaranowski + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.simplify4u.test; + +import lombok.Builder; +import lombok.Data; + +/** + * lombok Data with private fields + */ +@Data +@Builder +public class LombokData { + private String test1; + + private String test2; +} diff --git a/src/test/java/org/simplify4u/test/LombokDataTest.java b/src/test/java/org/simplify4u/test/LombokDataTest.java new file mode 100644 index 0000000..3522206 --- /dev/null +++ b/src/test/java/org/simplify4u/test/LombokDataTest.java @@ -0,0 +1,42 @@ +/* + * Copyright 2021 Slawomir Jaranowski + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.simplify4u.test; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class LombokDataTest { + + @Test + void test1() { + LombokData test = LombokData.builder() + .test1("test1") + .build(); + assertNotNull(test); + assertEquals("test1", test.getTest1()); + assertTrue(test.toString().contains("test1")); + + + LombokData test2 = LombokData.builder() + .test2("test2") + .build(); + + assertNotEquals(test, test2); + } + +} \ No newline at end of file