* BAEL-5138: Implementation code for Lombok @With Methods * BAEL-5138: Implementation code for Lombok @With Methods * Fixed a type issue in HolderUnitTest * Removed a constructor from User to avoid confusion with article
22 lines
621 B
Java
22 lines
621 B
Java
package com.baeldung.lombok.with;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
|
|
public class ImprovedUserUnitTest {
|
|
|
|
@Test
|
|
public void whenUsernameNull_thenException() {
|
|
ImprovedUser user = new ImprovedUser("testuser", "test@mail.com");
|
|
|
|
assertThrows(NullPointerException.class, () -> user.withUsername(null));
|
|
}
|
|
|
|
@Test
|
|
public void whenEmailNull_thenException() {
|
|
ImprovedUser user = new ImprovedUser("testuser", "test@mail.com");
|
|
|
|
assertThrows(NullPointerException.class, () -> user.withEmailAddress(null));
|
|
}
|
|
} |