From 8232bf8f0992a315cc1e8932eaa06eaecc67f5b9 Mon Sep 17 00:00:00 2001 From: Stephane Bouchet Date: Mon, 23 Sep 2024 15:57:49 +0200 Subject: [PATCH] test: add a unit test when podman is not present (#886) * test: add a unit test when podman is not present Signed-off-by: Stephane Bouchet * fix after reviews Signed-off-by: Stephane Bouchet * fix after reviews Signed-off-by: Stephane Bouchet * fix after reviews Signed-off-by: Stephane Bouchet * fix after reviews Signed-off-by: Stephane Bouchet --------- Signed-off-by: Stephane Bouchet --- .../utils/odo/OdoCliComponentTest.java | 73 +++++++++-- .../utils/odo/OdoCliRegistryTest.java | 34 ++++-- .../utils/odo/OdoCliServiceTest.java | 1 + .../openshift/utils/odo/OdoCliTest.java | 7 +- src/it/projects/go/.gitignore | 5 +- .../component/DevOnPodmanComponentAction.java | 3 +- .../utils/odo/ComponentFeatures.java | 114 ++++++++++-------- .../openshift/actions/ActionTest.java | 17 ++- .../DevOnPodmanComponentActionTest.java | 2 +- ...OnPodmanNotPresentComponentActionTest.java | 69 +++++++++++ .../helm/AddHelmRepositoryActionTest.java | 6 +- .../helm/EditHelmRepositoryActionTest.java | 32 +++++ .../actions/helm/RefreshActionTest.java | 6 +- .../helm/RemoveHelmRepositoryActionTest.java | 6 +- 14 files changed, 271 insertions(+), 104 deletions(-) create mode 100644 src/test/java/org/jboss/tools/intellij/openshift/actions/component/DevOnPodmanNotPresentComponentActionTest.java create mode 100644 src/test/java/org/jboss/tools/intellij/openshift/actions/helm/EditHelmRepositoryActionTest.java diff --git a/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliComponentTest.java b/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliComponentTest.java index cfb8a9763..691cf87b3 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliComponentTest.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliComponentTest.java @@ -30,7 +30,7 @@ @RunWith(Parameterized.class) public class OdoCliComponentTest extends OdoCliTest { - protected static final String COMPONENT_PATH = "src/it/projects/go"; + private static final String COMPONENT_PATH = "src/it/projects/go"; private final ComponentFeature feature; private String project; private String component; @@ -50,21 +50,26 @@ public static Iterable data() { } @Before - public void initTestEnv() { + public void initTestEnv() throws IOException { project = PROJECT_PREFIX + random.nextInt(); component = COMPONENT_PREFIX + random.nextInt(); service = SERVICE_PREFIX + random.nextInt(); + odo.createDevfileRegistry(REGISTRY_NAME, REGISTRY_URL, null); } @After public void cleanUp() throws IOException { - if (odo.isStarted(COMPONENT_PATH, feature)) { - odo.stop(COMPONENT_PATH, component, feature); + if (odo.isStarted(component, feature)) { + odo.stop(projectPath, component, feature); + } + if (!odo.discover(projectPath).isEmpty()) { + odo.deleteComponent(project, projectPath, component, ComponentKind.DEVFILE); } if (project.equals(odo.getCurrentNamespace())) { odo.deleteProject(project); } cleanLocalProjectDirectory(projectPath); + odo.deleteDevfileRegistry(REGISTRY_NAME); } protected void startComponent(String component, ComponentFeature feature) throws IOException { @@ -87,7 +92,7 @@ public void checkCreateComponent() throws IOException, ExecutionException, Inter @Test public void checkCreateAndDiscoverComponent() throws IOException, ExecutionException, InterruptedException { createComponent(project, component, projectPath); - List components = odo.discover(COMPONENT_PATH); + List components = odo.discover(projectPath); assertNotNull(components); assertEquals(1, components.size()); assertEquals(projectPath, components.get(0).getPath()); @@ -111,6 +116,7 @@ public void checkCreateComponentAndLinkService() throws IOException, ExecutionEx createComponent(project, component, projectPath); ServiceTemplate serviceTemplate = getServiceTemplate(); OperatorCRD crd = getOperatorCRD(serviceTemplate); + assertNotNull(crd); odo.createService(project, serviceTemplate, crd, service, null, true); List deployedServices = odo.getServices(project); assertNotNull(deployedServices); @@ -118,24 +124,37 @@ public void checkCreateComponentAndLinkService() throws IOException, ExecutionEx Service deployedService = deployedServices.get(0); assertNotNull(deployedService); String target = deployedService.getName() + '/' + deployedService.getKind() + "." + deployedService.getApiVersion(); - Binding binding = odo.link(COMPONENT_PATH, target); + Binding binding = odo.link(projectPath, target); assertNotNull(binding); + List bindings = odo.listBindings(projectPath); + assertEquals(1, bindings.size()); + //cleanup + odo.deleteBinding(projectPath, binding.getName()); + bindings = odo.listBindings(projectPath); + assertEquals(0, bindings.size()); + odo.deleteService(project, deployedService); + deployedServices = odo.getServices(project); + assertEquals(0, deployedServices.size()); } @Test public void checkCreateComponentAndListURLs() throws IOException, ExecutionException, InterruptedException { createComponent(project, component, projectPath); - List urls = odo.listURLs(COMPONENT_PATH); + List urls = odo.listURLs(projectPath); assertEquals(0, urls.size()); startComponent(component, feature); - urls = odo.listURLs(COMPONENT_PATH); + urls = odo.listURLs(projectPath); assertEquals(1, urls.size()); + //cleanup + odo.stop(projectPath, component, feature); } @Test public void checkCreateComponentAndDebug() throws IOException, ExecutionException, InterruptedException { createComponent(project, component, projectPath); - startComponent(component, feature); + DebugComponentFeature debugComponentFeature = new DebugComponentFeature(feature); + startComponent(component, debugComponentFeature); + assertTrue(odo.isStarted(component, debugComponentFeature)); int debugPort; try (ServerSocket serverSocket = new ServerSocket(0)) { debugPort = serverSocket.getLocalPort(); @@ -143,11 +162,22 @@ public void checkCreateComponentAndDebug() throws IOException, ExecutionExceptio ExecHelper.submit(() -> { try { odo.debug(projectPath, debugPort); - assertTrue(odo.isStarted(component, feature)); } catch (IOException e) { - fail("Should not raise Exception"); + fail("Should not raise Exception: " + e.getMessage()); } }); + List components = odo.getComponents(project); + assertNotNull(components); + assertEquals(1, components.size()); + Component comp = components.get(0); + assertNotNull(comp); + ComponentFeatures features = comp.getLiveFeatures(); + assertNotNull(features); + assertFalse(features.isEmpty()); + assertEquals(1, features.size()); + // assertTrue(features.isDebug()); odo issue, see #redhat-developer/odo/issues/7197 + assertTrue(features.isDev()); + //cleanup odo.stop(projectPath, component, feature); } @@ -163,6 +193,25 @@ public void checkCreateComponentStarter() throws IOException, ExecutionException public void checkCreateComponentAndStartDev() throws IOException, ExecutionException, InterruptedException { createComponent(project, component, projectPath); startComponent(component, feature); - with().pollDelay(10, TimeUnit.SECONDS).await().atMost(10, TimeUnit.MINUTES).until(() -> odo.isStarted(component, feature)); + assertTrue(odo.isStarted(component, feature)); + ComponentInfo info = odo.getComponentInfo(project, component, projectPath, ComponentKind.DEVFILE); + assertNotNull(info.getSupportedFeatures()); + assertEquals(2, info.getSupportedFeatures().size()); + List supportedFeatures = info.getSupportedFeatures(); + assertTrue(supportedFeatures.contains(ComponentFeature.Mode.DEV_MODE)); + assertTrue(supportedFeatures.contains(ComponentFeature.Mode.DEBUG_MODE)); + List components = odo.getComponents(project); + assertNotNull(components); + assertEquals(1, components.size()); + Component comp = components.get(0); + assertNotNull(comp); + ComponentFeatures features = comp.getLiveFeatures(); + assertNotNull(features); + assertFalse(features.isEmpty()); + assertEquals(1, features.size()); + assertTrue(features.isDev()); + //cleanup + odo.stop(projectPath, component, feature); } + } diff --git a/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliRegistryTest.java b/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliRegistryTest.java index e9a2823fe..b243701be 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliRegistryTest.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliRegistryTest.java @@ -15,17 +15,29 @@ public class OdoCliRegistryTest extends OdoCliTest { - public void testCheckCreateRegistry() throws IOException { - String registryName = REGISTRY_PREFIX + random.nextInt(); - try { - odo.createDevfileRegistry(registryName, "https://registry.devfile.io", null); - } finally { - odo.deleteDevfileRegistry(registryName); - } - } + @Override + protected void setUp() throws Exception { + super.setUp(); + odo.createDevfileRegistry(REGISTRY_NAME, REGISTRY_URL, null); + } + + @Override + protected void tearDown() throws Exception { + odo.deleteDevfileRegistry(REGISTRY_NAME); + super.tearDown(); + } - public void testCheckListRegistries() throws IOException { - List registries = odo.listDevfileRegistries(); - assertFalse(registries.isEmpty()); + public void testCheckCreateRegistry() throws IOException { + String registryName = REGISTRY_PREFIX + random.nextInt(); + try { + odo.createDevfileRegistry(registryName, "https://registry.devfile.io", null); + } finally { + odo.deleteDevfileRegistry(registryName); } + } + + public void testCheckListRegistries() throws IOException { + List registries = odo.listDevfileRegistries(); + assertFalse(registries.isEmpty()); + } } diff --git a/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliServiceTest.java b/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliServiceTest.java index 0946493a3..ae5760af1 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliServiceTest.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliServiceTest.java @@ -53,6 +53,7 @@ private void createService(String project, String service) throws IOException, E createProject(project); ServiceTemplate serviceTemplate = getServiceTemplate(); OperatorCRD crd = getOperatorCRD(serviceTemplate); + assertNotNull(crd); createService(project, serviceTemplate, crd, service, projectPath); } } diff --git a/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliTest.java b/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliTest.java index a43fca2e0..6733b4fd9 100644 --- a/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliTest.java +++ b/src/it/java/org/jboss/tools/intellij/openshift/utils/odo/OdoCliTest.java @@ -71,14 +71,11 @@ protected void setUp() throws Exception { } }); odo = getOdo().get(); - if (odo.listDevfileRegistries().stream().noneMatch(c -> c.getName().equals(REGISTRY_NAME))) - odo.createDevfileRegistry(REGISTRY_NAME, REGISTRY_URL, null); } @Override protected void tearDown() throws Exception { MessagesHelper.setTestDialog(previousTestDialog); - odo.deleteDevfileRegistry(REGISTRY_NAME); super.tearDown(); } @@ -110,9 +107,7 @@ protected void cleanLocalProjectDirectory(String projectPath) throws IOException } protected OperatorCRD getOperatorCRD(ServiceTemplate serviceTemplate) { - OperatorCRD crd = serviceTemplate.getCRDs().stream().filter(c -> c.getName().equals(SERVICE_CRD)).findFirst().orElse(null); - assertNotNull(crd); - return crd; + return serviceTemplate.getCRDs().stream().filter(c -> c.getName().equals(SERVICE_CRD)).findFirst().orElse(null); } protected ServiceTemplate getServiceTemplate() throws IOException { diff --git a/src/it/projects/go/.gitignore b/src/it/projects/go/.gitignore index 9e39036b0..4e8bab5d0 100644 --- a/src/it/projects/go/.gitignore +++ b/src/it/projects/go/.gitignore @@ -1,4 +1,3 @@ -.odo/env -.odo/odo-file-index.json +.odo/ main -main.exe +main.exe \ No newline at end of file diff --git a/src/main/java/org/jboss/tools/intellij/openshift/actions/component/DevOnPodmanComponentAction.java b/src/main/java/org/jboss/tools/intellij/openshift/actions/component/DevOnPodmanComponentAction.java index 3d5e873fb..cd2689158 100644 --- a/src/main/java/org/jboss/tools/intellij/openshift/actions/component/DevOnPodmanComponentAction.java +++ b/src/main/java/org/jboss/tools/intellij/openshift/actions/component/DevOnPodmanComponentAction.java @@ -40,10 +40,9 @@ public void update(AnActionEvent e) { super.update(e); if (e.getPresentation().isVisible()) { Object node = adjust(getSelected(getTree(e))); - if (!(node instanceof ComponentNode)) { + if (!(node instanceof ComponentNode componentNode)) { return; } - ComponentNode componentNode = (ComponentNode) node; e.getPresentation().setEnabled(componentNode.getComponent().getInfo().isLocalPodmanPresent()); } } diff --git a/src/main/java/org/jboss/tools/intellij/openshift/utils/odo/ComponentFeatures.java b/src/main/java/org/jboss/tools/intellij/openshift/utils/odo/ComponentFeatures.java index 6b579942a..af599c429 100644 --- a/src/main/java/org/jboss/tools/intellij/openshift/utils/odo/ComponentFeatures.java +++ b/src/main/java/org/jboss/tools/intellij/openshift/utils/odo/ComponentFeatures.java @@ -17,57 +17,65 @@ public class ComponentFeatures { - private final Set features = new HashSet<>(); - - public ComponentFeatures(ComponentFeature feature) { - addFeature(feature); - } - - public ComponentFeatures() {} - - public void addFeature(ComponentFeature feature) { - features.add(feature); - } - - public void removeFeature(ComponentFeature feature) { - features.remove(feature); - } - - public boolean is(ComponentFeature feature) { - return features.contains(feature); - } - - public boolean isDev() { - return is(ComponentFeature.DEV) || is(ComponentFeature.DEV_ON_PODMAN); - } - - public boolean isDeploy() { - return is(ComponentFeature.DEPLOY); - } - - public boolean isDebug() { - return features.stream().anyMatch(DebugComponentFeature.class::isInstance); - } - - @Override - public String toString() { - return features.stream().map(f -> f.getMode().getLabel()).collect(Collectors.joining(", ")); - } - - public boolean isOnCluster() { - return isDev() || isDebug() || isDeploy(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - ComponentFeatures that = (ComponentFeatures) o; - return Objects.equals(features, that.features); - } - - @Override - public int hashCode() { - return Objects.hash(features); - } + private final Set features = new HashSet<>(); + + public ComponentFeatures(ComponentFeature feature) { + addFeature(feature); + } + + public ComponentFeatures() {} + + public void addFeature(ComponentFeature feature) { + features.add(feature); + } + + public void removeFeature(ComponentFeature feature) { + features.remove(feature); + } + + public boolean is(ComponentFeature feature) { + return features.contains(feature); + } + + public boolean isDev() { + return is(ComponentFeature.DEV) || is(ComponentFeature.DEV_ON_PODMAN); + } + + public boolean isDeploy() { + return is(ComponentFeature.DEPLOY); + } + + public boolean isDebug() { + return features.stream().anyMatch(DebugComponentFeature.class::isInstance); + } + + @Override + public String toString() { + return features.stream().map(f -> f.getMode().getLabel()).collect(Collectors.joining(", ")); + } + + public boolean isOnCluster() { + return isDev() || isDebug() || isDeploy(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ComponentFeatures that = (ComponentFeatures) o; + return Objects.equals(features, that.features); + } + + @Override + public int hashCode() { + return Objects.hash(features); + } + + public boolean isEmpty() { + return features.isEmpty(); + } + + public int size() { + return features.size(); + } } diff --git a/src/test/java/org/jboss/tools/intellij/openshift/actions/ActionTest.java b/src/test/java/org/jboss/tools/intellij/openshift/actions/ActionTest.java index dbb867da3..ab3a40256 100644 --- a/src/test/java/org/jboss/tools/intellij/openshift/actions/ActionTest.java +++ b/src/test/java/org/jboss/tools/intellij/openshift/actions/ActionTest.java @@ -81,9 +81,6 @@ protected ApplicationsRootNode createApplicationRootNode(boolean isLogged) { when(applicationsRootNode.isLogged()).thenReturn(isLogged); when(applicationsRootNode.getRoot()).thenReturn(applicationsRootNode); when(applicationsRootNode.getOdo()).thenReturn(odoFuture); - ApplicationRootNodeOdo odo = mock(ApplicationRootNodeOdo.class); - when(odo.getNamespaceKind()).thenReturn(isOpenshift ? "Project" : "Namespace"); - when(odoFuture.getNow(null)).thenReturn(odo); return applicationsRootNode; } @@ -92,6 +89,7 @@ protected CompletableFuture createOdoFuture() { ApplicationRootNodeOdo odo = mock(ApplicationRootNodeOdo.class); when(odo.isOpenShift()).thenReturn(isOpenshift); CompletableFuture odoFuture = mock(CompletableFuture.class); + when(odo.getNamespaceKind()).thenReturn(isOpenshift ? "Project" : "Namespace"); when(odoFuture.getNow(any())).thenReturn(odo); return odoFuture; } @@ -117,7 +115,6 @@ public AnActionEvent createEvent(ParentableNode node) { when(structure.getApplicationsRoot()).thenReturn(applicationRootNode); when(node.getRoot()).thenReturn(applicationRootNode); } - when(event.getPresentation()).thenReturn(presentation); return event; } @@ -300,7 +297,7 @@ public void testActionOnHelmRepositories() { AnActionEvent event = createEvent(helmRepositoriesNode); AnAction action = getAction(); action.update(event); - verifyHelmRepositories(event.getPresentation().isVisible()); + verifyHelmRepositories(event.getPresentation()); } @Test @@ -309,7 +306,7 @@ public void testActionOnHelmRepository() { AnActionEvent event = createEvent(helmRepositoryNode); AnAction action = getAction(); action.update(event); - verifyHelmRepository(event.getPresentation().isVisible()); + verifyHelmRepository(event.getPresentation()); } /** @@ -388,11 +385,11 @@ protected void verifyProject(@NotNull Presentation presentation) { defaultAssertions(presentation); } - protected void verifyHelmRepositories(boolean visible) { - assertFalse(visible); + protected void verifyHelmRepositories(@NotNull Presentation presentation) { + defaultAssertions(presentation); } - protected void verifyHelmRepository(boolean visible) { - assertFalse(visible); + protected void verifyHelmRepository(@NotNull Presentation presentation) { + defaultAssertions(presentation); } } diff --git a/src/test/java/org/jboss/tools/intellij/openshift/actions/component/DevOnPodmanComponentActionTest.java b/src/test/java/org/jboss/tools/intellij/openshift/actions/component/DevOnPodmanComponentActionTest.java index b28a6c2aa..aedd12c0e 100644 --- a/src/test/java/org/jboss/tools/intellij/openshift/actions/component/DevOnPodmanComponentActionTest.java +++ b/src/test/java/org/jboss/tools/intellij/openshift/actions/component/DevOnPodmanComponentActionTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019 Red Hat, Inc. + * Copyright (c) 2024 Red Hat, Inc. * Distributed under license by Red Hat, Inc. All rights reserved. * This program is made available under the terms of the * Eclipse Public License v2.0 which accompanies this distribution, diff --git a/src/test/java/org/jboss/tools/intellij/openshift/actions/component/DevOnPodmanNotPresentComponentActionTest.java b/src/test/java/org/jboss/tools/intellij/openshift/actions/component/DevOnPodmanNotPresentComponentActionTest.java new file mode 100644 index 000000000..163aeda62 --- /dev/null +++ b/src/test/java/org/jboss/tools/intellij/openshift/actions/component/DevOnPodmanNotPresentComponentActionTest.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2019 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v20.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ +package org.jboss.tools.intellij.openshift.actions.component; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.Presentation; +import org.jboss.tools.intellij.openshift.actions.ActionTest; +import org.jboss.tools.intellij.openshift.tree.application.ApplicationRootNodeOdo; +import org.jboss.tools.intellij.openshift.utils.odo.OdoDelegate; +import org.jetbrains.annotations.NotNull; + +import java.lang.reflect.Field; +import java.util.concurrent.CompletableFuture; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class DevOnPodmanNotPresentComponentActionTest extends ActionTest { + + @Override + protected @NotNull CompletableFuture createOdoFuture() { + CompletableFuture future = super.createOdoFuture(); + ApplicationRootNodeOdo applicationRootNodeOdo = mock(ApplicationRootNodeOdo.class); + when(applicationRootNodeOdo.getNamespaceKind()).thenReturn(isOpenshift ? "Project" : "Namespace"); + when(future.getNow(any())).thenReturn(applicationRootNodeOdo); + OdoDelegate odo = mock(OdoDelegate.class); + try { + applicationRootNodeOdo = future.getNow(null); + Field fld = applicationRootNodeOdo.getClass().getDeclaredField("delegate"); + fld.setAccessible(true); + fld.set(applicationRootNodeOdo, odo); + } catch (IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + return future; + } + + public DevOnPodmanNotPresentComponentActionTest(boolean isOpenshift) { + super(isOpenshift); + } + + @Override + public AnAction getAction() { + return new DevOnPodmanComponentAction(); + } + + @Override + protected void verifyLocalDevOnPodmanComponentWithDevSupportedFeatures(@NotNull Presentation presentation) { + assertFalse(presentation.isEnabled()); + assertTrue(presentation.isVisible()); + assertEquals("Stop dev on Podman", presentation.getText()); + } + + @Override + protected void verifyLocalDevComponentWithDevSupportedFeatures(@NotNull Presentation presentation) { + assertFalse(presentation.isEnabled()); + assertTrue(presentation.isVisible()); + assertEquals("Start dev on Podman", presentation.getText()); + } +} diff --git a/src/test/java/org/jboss/tools/intellij/openshift/actions/helm/AddHelmRepositoryActionTest.java b/src/test/java/org/jboss/tools/intellij/openshift/actions/helm/AddHelmRepositoryActionTest.java index 6c4695710..bb31e36b1 100644 --- a/src/test/java/org/jboss/tools/intellij/openshift/actions/helm/AddHelmRepositoryActionTest.java +++ b/src/test/java/org/jboss/tools/intellij/openshift/actions/helm/AddHelmRepositoryActionTest.java @@ -11,7 +11,9 @@ package org.jboss.tools.intellij.openshift.actions.helm; import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.Presentation; import org.jboss.tools.intellij.openshift.actions.ActionTest; +import org.jetbrains.annotations.NotNull; public class AddHelmRepositoryActionTest extends ActionTest { public AddHelmRepositoryActionTest(boolean isOpenshift) { @@ -24,7 +26,7 @@ public AnAction getAction() { } @Override - protected void verifyHelmRepositories(boolean visible) { - assertTrue(visible); + protected void verifyHelmRepositories(@NotNull Presentation presentation) { + assertTrue(presentation.isVisible()); } } diff --git a/src/test/java/org/jboss/tools/intellij/openshift/actions/helm/EditHelmRepositoryActionTest.java b/src/test/java/org/jboss/tools/intellij/openshift/actions/helm/EditHelmRepositoryActionTest.java new file mode 100644 index 000000000..6da13f18b --- /dev/null +++ b/src/test/java/org/jboss/tools/intellij/openshift/actions/helm/EditHelmRepositoryActionTest.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2024 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v20.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ +package org.jboss.tools.intellij.openshift.actions.helm; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.Presentation; +import org.jboss.tools.intellij.openshift.actions.ActionTest; +import org.jetbrains.annotations.NotNull; + +public class EditHelmRepositoryActionTest extends ActionTest { + public EditHelmRepositoryActionTest(boolean isOpenshift) { + super(isOpenshift); + } + + @Override + public AnAction getAction() { + return new EditHelmRepoAction(); + } + + @Override + protected void verifyHelmRepository(@NotNull Presentation presentation) { + assertTrue(presentation.isVisible()); + } +} diff --git a/src/test/java/org/jboss/tools/intellij/openshift/actions/helm/RefreshActionTest.java b/src/test/java/org/jboss/tools/intellij/openshift/actions/helm/RefreshActionTest.java index eb0d85a99..d3195d7ab 100644 --- a/src/test/java/org/jboss/tools/intellij/openshift/actions/helm/RefreshActionTest.java +++ b/src/test/java/org/jboss/tools/intellij/openshift/actions/helm/RefreshActionTest.java @@ -11,7 +11,9 @@ package org.jboss.tools.intellij.openshift.actions.helm; import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.Presentation; import org.jboss.tools.intellij.openshift.actions.ActionTest; +import org.jetbrains.annotations.NotNull; public class RefreshActionTest extends ActionTest { public RefreshActionTest(boolean isOpenshift) { @@ -24,7 +26,7 @@ public AnAction getAction() { } @Override - protected void verifyHelmRepositories(boolean visible) { - assertTrue(visible); + protected void verifyHelmRepositories(@NotNull Presentation presentation) { + assertTrue(presentation.isVisible()); } } diff --git a/src/test/java/org/jboss/tools/intellij/openshift/actions/helm/RemoveHelmRepositoryActionTest.java b/src/test/java/org/jboss/tools/intellij/openshift/actions/helm/RemoveHelmRepositoryActionTest.java index 25b0c3dfc..c875afb8d 100644 --- a/src/test/java/org/jboss/tools/intellij/openshift/actions/helm/RemoveHelmRepositoryActionTest.java +++ b/src/test/java/org/jboss/tools/intellij/openshift/actions/helm/RemoveHelmRepositoryActionTest.java @@ -11,7 +11,9 @@ package org.jboss.tools.intellij.openshift.actions.helm; import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.Presentation; import org.jboss.tools.intellij.openshift.actions.ActionTest; +import org.jetbrains.annotations.NotNull; public class RemoveHelmRepositoryActionTest extends ActionTest { public RemoveHelmRepositoryActionTest(boolean isOpenshift) { @@ -24,7 +26,7 @@ public AnAction getAction() { } @Override - protected void verifyHelmRepository(boolean visible) { - assertTrue(visible); + protected void verifyHelmRepository(@NotNull Presentation presentation) { + assertTrue(presentation.isVisible()); } }