commit
10e7aaed73
|
@ -0,0 +1,18 @@
|
|||
package com.baeldung.lombok.builder;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
|
||||
@Builder(builderMethodName = "internalBuilder")
|
||||
@Getter
|
||||
public class RequiredFieldAnnotation {
|
||||
|
||||
@NonNull
|
||||
String name;
|
||||
String description;
|
||||
|
||||
public static RequiredFieldAnnotationBuilder builder(String name) {
|
||||
return internalBuilder().name(name);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.baeldung.lombok.builder;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class RequiredFieldAnnotationUnitTest {
|
||||
RequiredFieldAnnotation requiredFieldTest;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
requiredFieldTest = RequiredFieldAnnotation.builder("NameField").description("Field Description").build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenBuilderWithRequiredParameter_thenParameterIsPresent() {
|
||||
assertEquals("NameField", requiredFieldTest.getName());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue