Merge pull request #5479 from Vizsoro/bael-2195
bael-2195 lombok builder default
This commit is contained in:
commit
1bcfbed484
|
@ -59,6 +59,7 @@
|
|||
</goals>
|
||||
<configuration>
|
||||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
||||
<outputDirectory>${project.build.directory}/delombok</outputDirectory>
|
||||
<addOutputDirectory>false</addOutputDirectory>
|
||||
<formatPreferences>
|
||||
<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