Search in sources :

Example 6 with DataValidator

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);
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData) Optional(java.util.Optional) DataValidator(com.izforge.izpack.api.installer.DataValidator) Test(org.junit.jupiter.api.Test)

Example 7 with DataValidator

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());
    });
}
Also used : DataValidator(com.izforge.izpack.api.installer.DataValidator) Test(org.junit.jupiter.api.Test) ServerSetupTest(com.icegreen.greenmail.util.ServerSetupTest)

Example 8 with DataValidator

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);
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData) DataValidator(com.izforge.izpack.api.installer.DataValidator) Test(org.junit.jupiter.api.Test) ServerSetupTest(com.icegreen.greenmail.util.ServerSetupTest)

Example 9 with DataValidator

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);
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData) DataValidator(com.izforge.izpack.api.installer.DataValidator) Test(org.junit.jupiter.api.Test) ServerSetupTest(com.icegreen.greenmail.util.ServerSetupTest)

Example 10 with DataValidator

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();
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData) DataValidator(com.izforge.izpack.api.installer.DataValidator) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

DataValidator (com.izforge.izpack.api.installer.DataValidator)14 Test (org.junit.jupiter.api.Test)14 InstallData (com.izforge.izpack.api.data.InstallData)10 File (java.io.File)5 ServerSetupTest (com.icegreen.greenmail.util.ServerSetupTest)3 ConfirmationProvider (com.github.robozonky.api.confirmations.ConfirmationProvider)2 Optional (java.util.Optional)1