Search in sources :

Example 21 with InstallData

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

the class ZonkySettingsValidatorTest method properLogin.

@Test
void properLogin() {
    // mock data
    final ZonkyApiToken token = mock(ZonkyApiToken.class);
    final OAuth oauth = mock(OAuth.class);
    when(oauth.login(any(), any())).thenReturn(token);
    final Zonky zonky = mock(Zonky.class);
    final ApiProvider provider = mockApiProvider(oauth, token, zonky);
    // execute SUT
    final ZonkySettingsValidator validator = new ZonkySettingsValidator(() -> provider);
    final InstallData d = ZonkySettingsValidatorTest.mockInstallData();
    final DataValidator.Status result = validator.validateData(d);
    // test
    assertThat(result).isEqualTo(DataValidator.Status.OK);
    verify(oauth).login(eq(ZonkySettingsValidatorTest.USERNAME), eq(ZonkySettingsValidatorTest.PASSWORD.toCharArray()));
    verify(zonky).logout();
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData) DataValidator(com.izforge.izpack.api.installer.DataValidator) ApiProvider(com.github.robozonky.common.remote.ApiProvider) ZonkyApiToken(com.github.robozonky.api.remote.entities.ZonkyApiToken) OAuth(com.github.robozonky.common.remote.OAuth) Zonky(com.github.robozonky.common.remote.Zonky) Test(org.junit.jupiter.api.Test)

Example 22 with InstallData

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

the class ZonkySettingsValidatorTest method error.

@Test
void error() {
    // mock data
    final OAuth oauth = mock(OAuth.class);
    when(oauth.login(any(), any())).thenThrow(new ServerErrorException(Response.Status.INTERNAL_SERVER_ERROR));
    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.ERROR);
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData) DataValidator(com.izforge.izpack.api.installer.DataValidator) ApiProvider(com.github.robozonky.common.remote.ApiProvider) ServerErrorException(javax.ws.rs.ServerErrorException) OAuth(com.github.robozonky.common.remote.OAuth) Test(org.junit.jupiter.api.Test)

Example 23 with InstallData

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

the class InstallDirValidatorTest method mockBaseData.

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

Example 24 with InstallData

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

the class InstallDirValidatorTest method correctDirLinux.

@Test
void correctDirLinux() {
    final InstallData d = InstallDirValidatorTest.mockBaseData("/home/lpetrovi/RoboZonky/4.0.0-SNAPSHOT");
    final InstallDirValidator v = new InstallDirValidator();
    assertThat(v.validateData(d)).isEqualTo(DataValidator.Status.OK);
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData) Test(org.junit.jupiter.api.Test)

Example 25 with InstallData

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

the class InstallDirValidatorTest method correctDirWindows.

@Test
void correctDirWindows() {
    final InstallData d = InstallDirValidatorTest.mockBaseData("C:\\RoboZonky\\4.0.0-SNAPSHOT");
    final InstallDirValidator v = new InstallDirValidator();
    assertThat(v.validateData(d)).isEqualTo(DataValidator.Status.OK);
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData) 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