Search in sources :

Example 6 with InstallData

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

the class ZonkoidSettingsValidatorTest method mockInstallData.

private static InstallData mockInstallData() {
    final InstallData d = mock(InstallData.class);
    when(d.getVariable(Variables.ZONKY_USERNAME.getKey())).thenReturn(ZonkoidSettingsValidatorTest.USER);
    when(d.getVariable(Variables.ZONKOID_TOKEN.getKey())).thenReturn(ZonkoidSettingsValidatorTest.TOKEN);
    return d;
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData)

Example 7 with InstallData

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

the class ZonkoidSettingsValidatorTest method zonkoidProper.

@Test
void zonkoidProper() {
    final ConfirmationProvider cp = mock(ConfirmationProvider.class);
    when(cp.requestConfirmation(any(), anyInt(), anyInt())).thenReturn(true);
    final InstallData d = ZonkoidSettingsValidatorTest.mockInstallData();
    // execute SUT
    final DataValidator validator = new ZonkoidSettingsValidator(() -> Optional.of(cp));
    final DataValidator.Status result = validator.validateData(d);
    // run test
    assertThat(result).isEqualTo(DataValidator.Status.OK);
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData) DataValidator(com.izforge.izpack.api.installer.DataValidator) ConfirmationProvider(com.github.robozonky.api.confirmations.ConfirmationProvider) Test(org.junit.jupiter.api.Test)

Example 8 with InstallData

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

the class ZonkoidSettingsValidatorTest method zonkoidPresentButRejecting.

@Test
void zonkoidPresentButRejecting() {
    final ConfirmationProvider cp = mock(ConfirmationProvider.class);
    when(cp.requestConfirmation(any(), anyInt(), anyInt())).thenReturn(false);
    final InstallData d = ZonkoidSettingsValidatorTest.mockInstallData();
    // execute SUT
    final DataValidator validator = new ZonkoidSettingsValidator(() -> Optional.of(cp));
    final DataValidator.Status result = validator.validateData(d);
    // run test
    assertThat(result).isEqualTo(DataValidator.Status.WARNING);
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData) DataValidator(com.izforge.izpack.api.installer.DataValidator) ConfirmationProvider(com.github.robozonky.api.confirmations.ConfirmationProvider) Test(org.junit.jupiter.api.Test)

Example 9 with InstallData

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

the class ZonkySettingsValidatorTest method mockInstallData.

private static InstallData mockInstallData() {
    final InstallData d = mock(InstallData.class);
    when(d.getVariable(Variables.ZONKY_USERNAME.getKey())).thenReturn(ZonkySettingsValidatorTest.USERNAME);
    when(d.getVariable(Variables.ZONKY_PASSWORD.getKey())).thenReturn(ZonkySettingsValidatorTest.PASSWORD);
    return d;
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData)

Example 10 with InstallData

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

the class ZonkySettingsValidatorTest method warning.

@Test
void warning() {
    // mock data
    final OAuth oauth = mock(OAuth.class);
    when(oauth.login(any(), any())).thenThrow(new IllegalStateException());
    final ApiProvider provider = mockApiProvider(oauth);
    final InstallData d = ZonkySettingsValidatorTest.mockInstallData();
    // execute SUT
    final ZonkySettingsValidator validator = new ZonkySettingsValidator(() -> provider);
    final DataValidator.Status result = validator.validateData(d);
    // test
    assertThat(result).isEqualTo(DataValidator.Status.WARNING);
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData) DataValidator(com.izforge.izpack.api.installer.DataValidator) ApiProvider(com.github.robozonky.common.remote.ApiProvider) OAuth(com.github.robozonky.common.remote.OAuth) Test(org.junit.jupiter.api.Test)

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