mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-23 14:40:49 +08:00
23 lines
632 B
Java
23 lines
632 B
Java
package com.openisle.service;
|
|
|
|
import com.openisle.exception.FieldException;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
class UsernameValidatorTest {
|
|
|
|
@Test
|
|
void rejectsEmptyUsername() {
|
|
UsernameValidator validator = new UsernameValidator();
|
|
assertThrows(FieldException.class, () -> validator.validate(""));
|
|
assertThrows(FieldException.class, () -> validator.validate(null));
|
|
}
|
|
|
|
@Test
|
|
void allowsShortUsername() {
|
|
UsernameValidator validator = new UsernameValidator();
|
|
assertDoesNotThrow(() -> validator.validate("a"));
|
|
}
|
|
}
|