Search in sources :

Example 1 with TestOpenShiftExtension

use of org.eclipse.jkube.gradle.plugin.TestOpenShiftExtension in project jkube by eclipse.

the class OpenShiftHelmTaskTest method setUp.

@Before
public void setUp() {
    extension = new TestOpenShiftExtension();
    helmServiceMockedConstruction = mockConstruction(HelmService.class);
    when(taskEnvironment.project.getExtensions().getByType(OpenShiftExtension.class)).thenReturn(extension);
}
Also used : HelmService(org.eclipse.jkube.kit.resource.helm.HelmService) TestOpenShiftExtension(org.eclipse.jkube.gradle.plugin.TestOpenShiftExtension) Before(org.junit.Before)

Example 2 with TestOpenShiftExtension

use of org.eclipse.jkube.gradle.plugin.TestOpenShiftExtension in project jkube by eclipse.

the class OpenShiftUndeployTaskTest method setUp.

@Before
public void setUp() {
    clusterAccessMockedConstruction = mockConstruction(ClusterAccess.class, (mock, ctx) -> {
        final OpenShiftClient openShiftClient = mock(OpenShiftClient.class);
        when(mock.createDefaultClient()).thenReturn(openShiftClient);
        when(openShiftClient.isAdaptable(OpenShiftClient.class)).thenReturn(true);
    });
    openshiftUndeployServiceMockedConstruction = mockConstruction(OpenshiftUndeployService.class);
    extension = new TestOpenShiftExtension();
    when(taskEnvironment.project.getExtensions().getByType(OpenShiftExtension.class)).thenReturn(extension);
    when(taskEnvironment.project.getName()).thenReturn("test-project");
}
Also used : ClusterAccess(org.eclipse.jkube.kit.config.access.ClusterAccess) OpenshiftUndeployService(org.eclipse.jkube.kit.config.service.openshift.OpenshiftUndeployService) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assert.assertThrows(org.junit.Assert.assertThrows) IOException(java.io.IOException) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) OpenShiftExtension(org.eclipse.jkube.gradle.plugin.OpenShiftExtension) Mockito.when(org.mockito.Mockito.when) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) Mockito.verify(org.mockito.Mockito.verify) TestOpenShiftExtension(org.eclipse.jkube.gradle.plugin.TestOpenShiftExtension) Rule(org.junit.Rule) Paths(java.nio.file.Paths) After(org.junit.After) Mockito.mockConstruction(org.mockito.Mockito.mockConstruction) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Before(org.junit.Before) MockedConstruction(org.mockito.MockedConstruction) Mockito.mock(org.mockito.Mockito.mock) OpenshiftUndeployService(org.eclipse.jkube.kit.config.service.openshift.OpenshiftUndeployService) ClusterAccess(org.eclipse.jkube.kit.config.access.ClusterAccess) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) TestOpenShiftExtension(org.eclipse.jkube.gradle.plugin.TestOpenShiftExtension) Before(org.junit.Before)

Example 3 with TestOpenShiftExtension

use of org.eclipse.jkube.gradle.plugin.TestOpenShiftExtension in project jkube by eclipse.

the class OpenShiftWatchTaskTest method setUp.

@Before
public void setUp() throws IOException {
    clusterAccessMockedConstruction = mockConstruction(ClusterAccess.class, (mock, ctx) -> {
        final OpenShiftClient openShiftClient = mock(OpenShiftClient.class);
        when(openShiftClient.getMasterUrl()).thenReturn(new URL("http://openshiftapps.com:6443"));
        when(mock.createDefaultClient()).thenReturn(openShiftClient);
    });
    watcherManagerMockedStatic = mockStatic(WatcherManager.class);
    kubernetesHelperMockedStatic = mockStatic(KubernetesHelper.class);
    extension = new TestOpenShiftExtension();
    when(taskEnvironment.project.getExtensions().getByType(OpenShiftExtension.class)).thenReturn(extension);
    kubernetesHelperMockedStatic.when(KubernetesHelper::getDefaultNamespace).thenReturn(null);
    extension.isFailOnNoKubernetesJson = false;
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) ArgumentMatchers.isNull(org.mockito.ArgumentMatchers.isNull) ClusterAccess(org.eclipse.jkube.kit.config.access.ClusterAccess) URL(java.net.URL) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assert.assertThrows(org.junit.Assert.assertThrows) Mockito.mockStatic(org.mockito.Mockito.mockStatic) KubernetesHelper(org.eclipse.jkube.kit.common.util.KubernetesHelper) Test(org.junit.Test) IOException(java.io.IOException) Mockito.times(org.mockito.Mockito.times) OpenShiftExtension(org.eclipse.jkube.gradle.plugin.OpenShiftExtension) Mockito.when(org.mockito.Mockito.when) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) MockedStatic(org.mockito.MockedStatic) TestOpenShiftExtension(org.eclipse.jkube.gradle.plugin.TestOpenShiftExtension) Rule(org.junit.Rule) After(org.junit.After) Mockito.mockConstruction(org.mockito.Mockito.mockConstruction) WatcherManager(org.eclipse.jkube.watcher.api.WatcherManager) Before(org.junit.Before) MockedConstruction(org.mockito.MockedConstruction) Mockito.mock(org.mockito.Mockito.mock) WatcherManager(org.eclipse.jkube.watcher.api.WatcherManager) ClusterAccess(org.eclipse.jkube.kit.config.access.ClusterAccess) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) TestOpenShiftExtension(org.eclipse.jkube.gradle.plugin.TestOpenShiftExtension) URL(java.net.URL) KubernetesHelper(org.eclipse.jkube.kit.common.util.KubernetesHelper) Before(org.junit.Before)

