use of com.thecoderscorner.menu.persist.VersionInfo in project tcMenu by davetcc.
the class MenuEditorTestCases method testAreaInformationPanelNeedingUpdate.
@Test
void testAreaInformationPanelNeedingUpdate(FxRobot robot) throws Exception {
when(installer.statusOfAllLibraries()).thenReturn(new LibraryStatus(true, true, true, false));
when(installer.getVersionOfLibrary("module.name", AVAILABLE_PLUGIN)).thenReturn(new VersionInfo("1.0.2"));
openTheCompleteMenuTree(robot);
SubMenuItem subItem = project.getMenuTree().getSubMenuById(100).orElseThrow();
TreeView<MenuItem> treeView = robot.lookup("#menuTree").query();
assertTrue(recursiveSelectTreeItem(treeView, treeView.getRoot(), subItem));
assertTrue(recursiveSelectTreeItem(treeView, treeView.getRoot(), MenuTree.ROOT));
Thread.sleep(500);
verifyThat("#tcMenuStatusArea", LabeledMatchers.hasText("Libraries need updating, check in General Settings"));
}
use of com.thecoderscorner.menu.persist.VersionInfo in project tcMenu by davetcc.
the class MenuEditorTestCases method onStart.
@Start
public void onStart(Stage stage) throws Exception {
dirHelper.initialise();
dirHelper.createSketch(TCMENU_DIR, "exampleSketch1", true);
dirHelper.createSketch(TCMENU_DIR, "exampleSketch2", true);
var sketch1 = dirHelper.createSketch(SKETCHES_DIR, "sketches1", true);
var sketch2 = dirHelper.createSketch(SKETCHES_DIR, "sketches2", true);
dirHelper.createSketch(SKETCHES_DIR, "sketchesIgnore", false);
// load the main window FXML
FXMLLoader loader = new FXMLLoader(getClass().getResource("/ui/menuEditor.fxml"));
Pane myPane = loader.load();
// we need to mock a few things around the edges to make testing easier.
editorProjectUI = mock(CurrentProjectEditorUI.class);
when(editorProjectUI.createPanelForMenuItem(any(), any(), any(), any())).thenReturn(Optional.empty());
persistor = mock(ProjectPersistor.class);
installer = mock(ArduinoLibraryInstaller.class);
simulatedCodeManager = mock(CodePluginManager.class);
when(simulatedCodeManager.getLoadedPlugins()).thenReturn(Collections.singletonList(generateCodePluginConfig()));
setUpInstallerLibVersions();
// create a basic project, that has a few menu items in it.
project = new CurrentEditorProject(editorProjectUI, persistor, mock(ConfigurationStorage.class));
ConfigurationStorage storage = mock(ConfigurationStorage.class);
when(storage.loadRecents()).thenReturn(List.of(sketch1.orElseThrow(), sketch2.orElseThrow(), "filesDoesNotExistRemove.emf"));
when(storage.getRegisteredKey()).thenReturn("UnitTesterII");
when(storage.isUsingArduinoIDE()).thenReturn(true);
when(storage.getArduinoOverrideDirectory()).thenReturn(Optional.empty());
// both versions same, do not invoke splash screen.
when(storage.getVersion()).thenReturn("1.1.1");
when(storage.getLastRunVersion()).thenReturn(new VersionInfo("1.1.1"));
// set up the controller and stage..
MenuEditorController controller = loader.getController();
libDetector = mock(LibraryVersionDetector.class);
when(libDetector.getReleaseType()).thenReturn(ReleaseType.STABLE);
controller.initialise(project, installer, editorProjectUI, simulatedCodeManager, storage, libDetector);
this.stage = stage;
when(libDetector.availableVersionsAreValid(anyBoolean())).thenReturn(true);
Scene myScene = new Scene(myPane);
stage.setScene(myScene);
stage.show();
}
use of com.thecoderscorner.menu.persist.VersionInfo in project tcMenu by davetcc.
the class MenuEditorTestCases method setUpInstallerLibVersions.
private void setUpInstallerLibVersions() throws IOException {
// and we are always up to date library wise in unit test land
when(installer.statusOfAllLibraries()).thenReturn(new LibraryStatus(true, true, true, true));
when(installer.findLibraryInstall("tcMenu")).thenReturn(dirHelper.getTcMenuPath());
when(installer.getArduinoDirectory()).thenReturn(dirHelper.getSketchesDir());
when(installer.getVersionOfLibrary("java-app", AVAILABLE_APP)).thenReturn(new VersionInfo("1.0.0"));
when(installer.getVersionOfLibrary("java-app", CURRENT_APP)).thenReturn(new VersionInfo("1.0.0"));
when(installer.getVersionOfLibrary("module.name", AVAILABLE_PLUGIN)).thenReturn(new VersionInfo("1.0.0"));
when(installer.getVersionOfLibrary("module.name", CURRENT_PLUGIN)).thenReturn(new VersionInfo("1.0.0"));
when(installer.getVersionOfLibrary("tcMenu", AVAILABLE_LIB)).thenReturn(new VersionInfo("1.0.1"));
when(installer.getVersionOfLibrary("tcMenu", CURRENT_LIB)).thenReturn(new VersionInfo("1.0.0"));
when(installer.getVersionOfLibrary("IoAbstraction", AVAILABLE_LIB)).thenReturn(new VersionInfo("1.0.0"));
when(installer.getVersionOfLibrary("IoAbstraction", CURRENT_LIB)).thenReturn(new VersionInfo("1.0.0"));
when(installer.getVersionOfLibrary("LiquidCrystalIO", AVAILABLE_LIB)).thenReturn(new VersionInfo("1.0.0"));
when(installer.getVersionOfLibrary("LiquidCrystalIO", CURRENT_LIB)).thenReturn(new VersionInfo("1.0.0"));
when(installer.getVersionOfLibrary("TaskManagerIO", AVAILABLE_LIB)).thenReturn(new VersionInfo("1.0.0"));
when(installer.getVersionOfLibrary("TaskManagerIO", CURRENT_LIB)).thenReturn(new VersionInfo("1.0.0"));
when(installer.statusOfAllLibraries()).thenReturn(new LibraryStatus(false, true, true, true));
}
use of com.thecoderscorner.menu.persist.VersionInfo in project tcMenu by davetcc.
the class ArduinoLibraryInstallerTest method testGetAllLibraryStatus.
@Test
public void testGetAllLibraryStatus() throws IOException {
// put libs in the embedded source at 1.0.1, newer than arduino copy
putLibraryInPlace(dirArduinoLibs, "tcMenu", "1.0.1");
putLibraryInPlace(dirArduinoLibs, "IoAbstraction", "1.2.1");
putLibraryInPlace(dirArduinoLibs, "LiquidCrystalIO", "1.4.1");
putLibraryInPlace(dirArduinoLibs, "TaskManagerIO", "1.0.0");
var versions = Map.of("tcMenu/Library", new VersionInfo("1.0.0"), "IoAbstraction/Library", new VersionInfo("1.2.1"), "LiquidCrystalIO/Library", new VersionInfo("1.5.1"), "TaskManagerIO/Library", new VersionInfo("1.0.1"), "xyz/Plugin", new VersionInfo("7.8.9"));
when(verDetector.acquireVersions()).thenReturn(versions);
LibraryStatus libraryStatus = installer.statusOfAllLibraries();
assertFalse(libraryStatus.isUpToDate());
assertTrue(libraryStatus.isIoAbstractionUpToDate());
assertTrue(libraryStatus.isTcMenuUpToDate());
assertFalse(libraryStatus.isLiquidCrystalIoUpToDate());
assertEquals("1.0.1", installer.getVersionOfLibrary("tcMenu", CURRENT_LIB).toString());
assertEquals("1.2.1", installer.getVersionOfLibrary("IoAbstraction", CURRENT_LIB).toString());
assertEquals("1.4.1", installer.getVersionOfLibrary("LiquidCrystalIO", CURRENT_LIB).toString());
assertEquals("1.0.0", installer.getVersionOfLibrary("TaskManagerIO", CURRENT_LIB).toString());
assertEquals("1.0.1", installer.getVersionOfLibrary("TaskManagerIO", AVAILABLE_LIB).toString());
assertEquals("1.0.0", installer.getVersionOfLibrary("tcMenu", AVAILABLE_LIB).toString());
assertEquals("1.2.1", installer.getVersionOfLibrary("IoAbstraction", AVAILABLE_LIB).toString());
assertEquals("1.5.1", installer.getVersionOfLibrary("LiquidCrystalIO", AVAILABLE_LIB).toString());
assertEquals("7.8.9", installer.getVersionOfLibrary("xyz", AVAILABLE_PLUGIN).toString());
}
use of com.thecoderscorner.menu.persist.VersionInfo in project tcMenu by davetcc.
the class MenuEditorApp method createOrUpdateDirectoriesAsNeeded.
public static void createOrUpdateDirectoriesAsNeeded(ConfigurationStorage storage) {
var homeDir = Paths.get(System.getProperty("user.home"));
try {
Path menuDir = homeDir.resolve(".tcmenu/logs");
if (!Files.exists(menuDir)) {
Files.createDirectories(menuDir);
}
Path pluginDir = homeDir.resolve(".tcmenu/plugins");
var current = new VersionInfo(storage.getVersion());
var noPluginDir = !isDirectoryPresentAndPopulated(pluginDir);
if (!storage.getLastRunVersion().equals(current) || noPluginDir) {
try {
if (noPluginDir)
Files.createDirectories(pluginDir);
if (Files.find(pluginDir, 2, (path, basicFileAttributes) -> path.endsWith(".git") || path.endsWith(".development")).findFirst().isPresent()) {
System.getLogger("Main").log(WARNING, "Not upgrading core plugins, this is a development system");
return;
}
try (var resourceAsStream = MenuEditorApp.class.getResourceAsStream("/plugins/InitialPlugins.zip")) {
OnlineLibraryVersionDetector.extractFilesFromZip(pluginDir, resourceAsStream);
}
} catch (Exception ex) {
System.getLogger("Main").log(ERROR, "failed to prepare directory structure", ex);
}
}
} catch (IOException e) {
Alert alert = new Alert(AlertType.ERROR, "Error creating user directory", ButtonType.CLOSE);
BaseDialogSupport.getJMetro().setScene(alert.getDialogPane().getScene());
alert.setContentText("Couldn't create user directory: " + e.getMessage());
alert.showAndWait();
}
}
Aggregations