Search in sources :

Example 6 with TaskConfigurationModel

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

the class TaskConfigurationModelTest method checkTaskModelWithOutputResources.

@Test
public void checkTaskModelWithOutputResources() throws IOException {
    String configuration = load("task9.yaml");
    TaskConfigurationModel model = (TaskConfigurationModel) ConfigurationModelFactory.getModel(configuration);
    assertEquals(model.getName(), "foo");
    assertEquals(model.getNamespace(), "tekton");
    assertEquals(model.getKind(), "Task");
    assertTrue(model.getParams().isEmpty());
    assertTrue(model.getInputResources().isEmpty());
    assertTrue(model.getOutputResources().size() == 2);
    assertEquals(model.getOutputResources().get(0).name(), "resource1");
    assertEquals(model.getOutputResources().get(0).type(), "image");
    assertEquals(model.getOutputResources().get(1).name(), "resource2");
    assertEquals(model.getOutputResources().get(1).type(), "image");
    assertTrue(model.getWorkspaces().isEmpty());
}
Also used : TaskConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.TaskConfigurationModel) Test(org.junit.Test) BaseTest(com.redhat.devtools.intellij.tektoncd.BaseTest)

Example 7 with TaskConfigurationModel

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

the class YAMLBuilderTest method checkTaskRunCreatedWithTaskConfigurationModelWithoutWorkspace.

@Test
public void checkTaskRunCreatedWithTaskConfigurationModelWithoutWorkspace() throws IOException {
    String content = load("task5.yaml");
    TaskConfigurationModel model = new TaskConfigurationModel(content);
    ObjectNode taskRunNode = YAMLBuilder.createTaskRun(model);
    assertEquals(taskRunNode.get("apiVersion").asText(), "tekton.dev/v1beta1");
    assertEquals(taskRunNode.get("kind").asText(), "TaskRun");
    assertEquals(taskRunNode.get("metadata").get("generateName").asText(), "foo-");
    assertEquals(taskRunNode.get("spec").get("taskRef").get("name").asText(), "foo");
    assertTrue(taskRunNode.get("spec").has("serviceAccountName"));
    assertEquals(taskRunNode.get("spec").get("serviceAccountName").asText(), "");
    assertFalse(taskRunNode.get("spec").has("serviceAccountNames"));
    assertTrue(taskRunNode.get("spec").has("params"));
    assertFalse(taskRunNode.get("spec").has("resources"));
    assertFalse(taskRunNode.get("spec").has("workspaces"));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) TaskConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.TaskConfigurationModel) Test(org.junit.Test) BaseTest(com.redhat.devtools.intellij.tektoncd.BaseTest)

Example 8 with TaskConfigurationModel

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

the class ConfigurationModelFactoryTest method checkTaskModelIsReturned.

@Test
public void checkTaskModelIsReturned() throws IOException {
    String configuration = load("task1.yaml");
    ConfigurationModel model = ConfigurationModelFactory.getModel(configuration);
    assertTrue(model instanceof TaskConfigurationModel);
}
Also used : ConditionConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.ConditionConfigurationModel) TaskConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.TaskConfigurationModel) PipelineConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel) TaskConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.TaskConfigurationModel) Test(org.junit.Test) BaseTest(com.redhat.devtools.intellij.tektoncd.BaseTest)

Example 9 with TaskConfigurationModel

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

the class TaskConfigurationModelTest method checkTaskModelWithParams.

@Test
public void checkTaskModelWithParams() throws IOException {
    String configuration = load("task2.yaml");
    TaskConfigurationModel model = (TaskConfigurationModel) ConfigurationModelFactory.getModel(configuration);
    assertEquals(model.getName(), "foo");
    assertEquals(model.getNamespace(), "tekton");
    assertEquals(model.getKind(), "Task");
    assertTrue(model.getParams().size() == 1);
    assertEquals(model.getParams().get(0).name(), "parm1");
    assertTrue(model.getInputResources().isEmpty());
    assertTrue(model.getOutputResources().isEmpty());
    assertTrue(model.getWorkspaces().isEmpty());
}
Also used : TaskConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.TaskConfigurationModel) Test(org.junit.Test) BaseTest(com.redhat.devtools.intellij.tektoncd.BaseTest)

Example 10 with TaskConfigurationModel

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

the class TaskConfigurationModelTest method checkTaskModelWithInputResources.

@Test
public void checkTaskModelWithInputResources() throws IOException {
    String configuration = load("task7.yaml");
    TaskConfigurationModel model = (TaskConfigurationModel) ConfigurationModelFactory.getModel(configuration);
    assertEquals(model.getName(), "foo");
    assertEquals(model.getNamespace(), "tekton");
    assertEquals(model.getKind(), "Task");
    assertTrue(model.getParams().isEmpty());
    assertTrue(model.getInputResources().size() == 2);
    assertEquals(model.getInputResources().get(0).name(), "resource1");
    assertEquals(model.getInputResources().get(0).type(), "git");
    assertEquals(model.getInputResources().get(1).name(), "resource2");
    assertEquals(model.getInputResources().get(1).type(), "git");
    assertTrue(model.getOutputResources().isEmpty());
    assertTrue(model.getWorkspaces().isEmpty());
}
Also used : TaskConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.TaskConfigurationModel) Test(org.junit.Test) BaseTest(com.redhat.devtools.intellij.tektoncd.BaseTest)

Aggregations

TaskConfigurationModel (com.redhat.devtools.intellij.tektoncd.utils.model.resources.TaskConfigurationModel)12 BaseTest (com.redhat.devtools.intellij.tektoncd.BaseTest)9 Test (org.junit.Test)9 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 YAMLMapper (com.fasterxml.jackson.dataformat.yaml.YAMLMapper)2 Input (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Input)2 Output (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Output)2 Workspace (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace)2 ConfigurationModel (com.redhat.devtools.intellij.tektoncd.utils.model.ConfigurationModel)2 PipelineConfigurationModel (com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel)2 IOException (java.io.IOException)2 List (java.util.List)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 WRITE_DOC_START_MARKER (com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature.WRITE_DOC_START_MARKER)1 InspectionManager (com.intellij.codeInspection.InspectionManager)1 LocalQuickFix (com.intellij.codeInspection.LocalQuickFix)1 ProblemDescriptor (com.intellij.codeInspection.ProblemDescriptor)1