A new configuration setup now allows specifying a path for database properties via command-line arguments during application startup. This update also changes the call signature for `DatabaseConnection.initialize()` method to accept a path argument. Similarly, methods in `PropertiesLoader`, `PropertiesWriter`, and `MailSettings` classes were also updated to use the specified path when working with properties files. The `TestForm` class's tests were updated accordingly to handle these changes.
40 lines
1.6 KiB
Java
40 lines
1.6 KiB
Java
import com.alttd.forms.contact.ContactFormData;
|
|
import com.alttd.forms.contact.StoreFormQuery;
|
|
import com.alttd.forms.database.DatabaseConnection;
|
|
import com.alttd.forms.form.Form;
|
|
import com.alttd.forms.verify_mail.FormQuery;
|
|
import org.junit.jupiter.api.Assertions;
|
|
import org.junit.jupiter.api.BeforeAll;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import java.util.Optional;
|
|
|
|
public class TestForm {
|
|
|
|
private static int code;
|
|
|
|
@BeforeAll
|
|
public static void testInsert() {
|
|
Assertions.assertDoesNotThrow(() -> DatabaseConnection.initialize());
|
|
StoreFormQuery storeFormQuery = new StoreFormQuery();
|
|
ContactFormData contactFormData = new ContactFormData("akastijn", "akastijn@alttd.com", "This is a test question.");
|
|
storeFormQuery.storeFormForVerificationCode("akastijn@alttd.com", contactFormData).
|
|
thenAccept(code -> {
|
|
TestForm.code = code;
|
|
Assertions.assertTrue(code > 999 && code < 10000);
|
|
})
|
|
.exceptionally(throwable -> Assertions.fail());
|
|
}
|
|
|
|
@Test
|
|
public void testRetrieveForm() {
|
|
Assertions.assertDoesNotThrow(() -> DatabaseConnection.initialize());
|
|
new FormQuery().getFormForCode(String.valueOf(code), "akastijn@alttd.com").thenAccept(result -> {
|
|
Assertions.assertTrue(result.failReason().isEmpty());
|
|
Optional<Form> optionalForm = result.form();
|
|
Assertions.assertTrue(optionalForm.isPresent());
|
|
Form form = optionalForm.get();
|
|
Assertions.assertInstanceOf(ContactFormData.class, form);
|
|
});
|
|
}
|
|
} |