mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-28 12:22:28 +00:00
deps: Refactor dependencies (#3224)
* remove spring dep move junit, logging, mockito under dep mgmt * upgrade anti-corruption-layer deps * async method invocation * balking, bloc * bridge to bytecode * caching * callback - cqrs * component - health check * hexagonal - metadata mapping * rest of the patterns * remove checkstyle, take spotless into use
This commit is contained in:
@@ -33,42 +33,41 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
class RegisterWorkerFormTest {
|
||||
|
||||
private RegisterWorkerForm registerWorkerForm;
|
||||
private RegisterWorkerForm registerWorkerForm;
|
||||
|
||||
@Test
|
||||
void submitSuccessfully() {
|
||||
// Ensure the worker is null initially
|
||||
registerWorkerForm = new RegisterWorkerForm("John Doe", "Engineer", LocalDate.of(1990, 1, 1));
|
||||
@Test
|
||||
void submitSuccessfully() {
|
||||
// Ensure the worker is null initially
|
||||
registerWorkerForm = new RegisterWorkerForm("John Doe", "Engineer", LocalDate.of(1990, 1, 1));
|
||||
|
||||
assertNull(registerWorkerForm.worker);
|
||||
assertNull(registerWorkerForm.worker);
|
||||
|
||||
// Submit the form
|
||||
registerWorkerForm.submit();
|
||||
// Submit the form
|
||||
registerWorkerForm.submit();
|
||||
|
||||
// Verify that the worker is not null after submission
|
||||
assertNotNull(registerWorkerForm.worker);
|
||||
// Verify that the worker is not null after submission
|
||||
assertNotNull(registerWorkerForm.worker);
|
||||
|
||||
// Verify that the worker's properties are set correctly
|
||||
assertEquals("John Doe", registerWorkerForm.worker.getName());
|
||||
assertEquals("Engineer", registerWorkerForm.worker.getOccupation());
|
||||
assertEquals(LocalDate.of(1990, 1, 1), registerWorkerForm.worker.getDateOfBirth());
|
||||
}
|
||||
// Verify that the worker's properties are set correctly
|
||||
assertEquals("John Doe", registerWorkerForm.worker.getName());
|
||||
assertEquals("Engineer", registerWorkerForm.worker.getOccupation());
|
||||
assertEquals(LocalDate.of(1990, 1, 1), registerWorkerForm.worker.getDateOfBirth());
|
||||
}
|
||||
|
||||
@Test
|
||||
void submitWithErrors() {
|
||||
// Set up the worker with a notification containing errors
|
||||
registerWorkerForm = new RegisterWorkerForm(null, null, null);
|
||||
@Test
|
||||
void submitWithErrors() {
|
||||
// Set up the worker with a notification containing errors
|
||||
registerWorkerForm = new RegisterWorkerForm(null, null, null);
|
||||
|
||||
// Submit the form
|
||||
registerWorkerForm.submit();
|
||||
// Submit the form
|
||||
registerWorkerForm.submit();
|
||||
|
||||
// Verify that the worker's properties remain unchanged
|
||||
assertNull(registerWorkerForm.worker.getName());
|
||||
assertNull(registerWorkerForm.worker.getOccupation());
|
||||
assertNull(registerWorkerForm.worker.getDateOfBirth());
|
||||
|
||||
// Verify the presence of errors
|
||||
assertEquals(registerWorkerForm.worker.getNotification().getErrors().size(), 4);
|
||||
}
|
||||
// Verify that the worker's properties remain unchanged
|
||||
assertNull(registerWorkerForm.worker.getName());
|
||||
assertNull(registerWorkerForm.worker.getOccupation());
|
||||
assertNull(registerWorkerForm.worker.getDateOfBirth());
|
||||
|
||||
// Verify the presence of errors
|
||||
assertEquals(registerWorkerForm.worker.getNotification().getErrors().size(), 4);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user