diff --git a/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/m2e/core/ui/preferences/MavenPreferencePage.java b/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/m2e/core/ui/preferences/MavenPreferencePage.java index 357bf9b6b..f64edf81f 100644 --- a/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/m2e/core/ui/preferences/MavenPreferencePage.java +++ b/plugins/org.eclipse.reddeer.eclipse/src/org/eclipse/reddeer/eclipse/m2e/core/ui/preferences/MavenPreferencePage.java @@ -15,6 +15,7 @@ import org.eclipse.reddeer.core.reference.ReferencedComposite; import org.eclipse.reddeer.jface.preference.PreferencePage; import org.eclipse.reddeer.swt.impl.button.CheckBox; +import org.eclipse.reddeer.swt.impl.combo.LabeledCombo; import org.hamcrest.Description; import org.hamcrest.TypeSafeMatcher; @@ -34,6 +35,7 @@ public class MavenPreferencePage extends PreferencePage { private static final String DOWNLOAD_REPO_INDEX_UPDATES_ON_STARTUP="Download repository index updates on startup"; private static final String UPDATE_MAVEN_PROJECTS_ON_STARTUP="Update Maven projects on startup"; private static final String HIDE_FOLDERS_OF_PHYSICALLY_NESTED_MODULES="Hide folders of physically nested modules (experimental)"; + private static final String GLOBAL_UPDATE_POLICY="Global Update Policy:"; /** * Constructs the preference page with "Maven". @@ -67,7 +69,11 @@ public MavenPreferencePage setOffline(boolean check) { * @return true, if is do not auto update deps checked */ public boolean isDoNotAutoUpdateDepsChecked() { - return new CheckBox(this, MavenPreferencePage.DO_NOT_AUTO_UPDATE_DEPS).isChecked(); + try { + return new CheckBox(this, MavenPreferencePage.DO_NOT_AUTO_UPDATE_DEPS).isChecked(); + } catch (org.eclipse.reddeer.core.exception.CoreLayerException e) { // there is no CheckBox "Do Not Auto update..." starting 2023-09-M3 Eclipse + return "Never".equals(getGlobalUpdatePolicy()); + } } /** @@ -76,7 +82,15 @@ public boolean isDoNotAutoUpdateDepsChecked() { * @param check the new do not auto update deps */ public MavenPreferencePage setDoNotAutoUpdateDeps(boolean check) { - new CheckBox(this, MavenPreferencePage.DO_NOT_AUTO_UPDATE_DEPS).toggle(check); + try { + new CheckBox(this, MavenPreferencePage.DO_NOT_AUTO_UPDATE_DEPS).toggle(check); + } catch (org.eclipse.reddeer.core.exception.CoreLayerException e) { // there is no CheckBox "Do Not Auto update..." starting 2023-09-M3 Eclipse + if (check) { + setGlobalUpdatePolicy("Never"); + } else { + setGlobalUpdatePolicy("Default"); + } + } return this; } @@ -212,4 +226,23 @@ public MavenPreferencePage setHideFoldersOfPhysicalyNestedModules(boolean check) new CheckBox(this, MavenPreferencePage.HIDE_FOLDERS_OF_PHYSICALLY_NESTED_MODULES).toggle(check); return this; } + + /** + * Returns String with selected Global Update Policy combo item . + * + * @return selected Global Update Policy combo item + */ + public String getGlobalUpdatePolicy() { + return new LabeledCombo(MavenPreferencePage.GLOBAL_UPDATE_POLICY).getSelection(); + } + + /** + * Sets Global Update Policy . + * + * @param updatePolicyType type of Global Update Policy to select + */ + public MavenPreferencePage setGlobalUpdatePolicy(String updatePolicyType) { + new LabeledCombo(MavenPreferencePage.GLOBAL_UPDATE_POLICY).setSelection(updatePolicyType); + return this; + } } diff --git a/tests/org.eclipse.reddeer.eclipse.test/src/org/eclipse/reddeer/eclipse/test/m2e/core/ui/preferences/MavenPreferencePageTest.java b/tests/org.eclipse.reddeer.eclipse.test/src/org/eclipse/reddeer/eclipse/test/m2e/core/ui/preferences/MavenPreferencePageTest.java index a08ec11e1..138088b58 100644 --- a/tests/org.eclipse.reddeer.eclipse.test/src/org/eclipse/reddeer/eclipse/test/m2e/core/ui/preferences/MavenPreferencePageTest.java +++ b/tests/org.eclipse.reddeer.eclipse.test/src/org/eclipse/reddeer/eclipse/test/m2e/core/ui/preferences/MavenPreferencePageTest.java @@ -27,14 +27,33 @@ public class MavenPreferencePageTest { private WorkbenchPreferenceDialog preferencesDialog = new WorkbenchPreferenceDialog(); private MavenPreferencePage mavenPreferencePage = new MavenPreferencePage(preferencesDialog); + + @Test + public void checkGlobalUpdatePolicy() { + preferencesDialog.open(); + preferencesDialog.select(mavenPreferencePage); + + mavenPreferencePage.setGlobalUpdatePolicy("Always"); + assertTrue("Always".equals(mavenPreferencePage.getGlobalUpdatePolicy())); + mavenPreferencePage.setGlobalUpdatePolicy("Daily"); + assertTrue("Daily".equals(mavenPreferencePage.getGlobalUpdatePolicy())); + mavenPreferencePage.setGlobalUpdatePolicy("Hourly"); + assertTrue("Hourly".equals(mavenPreferencePage.getGlobalUpdatePolicy()));; + mavenPreferencePage.setGlobalUpdatePolicy("Default"); + assertTrue("Default".equals(mavenPreferencePage.getGlobalUpdatePolicy())); + mavenPreferencePage.setGlobalUpdatePolicy("Never"); + assertTrue("Never".equals(mavenPreferencePage.getGlobalUpdatePolicy())); + preferencesDialog.cancel(); + } + @Test public void checkAllPreferences() { preferencesDialog.open(); preferencesDialog.select(mavenPreferencePage); mavenPreferencePage.setDebugOutput(true); -// mavenPreferencePage.setDoNotAutoUpdateDeps(true); # is not a part of 2023-09 Eclipse + mavenPreferencePage.setDoNotAutoUpdateDeps(true); mavenPreferencePage.setDownloadArtifactJavadoc(true); mavenPreferencePage.setDownloadArtifactSources(true); mavenPreferencePage.setDownloadRepoIndexOnStartup(true); @@ -43,14 +62,14 @@ public void checkAllPreferences() { mavenPreferencePage.setUpdateMavenProjectsOnStartup(true); assertTrue(mavenPreferencePage.isDebugOutputChecked()); -// assertTrue(mavenPreferencePage.isDoNotAutoUpdateDepsChecked()); # is not a part of 2023-09 Eclipse + assertTrue(mavenPreferencePage.isDoNotAutoUpdateDepsChecked()); assertTrue(mavenPreferencePage.isDownloadArtifactJavadocChecked()); assertTrue(mavenPreferencePage.isDownloadArtifactSourcesChecked()); assertTrue(mavenPreferencePage.isDownloadRepoIndexOnStartupChecked()); assertTrue(mavenPreferencePage.isHideFoldersOfPhysicalyNestedModulesChecked()); assertTrue(mavenPreferencePage.isOfflineChecked()); assertTrue(mavenPreferencePage.isUpdateMavenProjectsOnStartupChecked()); - + preferencesDialog.cancel(); } @@ -60,7 +79,7 @@ public void uncheckAllPreferences() { preferencesDialog.select(mavenPreferencePage); mavenPreferencePage.setDebugOutput(false); -// mavenPreferencePage.setDoNotAutoUpdateDeps(false); # is not a part of 2023-09 Eclipse + mavenPreferencePage.setDoNotAutoUpdateDeps(false); mavenPreferencePage.setDownloadArtifactJavadoc(false); mavenPreferencePage.setDownloadArtifactSources(false); mavenPreferencePage.setDownloadRepoIndexOnStartup(false); @@ -69,7 +88,7 @@ public void uncheckAllPreferences() { mavenPreferencePage.setUpdateMavenProjectsOnStartup(false); assertFalse(mavenPreferencePage.isDebugOutputChecked()); -// assertFalse(mavenPreferencePage.isDoNotAutoUpdateDepsChecked()); # is not a part of 2023-09 Eclipse + assertFalse(mavenPreferencePage.isDoNotAutoUpdateDepsChecked()); assertFalse(mavenPreferencePage.isDownloadArtifactJavadocChecked()); assertFalse(mavenPreferencePage.isDownloadArtifactSourcesChecked()); assertFalse(mavenPreferencePage.isDownloadRepoIndexOnStartupChecked());