Example 4 with TestOpenShiftExtension

use of org.eclipse.jkube.gradle.plugin.TestOpenShiftExtension in project jkube by eclipse.

the class OpenShiftApplyTaskTest method setUp.

@Before
public void setUp() {
    clusterAccessMockedConstruction = mockConstruction(ClusterAccess.class, (mock, ctx) -> {
        final OpenShiftClient openShiftClient = mock(OpenShiftClient.class);
        when(openShiftClient.getMasterUrl()).thenReturn(new URL("http://openshiftapps-com-cluster:6443"));
        when(openShiftClient.isAdaptable(OpenShiftClient.class)).thenReturn(true);
        when(mock.createDefaultClient()).thenReturn(openShiftClient);
    });
    applyServiceMockedConstruction = mockConstruction(ApplyService.class);
    extension = new TestOpenShiftExtension();
    when(taskEnvironment.project.getExtensions().getByType(OpenShiftExtension.class)).thenReturn(extension);
    extension.isFailOnNoKubernetesJson = false;
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) ClusterAccess(org.eclipse.jkube.kit.config.access.ClusterAccess) URL(java.net.URL) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assert.assertThrows(org.junit.Assert.assertThrows) IOException(java.io.IOException) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) OpenShiftExtension(org.eclipse.jkube.gradle.plugin.OpenShiftExtension) Mockito.when(org.mockito.Mockito.when) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) File(java.io.File) Mockito.verify(org.mockito.Mockito.verify) ApplyService(org.eclipse.jkube.kit.config.service.ApplyService) FileUtils(org.eclipse.jgit.util.FileUtils) TestOpenShiftExtension(org.eclipse.jkube.gradle.plugin.TestOpenShiftExtension) Rule(org.junit.Rule) After(org.junit.After) Mockito.mockConstruction(org.mockito.Mockito.mockConstruction) Collections(java.util.Collections) Before(org.junit.Before) MockedConstruction(org.mockito.MockedConstruction) Mockito.mock(org.mockito.Mockito.mock) ApplyService(org.eclipse.jkube.kit.config.service.ApplyService) ClusterAccess(org.eclipse.jkube.kit.config.access.ClusterAccess) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) TestOpenShiftExtension(org.eclipse.jkube.gradle.plugin.TestOpenShiftExtension) URL(java.net.URL) Before(org.junit.Before)

Example 5 with TestOpenShiftExtension

use of org.eclipse.jkube.gradle.plugin.TestOpenShiftExtension in project jkube by eclipse.

the class OpenShiftBuildTaskTest method setUp.

@Before
public void setUp() {
    openshiftBuildServiceMockedConstruction = mockConstruction(OpenshiftBuildService.class, (mock, ctx) -> when(mock.isApplicable()).thenReturn(true));
    final OpenShiftExtension extension = new TestOpenShiftExtension();
    when(taskEnvironment.project.getExtensions().getByType(OpenShiftExtension.class)).thenReturn(extension);
    extension.images = Collections.singletonList(ImageConfiguration.builder().name("foo/bar:latest").build(BuildConfiguration.builder().dockerFile("Dockerfile").build()).build());
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) OpenshiftBuildService(org.eclipse.jkube.kit.config.service.openshift.OpenshiftBuildService) BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) OpenShiftExtension(org.eclipse.jkube.gradle.plugin.OpenShiftExtension) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) TestOpenShiftExtension(org.eclipse.jkube.gradle.plugin.TestOpenShiftExtension) Rule(org.junit.Rule) After(org.junit.After) Mockito.mockConstruction(org.mockito.Mockito.mockConstruction) JKubeServiceException(org.eclipse.jkube.kit.config.service.JKubeServiceException) Collections(java.util.Collections) AssertionsForClassTypes.assertThat(org.assertj.core.api.AssertionsForClassTypes.assertThat) Before(org.junit.Before) MockedConstruction(org.mockito.MockedConstruction) OpenshiftBuildService(org.eclipse.jkube.kit.config.service.openshift.OpenshiftBuildService) OpenShiftExtension(org.eclipse.jkube.gradle.plugin.OpenShiftExtension) TestOpenShiftExtension(org.eclipse.jkube.gradle.plugin.TestOpenShiftExtension) TestOpenShiftExtension(org.eclipse.jkube.gradle.plugin.TestOpenShiftExtension) Before(org.junit.Before)

Aggregations

TestOpenShiftExtension (org.eclipse.jkube.gradle.plugin.TestOpenShiftExtension)9 Before (org.junit.Before)9 OpenShiftExtension (org.eclipse.jkube.gradle.plugin.OpenShiftExtension)5 After (org.junit.After)5 Rule (org.junit.Rule)5 Test (org.junit.Test)5 MockedConstruction (org.mockito.MockedConstruction)5 Mockito.mockConstruction (org.mockito.Mockito.mockConstruction)5 Mockito.when (org.mockito.Mockito.when)5 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)4 Mockito.times (org.mockito.Mockito.times)4 Mockito.verify (org.mockito.Mockito.verify)4 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)3 IOException (java.io.IOException)3 Collections (java.util.Collections)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 ClusterAccess (org.eclipse.jkube.kit.config.access.ClusterAccess)3 Assert.assertThrows (org.junit.Assert.assertThrows)3 Mockito.mock (org.mockito.Mockito.mock)3 URL (java.net.URL)2