MultiVersionTreeNode extends UpdaterTreeNode { @Override @NotNull public PackageNodeModel.SelectedState getCurrentState() { return getState(UpdaterTreeNode::getCurrentState); } MultiVersionTreeNode(@NotNull Collection<DetailsTreeNode> versionNodes); @Override @NotNull PackageNodeModel.SelectedState getInitialState(); @Override @NotNull PackageNodeModel.SelectedState getCurrentState(); @Override void customizeRenderer(Renderer renderer,
                                JTree tree,
                                boolean selected,
                                boolean expanded,
                                boolean leaf,
                                int row,
                                boolean hasFocus); @NotNull String getDisplayName(); @Override @NotNull String getStatusString();  }
@Test public void maxVersion() { SdkUpdaterConfigurable configurable = Mockito.mock(SdkUpdaterConfigurable.class); List<DetailsTreeNode> nodes = ImmutableList.of( new DetailsTreeNode(new PackageNodeModel(new UpdatablePackage(new FakePackage.FakeRemotePackage("foo;1.0.0-alpha1"))), null, configurable), new DetailsTreeNode(new PackageNodeModel(new UpdatablePackage(new FakePackage.FakeRemotePackage("foo;1.0.0-beta2"))), null, configurable), new DetailsTreeNode(new PackageNodeModel(new UpdatablePackage(new FakePackage.FakeRemotePackage("foo;1.0.0"))), null, configurable), new DetailsTreeNode(new PackageNodeModel(new UpdatablePackage(new FakePackage.FakeRemotePackage("foo;0.9.9"))), null, configurable) ); MultiVersionTreeNode node = new MultiVersionTreeNode(nodes); node.cycleState(); assertEquals(PackageNodeModel.SelectedState.NOT_INSTALLED, nodes.get(0).getCurrentState()); assertEquals(PackageNodeModel.SelectedState.NOT_INSTALLED, nodes.get(1).getCurrentState()); assertEquals(PackageNodeModel.SelectedState.INSTALLED, nodes.get(2).getCurrentState()); assertEquals(PackageNodeModel.SelectedState.NOT_INSTALLED, nodes.get(3).getCurrentState()); }
@Test public void maxPreviewVersion() { SdkUpdaterConfigurable configurable = Mockito.mock(SdkUpdaterConfigurable.class); List<DetailsTreeNode> nodes = ImmutableList.of( new DetailsTreeNode(new PackageNodeModel(new UpdatablePackage(new FakePackage.FakeRemotePackage("foo;1.0.1-alpha2"))), null, configurable), new DetailsTreeNode(new PackageNodeModel(new UpdatablePackage(new FakePackage.FakeRemotePackage("foo;1.0.1-beta1"))), null, configurable), new DetailsTreeNode(new PackageNodeModel(new UpdatablePackage(new FakePackage.FakeRemotePackage("foo;1.0.0"))), null, configurable) ); MultiVersionTreeNode node = new MultiVersionTreeNode(nodes); node.cycleState(); assertEquals(PackageNodeModel.SelectedState.NOT_INSTALLED, nodes.get(0).getCurrentState()); assertEquals(PackageNodeModel.SelectedState.INSTALLED, nodes.get(1).getCurrentState()); assertEquals(PackageNodeModel.SelectedState.NOT_INSTALLED, nodes.get(2).getCurrentState()); }
@Test public void latestVersion() { SdkUpdaterConfigurable configurable = Mockito.mock(SdkUpdaterConfigurable.class); FakePackage.FakeRemotePackage v1 = new FakePackage.FakeRemotePackage("foo;1"); v1.setRevision(new Revision(1)); FakePackage.FakeRemotePackage v11 = new FakePackage.FakeRemotePackage("foo;1.1"); v11.setRevision(new Revision(1, 1)); FakePackage.FakeRemotePackage latest = new FakePackage.FakeRemotePackage("foo;latest"); latest.setRevision(new Revision(1, 1)); List<DetailsTreeNode> nodes = ImmutableList.of( new DetailsTreeNode(new PackageNodeModel(new UpdatablePackage(v1)), null, configurable), new DetailsTreeNode(new PackageNodeModel(new UpdatablePackage(latest)), null, configurable), new DetailsTreeNode(new PackageNodeModel(new UpdatablePackage(v11)), null, configurable) ); MultiVersionTreeNode node = new MultiVersionTreeNode(nodes); node.cycleState(); assertEquals(PackageNodeModel.SelectedState.NOT_INSTALLED, nodes.get(0).getCurrentState()); assertEquals(PackageNodeModel.SelectedState.INSTALLED, nodes.get(1).getCurrentState()); assertEquals(PackageNodeModel.SelectedState.NOT_INSTALLED, nodes.get(2).getCurrentState()); }