bael-2195 lombok builder default
This commit is contained in:
parent
90978bf35e
commit
ad0eb1ee7d
|
@ -59,6 +59,7 @@
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
||||||
|
<outputDirectory>${project.build.directory}/delombok</outputDirectory>
|
||||||
<addOutputDirectory>false</addOutputDirectory>
|
<addOutputDirectory>false</addOutputDirectory>
|
||||||
<formatPreferences>
|
<formatPreferences>
|
||||||
<javaLangAsFQN>skip</javaLangAsFQN>
|
<javaLangAsFQN>skip</javaLangAsFQN>
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.baeldung.lombok.builder.defaultvalue;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Builder(toBuilder = true)
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class Pojo {
|
||||||
|
private String name = "foo";
|
||||||
|
private boolean original = true;
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.baeldung.lombok.builder.defaultvalue;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class BuilderWithDefaultValueUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenBuilderWithDefaultValue_ThanDefaultValueIsPresent() {
|
||||||
|
Pojo build = new Pojo().toBuilder()
|
||||||
|
.build();
|
||||||
|
Assert.assertEquals("foo", build.getName());
|
||||||
|
Assert.assertTrue(build.isOriginal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenBuilderWithDefaultValue_NoArgsWorksAlso() {
|
||||||
|
Pojo build = new Pojo().toBuilder()
|
||||||
|
.build();
|
||||||
|
Pojo pojo = new Pojo();
|
||||||
|
Assert.assertEquals(build.getName(), pojo.getName());
|
||||||
|
Assert.assertTrue(build.isOriginal() == pojo.isOriginal());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue