use of com.izforge.izpack.api.installer.DataValidator in project robozonky by RoboZonky.
the class ZonkoidSettingsValidatorTest method zonkoidMissing.
@Test
void zonkoidMissing() {
// execute SUT
final DataValidator validator = new ZonkoidSettingsValidator(Optional::empty);
final DataValidator.Status result = validator.validateData(mock(InstallData.class));
// run test
assertThat(result).isEqualTo(DataValidator.Status.ERROR);
}
use of com.izforge.izpack.api.installer.DataValidator in project robozonky by RoboZonky.
the class EmailSettingsValidatorTest method messages.
@Test
void messages() {
final DataValidator validator = new EmailSettingsValidator();
assertSoftly(softly -> {
softly.assertThat(validator.getDefaultAnswer()).isFalse();
softly.assertThat(validator.getWarningMessageId()).isNotEmpty();
softly.assertThat(validator.getErrorMessageId()).isNotEmpty();
softly.assertThat(validator.getErrorMessageId()).isNotEqualTo(validator.getWarningMessageId());
});
}
use of com.izforge.izpack.api.installer.DataValidator in project robozonky by RoboZonky.
the class EmailSettingsValidatorTest method mailFailed.
@Test
void mailFailed() {
final InstallData data = mock(InstallData.class);
when(data.getVariable(eq(Variables.SMTP_PORT.getKey()))).thenReturn(String.valueOf(EMAIL.getSmtp().getPort()));
when(data.getVariable(eq(Variables.SMTP_HOSTNAME.getKey()))).thenReturn(String.valueOf(EMAIL.getSmtp().getBindTo()));
when(data.getVariable(eq(Variables.SMTP_USERNAME.getKey()))).thenReturn("sender@server.cz");
when(data.getVariable(eq(Variables.SMTP_PASSWORD.getKey()))).thenReturn(UUID.randomUUID().toString());
final DataValidator validator = new EmailSettingsValidator();
final DataValidator.Status result = validator.validateData(data);
assertThat(result).isEqualTo(DataValidator.Status.WARNING);
assertThat(EMAIL.getReceivedMessages()).hasSize(0);
}
use of com.izforge.izpack.api.installer.DataValidator in project robozonky by RoboZonky.
the class EmailSettingsValidatorTest method mailSent.
@Test
void mailSent() {
final InstallData data = mock(InstallData.class);
when(data.getVariable(eq(Variables.ZONKY_USERNAME.getKey()))).thenReturn("someone@somewhere.cz");
when(data.getVariable(eq(Variables.SMTP_PORT.getKey()))).thenReturn(String.valueOf(EMAIL.getSmtp().getPort()));
when(data.getVariable(eq(Variables.SMTP_HOSTNAME.getKey()))).thenReturn(String.valueOf(EMAIL.getSmtp().getBindTo()));
when(data.getVariable(eq(Variables.SMTP_TO.getKey()))).thenReturn("recipient@server.cz");
when(data.getVariable(eq(Variables.SMTP_USERNAME.getKey()))).thenReturn("sender@server.cz");
when(data.getVariable(eq(Variables.SMTP_PASSWORD.getKey()))).thenReturn(UUID.randomUUID().toString());
final DataValidator validator = new EmailSettingsValidator();
final DataValidator.Status result = validator.validateData(data);
assertThat(result).isEqualTo(DataValidator.Status.OK);
}
use of com.izforge.izpack.api.installer.DataValidator in project robozonky by RoboZonky.
the class StrategySettingsValidatorTest method fileOk.
@Test
void fileOk() throws IOException {
final File f = File.createTempFile("robozonky-", ".cfg");
final InstallData d = StrategySettingsValidatorTest.mockInstallData(f);
// execute sut
final DataValidator validator = new StrategySettingsValidator();
final DataValidator.Status result = validator.validateData(d);
// execute test
assertThat(result).isEqualTo(DataValidator.Status.OK);
assertThat(RoboZonkyInstallerListener.INSTALL_PATH).isNotNull();
}
Aggregations