Search in sources :

Example 6 with ExecHelper

use of com.redhat.devtools.intellij.common.utils.ExecHelper in project intellij-tekton by redhat-developer.

the class TknCliTest method GetPipelineYAMLFromHub_PipelineAndVersion_Call.

@Test
public void GetPipelineYAMLFromHub_PipelineAndVersion_Call() throws IOException {
    MockedStatic<ExecHelper> exec = mockStatic(ExecHelper.class);
    exec.when(() -> ExecHelper.execute(anyString(), anyMap(), any())).thenReturn(null);
    String pipeline = "p1";
    String version = "v1";
    tkn.getPipelineYAMLFromHub(pipeline, version);
    exec.verify(() -> ExecHelper.execute(anyString(), anyMap(), eq("hub"), eq("get"), eq("pipeline"), eq(pipeline), eq("--version"), eq(version)));
    exec.close();
}
Also used : ExecHelper(com.redhat.devtools.intellij.common.utils.ExecHelper) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 7 with ExecHelper

use of com.redhat.devtools.intellij.common.utils.ExecHelper in project intellij-tekton by redhat-developer.

the class TknCliTest method checkRightArgsWhenStartingClusterTaskWithParameters.

@Test
public void checkRightArgsWhenStartingClusterTaskWithParameters() throws IOException {
    Map<String, Input> params = new HashMap<>();
    params.put("param1", new Input("param1", "string", Input.Kind.PARAMETER, "value1", Optional.empty(), Optional.empty()));
    params.put("param2", new Input("param2", "string", Input.Kind.PARAMETER, "value2", Optional.empty(), Optional.empty()));
    MockedStatic<ExecHelper> exec = mockStatic(ExecHelper.class);
    exec.when(() -> ExecHelper.execute(anyString(), anyMap(), any())).thenReturn("");
    tkn.startClusterTask("ns", "name", params, Collections.emptyMap(), Collections.emptyMap(), "", Collections.emptyMap(), "");
    exec.verify(() -> ExecHelper.execute(anyString(), anyMap(), eq("clustertask"), eq("start"), eq("name"), eq("-n"), eq("ns"), eq("-p"), eq("param1=value1"), eq("-p"), eq("param2=value2"), eq(FLAG_SKIP_OPTIONAL_WORKSPACES)));
    exec.close();
}
Also used : ExecHelper(com.redhat.devtools.intellij.common.utils.ExecHelper) Input(com.redhat.devtools.intellij.tektoncd.tkn.component.field.Input) HashMap(java.util.HashMap) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 8 with ExecHelper

use of com.redhat.devtools.intellij.common.utils.ExecHelper in project intellij-tekton by redhat-developer.

the class TknCliTest method checkRightArgsWhenStartingPipelineWithMultipleInputs.

@Test
public void checkRightArgsWhenStartingPipelineWithMultipleInputs() throws IOException {
    Map<String, Input> params = new HashMap<>();
    params.put("param1", new Input("param1", "string", Input.Kind.PARAMETER, "value1", Optional.empty(), Optional.empty()));
    Map<String, String> resources = new HashMap<>();
    resources.put("res1", "value1");
    resources.put("res2", "value2");
    Map<String, String> taskServiceAccount = new HashMap<>();
    taskServiceAccount.put("task1", "value1");
    Map<String, Workspace> workspaces = new HashMap<>();
    workspaces.put("work1", new Workspace("work1", Workspace.Kind.PVC, "value1"));
    workspaces.put("work2", new Workspace("work2", Workspace.Kind.SECRET, "value2"));
    MockedStatic<ExecHelper> exec = mockStatic(ExecHelper.class);
    exec.when(() -> ExecHelper.execute(anyString(), anyMap(), any())).thenReturn("");
    tkn.startPipeline("ns", "name", params, resources, "sa", taskServiceAccount, workspaces, "prefix");
    exec.verify(() -> ExecHelper.execute(anyString(), anyMap(), eq("pipeline"), eq("start"), eq("name"), eq("-n"), eq("ns"), eq("-s=sa"), eq("--task-serviceaccount"), eq("task1=value1"), eq("-w"), eq("name=work2,secret=value2"), eq("-w"), eq("name=work1,claimName=value1"), eq("-p"), eq("param1=value1"), eq("-r"), eq("res1=value1"), eq("-r"), eq("res2=value2"), eq("--prefix-name=prefix"), eq(FLAG_SKIP_OPTIONAL_WORKSPACES)));
    exec.close();
}
Also used : ExecHelper(com.redhat.devtools.intellij.common.utils.ExecHelper) Input(com.redhat.devtools.intellij.tektoncd.tkn.component.field.Input) HashMap(java.util.HashMap) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Workspace(com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace) Test(org.junit.Test)

