Search in sources :

Example 16 with AddTriggerModel

use of com.redhat.devtools.intellij.tektoncd.utils.model.actions.AddTriggerModel in project intellij-tekton by redhat-developer.

the class YAMLBuilderTest method checkPipelineRunCreatedHasWorkspace.

@Test
public void checkPipelineRunCreatedHasWorkspace() throws IOException {
    String content = load("pipeline5.yaml");
    AddTriggerModel model = new AddTriggerModel(content, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyMap());
    if (model.getWorkspaces().containsKey("password-vault")) {
        model.getWorkspaces().put("password-vault", new Workspace("foo1", Workspace.Kind.EMPTYDIR, "foo"));
    }
    if (model.getWorkspaces().containsKey("recipe-store")) {
        model.getWorkspaces().put("recipe-store", new Workspace("foo2", Workspace.Kind.EMPTYDIR, "foo"));
    }
    ObjectNode pipelineRunNode = YAMLBuilder.createPipelineRun(model);
    assertEquals(pipelineRunNode.get("apiVersion").asText(), "tekton.dev/v1beta1");
    assertEquals(pipelineRunNode.get("kind").asText(), "PipelineRun");
    assertEquals(pipelineRunNode.get("metadata").get("generateName").asText(), "foo-");
    assertEquals(pipelineRunNode.get("spec").get("pipelineRef").get("name").asText(), "foo");
    assertFalse(pipelineRunNode.get("spec").has("serviceAccountName"));
    assertFalse(pipelineRunNode.get("spec").has("serviceAccountNames"));
    assertFalse(pipelineRunNode.get("spec").has("params"));
    assertFalse(pipelineRunNode.get("spec").has("resources"));
    assertTrue(pipelineRunNode.get("spec").has("workspaces"));
    assertEquals(pipelineRunNode.get("spec").get("workspaces").get(0).get("name").asText(), "foo1");
    assertEquals(pipelineRunNode.get("spec").get("workspaces").get(1).get("name").asText(), "foo2");
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) AddTriggerModel(com.redhat.devtools.intellij.tektoncd.utils.model.actions.AddTriggerModel) Workspace(com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace) Test(org.junit.Test) BaseTest(com.redhat.devtools.intellij.tektoncd.BaseTest)

Aggregations

AddTriggerModel (com.redhat.devtools.intellij.tektoncd.utils.model.actions.AddTriggerModel)16 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)14 BaseTest (com.redhat.devtools.intellij.tektoncd.BaseTest)13 Test (org.junit.Test)13 Workspace (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace)2 BORDER_LABEL_NAME (com.redhat.devtools.intellij.tektoncd.ui.UIConstants.BORDER_LABEL_NAME)2 Color (java.awt.Color)2 Font (java.awt.Font)2 GridBagConstraints (java.awt.GridBagConstraints)2 Map (java.util.Map)2 Ints (com.google.common.primitives.Ints)1 AllIcons (com.intellij.icons.AllIcons)1 Notification (com.intellij.notification.Notification)1 ComboBox (com.intellij.openapi.ui.ComboBox)1 IconLoader (com.intellij.openapi.util.IconLoader)1 JBList (com.intellij.ui.components.JBList)1 JBScrollPane (com.intellij.ui.components.JBScrollPane)1 Input (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Input)1 ParentableNode (com.redhat.devtools.intellij.tektoncd.tree.ParentableNode)1 PipelineNode (com.redhat.devtools.intellij.tektoncd.tree.PipelineNode)1