@Test public void openAnExistingConfigurationFile() throws URISyntaxException { /*! An existing configuration can be opened by selecting **'Open'** from the **'File'** menu or by pressing **Ctrl+O**.<br> */ String fileName = new File(getClass().getResource("rules.properties").toURI()).getAbsolutePath(); fileSelector.setNextFile(null); view.menuBar.getMenu("File").getSubMenu("Open").click(); view.rulesButton.click(); assertTrue(rulesSelector.getPreviousRules().getForbiddenDependencies().isEmpty()); assertEquals("DTangler DsmUI - original.properties", view.getTitle()); fileSelector.setNextFile(fileName); view.menuBar.getMenu("File").getSubMenu("Open").click(); view.rulesButton.click(); Set<String> rule = rulesSelector.getPreviousRules().getForbiddenDependencies().get("foo"); assertTrue(rule.contains("bar")); assertTrue(rule.contains("bay")); assertEquals("DTangler DsmUI - " + fileName, view.getTitle()); }
@Test public void saveConfiguration() { /*! At any time you can save the current configuration by selecting **'Save'** from the **'File'** menu or by pressing **CTRL+S**. If this is the first time that you save the current configuration, you will be asked for the filename to save to. */ view.menuBar.getMenu("File").getSubMenu("New").click(); makeConfiguarationDirty(); String fileName = System.getProperty("java.io.tmpdir") + File.separator + "testsave.properties"; File file = new File(fileName); if (file.exists()) assertTrue(file.delete()); fileSelector.setNextFile(fileName); view.menuBar.getMenu("File").getSubMenu("Save").click(); assertTrue(file.exists()); assertTrue(file.delete()); view.menuBar.getMenu("File").getSubMenu("Save").click(); assertTrue(file.exists()); }
@Test public void changedConfigurationUponOpeningAnExistingConfigurationFile() throws URISyntaxException { /*! If the current configuration contains changes since the last time it has been saved, you will be asked whether to save those changes or not before another configuration is opened. */ String fileName = new File(getClass().getResource("rules.properties").toURI()).getAbsolutePath(); fileSelector.setNextFile(fileName); makeConfiguarationDirty(); assertEquals("DTangler DsmUI - * original.properties", view.getTitle()); dialogManager.setNextResult(DialogResult.cancel); view.menuBar.getMenu("File").getSubMenu("Open").click(); assertEquals("DTangler DsmUI - * original.properties", view.getTitle()); dialogManager.setNextResult(DialogResult.no); view.menuBar.getMenu("File").getSubMenu("Open").click(); assertEquals("DTangler DsmUI - " + fileName, view.getTitle()); }
@Test public void saveConfigurationToDifferentFile() { /*! At any time you can save the current configuration to a file of choice by selecting **'Save as...'** from the **'File'** menu or by pressing **CTRL+SHIFT+S**. You will be asked for the filename to save to. */ String fileName = System.getProperty("java.io.tmpdir") + File.separator + "testsave.properties"; File file = new File(fileName); if (file.exists()) assertTrue(file.delete()); fileSelector.setNextFile(fileName); view.menuBar.getMenu("File").getSubMenu("Save as").click(); assertTrue(file.exists()); }