Example 9 with ExecHelper

use of com.redhat.devtools.intellij.common.utils.ExecHelper in project intellij-tekton by redhat-developer.

the class TknCliTest method checkRightArgsWhenStartingClusterTaskWithWorkspaces.

@Test
public void checkRightArgsWhenStartingClusterTaskWithWorkspaces() throws IOException {
    Map<String, Workspace> workspaces = new HashMap<>();
    workspaces.put("work1", new Workspace("work1", Workspace.Kind.PVC, "value1"));
    workspaces.put("work2", new Workspace("work2", Workspace.Kind.CONFIGMAP, "value2"));
    workspaces.put("work3", new Workspace("work3", Workspace.Kind.SECRET, "value3"));
    workspaces.put("work4", new Workspace("work4", Workspace.Kind.EMPTYDIR, null));
    MockedStatic<ExecHelper> exec = mockStatic(ExecHelper.class);
    exec.when(() -> ExecHelper.execute(anyString(), anyMap(), any())).thenReturn("");
    tkn.startClusterTask("ns", "name", Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), "", workspaces, "");
    exec.verify(() -> ExecHelper.execute(anyString(), anyMap(), eq("clustertask"), eq("start"), eq("name"), eq("-n"), eq("ns"), eq("-w"), eq("name=work2,config=value2"), eq("-w"), eq("name=work1,claimName=value1"), eq("-w"), eq("name=work4,emptyDir="), eq("-w"), eq("name=work3,secret=value3"), eq(FLAG_SKIP_OPTIONAL_WORKSPACES)));
    exec.close();
}
Also used : ExecHelper(com.redhat.devtools.intellij.common.utils.ExecHelper) HashMap(java.util.HashMap) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Workspace(com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace) Test(org.junit.Test)

Example 10 with ExecHelper

use of com.redhat.devtools.intellij.common.utils.ExecHelper in project intellij-tekton by redhat-developer.

the class TknCliTest method checkNullIsReturnedWhenStartingClusterTaskReturnInvalidResult.

@Test
public void checkNullIsReturnedWhenStartingClusterTaskReturnInvalidResult() throws IOException {
    MockedStatic<ExecHelper> exec = mockStatic(ExecHelper.class);
    exec.when(() -> ExecHelper.execute(anyString(), anyMap(), any())).thenReturn("");
    String output = tkn.startClusterTask("ns", "name", Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), "", Collections.emptyMap(), "");
    exec.verify(() -> ExecHelper.execute(anyString(), anyMap(), eq("clustertask"), eq("start"), eq("name"), eq("-n"), eq("ns"), eq(FLAG_SKIP_OPTIONAL_WORKSPACES)));
    exec.close();
    assertNull(output);
}
Also used : ExecHelper(com.redhat.devtools.intellij.common.utils.ExecHelper) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

ExecHelper (com.redhat.devtools.intellij.common.utils.ExecHelper)16 Test (org.junit.Test)16 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)16 HashMap (java.util.HashMap)9 Input (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Input)6 Workspace (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace)6