Search in sources :

Example 26 with InstallData

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

the class RoboZonkyInstallerListenerTest method progressWindows.

@Test
void progressWindows() {
    final ProgressListener progress = mock(ProgressListener.class);
    final InstallData localData = RoboZonkyInstallerListenerTest.mockData();
    // execute SUT
    RoboZonkyInstallerListener.setInstallData(localData);
    final InstallerListener listener = new RoboZonkyInstallerListener(RoboZonkyInstallerListener.OS.WINDOWS);
    listener.afterPacks(Collections.emptyList(), progress);
    // test
    assertSoftly(softly -> {
        softly.assertThat(new File(RoboZonkyInstallerListener.INSTALL_PATH, "logback.xml")).exists();
        softly.assertThat(new File(RoboZonkyInstallerListener.INSTALL_PATH, "robozonky.properties")).exists();
        softly.assertThat(new File(RoboZonkyInstallerListener.INSTALL_PATH, "robozonky.cli")).exists();
        softly.assertThat(new File(RoboZonkyInstallerListener.INSTALL_PATH, "robozonky-exec.sh")).doesNotExist();
        softly.assertThat(new File(RoboZonkyInstallerListener.INSTALL_PATH, "robozonky-exec.bat")).exists().has(new Condition<>(File::canExecute, "Is executable"));
        softly.assertThat(new File(RoboZonkyInstallerListener.INSTALL_PATH, "robozonky-systemd.service")).doesNotExist();
        softly.assertThat(new File(RoboZonkyInstallerListener.INSTALL_PATH, "robozonky-upstart.conf")).doesNotExist();
        softly.assertThat(RoboZonkyInstallerListener.CLI_CONFIG_FILE).exists();
    });
    verify(progress, times(1)).startAction(anyString(), anyInt());
    verify(progress, times(7)).nextStep(anyString(), anyInt(), eq(1));
    verify(progress, times(1)).stopAction();
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData) ProgressListener(com.izforge.izpack.api.event.ProgressListener) InstallerListener(com.izforge.izpack.api.event.InstallerListener) File(java.io.File) Test(org.junit.jupiter.api.Test) AbstractRoboZonkyTest(com.github.robozonky.test.AbstractRoboZonkyTest)

Example 27 with InstallData

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

the class RoboZonkyInstallerListenerTest method coreWithoutKeyStore.

@Test
void coreWithoutKeyStore() {
    // prepare
    final InstallData localData = RoboZonkyInstallerListenerTest.mockData();
    when(localData.getVariable(Variables.IS_ZONKOID_ENABLED.getKey())).thenReturn("true");
    when(localData.getVariable(Variables.ZONKOID_TOKEN.getKey())).thenReturn("123456");
    RoboZonkyInstallerListener.setInstallData(localData);
    // execute SUT
    final CommandLinePart clp = new RoboZonkyInstallerListener().prepareCore(null);
    // test
    assertSoftly(softly -> {
        softly.assertThat(clp.getOptions()).doesNotContainKey("-d").doesNotContainKey("-r").doesNotContainKey("-g");
        softly.assertThat(clp.getOptions().get("-u")).containsOnly(localData.getVariable(Variables.ZONKY_USERNAME.getKey()));
        softly.assertThat(clp.getOptions().get("-x")).containsOnly("zonkoid:" + localData.getVariable(Variables.ZONKOID_TOKEN.getKey()));
        softly.assertThat(clp.getOptions().get("-p")).containsOnly(data.getVariable(Variables.ZONKY_PASSWORD.getKey()));
    });
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData) Test(org.junit.jupiter.api.Test) AbstractRoboZonkyTest(com.github.robozonky.test.AbstractRoboZonkyTest)

Example 28 with InstallData

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

the class RoboZonkyInstallerListenerTest method coreWithTweaks.

@Test
void coreWithTweaks() {
    // prepare
    final InstallData localData = RoboZonkyInstallerListenerTest.mockData();
    when(localData.getVariable(Variables.IS_DRY_RUN.getKey())).thenReturn("true");
    when(localData.getVariable(Variables.IS_ZONKOID_ENABLED.getKey())).thenReturn("true");
    when(localData.getVariable(Variables.ZONKOID_TOKEN.getKey())).thenReturn("123456");
    RoboZonkyInstallerListener.setInstallData(localData);
    // execute SUT
    final CommandLinePart clp = new RoboZonkyInstallerListener().prepareCore();
    // test
    assertSoftly(softly -> {
        softly.assertThat(clp.getOptions()).containsKey("-d").containsKey("-x");
        softly.assertThat(clp.getOptions().get("-p")).containsOnly(String.valueOf(RoboZonkyInstallerListener.KEYSTORE_PASSWORD));
    });
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData) Test(org.junit.jupiter.api.Test) AbstractRoboZonkyTest(com.github.robozonky.test.AbstractRoboZonkyTest)

Example 29 with InstallData

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

the class RoboZonkyInstallerListenerTest method emailDisabled.

@Test
void emailDisabled() {
    // prepare
    final InstallData data = RoboZonkyInstallerListenerTest.mockBaseData();
    when(data.getVariable(Variables.IS_EMAIL_ENABLED.getKey())).thenReturn("false");
    RoboZonkyInstallerListener.setInstallData(data);
    // execute SUT
    final CommandLinePart clp = new RoboZonkyInstallerListener().prepareEmailConfiguration();
    // test
    assertSoftly(softly -> {
        softly.assertThat(clp.getProperties()).isEmpty();
        softly.assertThat(RoboZonkyInstallerListener.EMAIL_CONFIG_FILE).doesNotExist();
    });
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData) Test(org.junit.jupiter.api.Test) AbstractRoboZonkyTest(com.github.robozonky.test.AbstractRoboZonkyTest)

Example 30 with InstallData

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

the class RoboZonkyInstallerListenerTest method strategyUrl.

@Test
void strategyUrl() {
    // prepare
    final InstallData localData = RoboZonkyInstallerListenerTest.mockBaseData();
    when(localData.getVariable(Variables.STRATEGY_TYPE.getKey())).thenReturn("url");
    when(localData.getVariable(Variables.STRATEGY_SOURCE.getKey())).thenReturn("http://www.robozonky.cz");
    RoboZonkyInstallerListener.setInstallData(localData);
    // execute SUT
    final CommandLinePart clp = new RoboZonkyInstallerListener().prepareStrategy();
    // test
    assertSoftly(softly -> {
        softly.assertThat(clp.getOptions()).containsKey("-s");
        final File newStrat = new File(data.getVariable(Variables.INSTALL_PATH.getKey()), "robozonky-strategy.cfg");
        softly.assertThat(newStrat).doesNotExist();
    });
}
Also used : InstallData(com.izforge.izpack.api.data.InstallData) File(java.io.File) Test(org.junit.jupiter.api.Test) AbstractRoboZonkyTest(com.github.robozonky.test.AbstractRoboZonkyTest)

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