Search in sources :

Example 51 with Task

use of com.google.cloud.tasks.v2.Task in project nomulus by google.

the class CloudTasksUtilsTest method testSuccess_createPostTasks_withZeroDelay.

@Test
void testSuccess_createPostTasks_withZeroDelay() {
    Task task = cloudTasksUtils.createPostTaskWithDelay("/the/path", "myservice", params, Duration.ZERO);
    assertThat(task.getAppEngineHttpRequest().getHttpMethod()).isEqualTo(HttpMethod.POST);
    assertThat(task.getAppEngineHttpRequest().getRelativeUri()).isEqualTo("/the/path");
    assertThat(task.getAppEngineHttpRequest().getAppEngineRouting().getService()).isEqualTo("myservice");
    assertThat(task.getAppEngineHttpRequest().getHeadersMap().get("Content-Type")).isEqualTo("application/x-www-form-urlencoded");
    assertThat(task.getAppEngineHttpRequest().getBody().toString(StandardCharsets.UTF_8)).isEqualTo("key1=val1&key2=val2&key1=val3");
    assertThat(task.getScheduleTime().getSeconds()).isEqualTo(0);
}
Also used : Task(com.google.cloud.tasks.v2.Task) Test(org.junit.jupiter.api.Test)

Example 52 with Task

use of com.google.cloud.tasks.v2.Task in project nomulus by google.

the class CloudTasksUtilsTest method testSuccess_createGetTasks_withNullParams.

@Test
void testSuccess_createGetTasks_withNullParams() {
    Task task = cloudTasksUtils.createGetTask("/the/path", "myservice", null);
    assertThat(task.getAppEngineHttpRequest().getHttpMethod()).isEqualTo(HttpMethod.GET);
    assertThat(task.getAppEngineHttpRequest().getRelativeUri()).isEqualTo("/the/path");
    assertThat(task.getAppEngineHttpRequest().getAppEngineRouting().getService()).isEqualTo("myservice");
    assertThat(task.getScheduleTime().getSeconds()).isEqualTo(0);
}
Also used : Task(com.google.cloud.tasks.v2.Task) Test(org.junit.jupiter.api.Test)

Example 53 with Task

use of com.google.cloud.tasks.v2.Task in project nomulus by google.

the class CloudTasksUtilsTest method testSuccess_createPostTasks_withEmptyJitterSeconds.

@Test
void testSuccess_createPostTasks_withEmptyJitterSeconds() {
    Task task = cloudTasksUtils.createPostTaskWithJitter("/the/path", "myservice", params, Optional.empty());
    assertThat(task.getAppEngineHttpRequest().getHttpMethod()).isEqualTo(HttpMethod.POST);
    assertThat(task.getAppEngineHttpRequest().getRelativeUri()).isEqualTo("/the/path");
    assertThat(task.getAppEngineHttpRequest().getAppEngineRouting().getService()).isEqualTo("myservice");
    assertThat(task.getAppEngineHttpRequest().getHeadersMap().get("Content-Type")).isEqualTo("application/x-www-form-urlencoded");
    assertThat(task.getAppEngineHttpRequest().getBody().toString(StandardCharsets.UTF_8)).isEqualTo("key1=val1&key2=val2&key1=val3");
    assertThat(task.getScheduleTime().getSeconds()).isEqualTo(0);
}
Also used : Task(com.google.cloud.tasks.v2.Task) Test(org.junit.jupiter.api.Test)

Example 54 with Task

use of com.google.cloud.tasks.v2.Task in project nomulus by google.

the class CloudTasksUtilsTest method testSuccess_createGetTasks_withDelay.

@Test
void testSuccess_createGetTasks_withDelay() {
    Task task = cloudTasksUtils.createGetTaskWithDelay("/the/path", "myservice", params, Duration.standardMinutes(10));
    assertThat(task.getAppEngineHttpRequest().getHttpMethod()).isEqualTo(HttpMethod.GET);
    assertThat(task.getAppEngineHttpRequest().getRelativeUri()).isEqualTo("/the/path?key1=val1&key2=val2&key1=val3");
    assertThat(task.getAppEngineHttpRequest().getAppEngineRouting().getService()).isEqualTo("myservice");
    assertThat(Instant.ofEpochSecond(task.getScheduleTime().getSeconds())).isEqualTo(Instant.ofEpochMilli(clock.nowUtc().plusMinutes(10).getMillis()));
}
Also used : Task(com.google.cloud.tasks.v2.Task) Test(org.junit.jupiter.api.Test)

Example 55 with Task

use of com.google.cloud.tasks.v2.Task in project nomulus by google.

the class CloudTasksUtilsTest method testSuccess_createPostTasks_withEmptyParams.

@Test
void testSuccess_createPostTasks_withEmptyParams() {
    Task task = cloudTasksUtils.createPostTask("/the/path", "myservice", ImmutableMultimap.of());
    assertThat(task.getAppEngineHttpRequest().getHttpMethod()).isEqualTo(HttpMethod.POST);
    assertThat(task.getAppEngineHttpRequest().getRelativeUri()).isEqualTo("/the/path");
    assertThat(task.getAppEngineHttpRequest().getAppEngineRouting().getService()).isEqualTo("myservice");
    assertThat(task.getAppEngineHttpRequest().getBody().toString(StandardCharsets.UTF_8)).isEmpty();
    assertThat(task.getScheduleTime().getSeconds()).isEqualTo(0);
}
Also used : Task(com.google.cloud.tasks.v2.Task) Test(org.junit.jupiter.api.Test)

Aggregations

Task (com.google.cloud.tasks.v2.Task)33 Test (org.junit.jupiter.api.Test)23 Task (org.eclipse.bpmn2.Task)17 Test (org.junit.Test)14 CloudTasksClient (com.google.cloud.tasks.v2.CloudTasksClient)11 Task (io.fabric8.tekton.pipeline.v1beta1.Task)8 ByteString (com.google.protobuf.ByteString)7 IOException (java.io.IOException)6 Optional (java.util.Optional)5 FlowElement (org.eclipse.bpmn2.FlowElement)5 InputSet (org.eclipse.bpmn2.InputSet)5 AssignmentsInfo (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo)5 Queue (com.google.cloud.tasks.v2.Queue)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)4 BusinessRuleTask (org.eclipse.bpmn2.BusinessRuleTask)4 GlobalTask (org.eclipse.bpmn2.GlobalTask)4 OutputSet (org.eclipse.bpmn2.OutputSet)4 Process (org.eclipse.bpmn2.Process)4