Search in sources :

Example 11 with InstallData

use of com.izforge.izpack.api.data.InstallData 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 12 with InstallData

use of com.izforge.izpack.api.data.InstallData 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 13 with InstallData

use of com.izforge.izpack.api.data.InstallData in project robozonky by RoboZonky.

the class InstallDirValidatorTest method wrongDir.

@Test
void wrongDir() {
    final InstallData d = InstallDirValidatorTest.mockBaseData("C:\\Program Files\\RoboZonky\\4.0.0-SNAPSHOT");
    final InstallDirValidator v = new InstallDirValidator();
    assertThat(v.validateData(d)).isEqualTo(DataValidator.Status.ERROR);
    assertThat(v.getErrorMessageId()).isNotEmpty();
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData) Test(org.junit.jupiter.api.Test)

Example 14 with InstallData

use of com.izforge.izpack.api.data.InstallData in project robozonky by RoboZonky.

the class RoboZonkyInstallerListenerTest method mockData.

private static InstallData mockData() {
    final InstallData data = RoboZonkyInstallerListenerTest.mockBaseData();
    when(data.getVariable(Variables.STRATEGY_TYPE.getKey())).thenReturn("file");
    when(data.getVariable(Variables.STRATEGY_SOURCE.getKey())).thenReturn(RoboZonkyInstallerListenerTest.newFile(true).getAbsolutePath());
    when(data.getVariable(Variables.ZONKY_USERNAME.getKey())).thenReturn(RoboZonkyInstallerListenerTest.ZONKY_USERNAME);
    when(data.getVariable(Variables.ZONKY_PASSWORD.getKey())).thenReturn(RoboZonkyInstallerListenerTest.ZONKY_PASSWORD);
    when(data.getVariable(Variables.IS_EMAIL_ENABLED.getKey())).thenReturn("true");
    when(data.getVariable(Variables.SMTP_HOSTNAME.getKey())).thenReturn("127.0.0.1");
    when(data.getVariable(Variables.SMTP_TO.getKey())).thenReturn("recipient@server.cz");
    when(data.getVariable(Variables.SMTP_USERNAME.getKey())).thenReturn("sender@server.cz");
    when(data.getVariable(Variables.SMTP_PASSWORD.getKey())).thenReturn(UUID.randomUUID().toString());
    return data;
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData)

Example 15 with InstallData

use of com.izforge.izpack.api.data.InstallData in project robozonky by RoboZonky.

the class RoboZonkyInstallerListenerTest method mockBaseData.

private static InstallData mockBaseData() {
    final InstallData data = mock(InstallData.class);
    when(data.getVariable(Variables.INSTALL_PATH.getKey())).thenReturn(new File("target/install").getAbsolutePath());
    return data;
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData) File(java.io.File)

Aggregations

InstallData (com.izforge.izpack.api.data.InstallData)30 Test (org.junit.jupiter.api.Test)22 DataValidator (com.izforge.izpack.api.installer.DataValidator)12 File (java.io.File)10 AbstractRoboZonkyTest (com.github.robozonky.test.AbstractRoboZonkyTest)6 ApiProvider (com.github.robozonky.common.remote.ApiProvider)3 OAuth (com.github.robozonky.common.remote.OAuth)3 ConfirmationProvider (com.github.robozonky.api.confirmations.ConfirmationProvider)2 ServerSetupTest (com.icegreen.greenmail.util.ServerSetupTest)2 ZonkyApiToken (com.github.robozonky.api.remote.entities.ZonkyApiToken)1 Zonky (com.github.robozonky.common.remote.Zonky)1 InstallerListener (com.izforge.izpack.api.event.InstallerListener)1 ProgressListener (com.izforge.izpack.api.event.ProgressListener)1 ServerErrorException (javax.ws.rs.ServerErrorException)1