use of com.google.cloud.tasks.v2.Task in project nomulus by google.
the class CloudTasksUtilsTest method testSuccess_enqueueTasks_iterable.
@Test
void testSuccess_enqueueTasks_iterable() {
Task task1 = cloudTasksUtils.createGetTask("/the/path", "myservice", params);
Task task2 = cloudTasksUtils.createGetTask("/other/path", "yourservice", params);
cloudTasksUtils.enqueue("test-queue", ImmutableList.of(task1, task2));
verify(mockClient).enqueue("project", "location", "test-queue", task1);
verify(mockClient).enqueue("project", "location", "test-queue", task2);
}
use of com.google.cloud.tasks.v2.Task in project nomulus by google.
the class CloudTasksUtilsTest method testSuccess_createGetTasks_withJitterSeconds.
@SuppressWarnings("ProtoTimestampGetSecondsGetNano")
@Test
void testSuccess_createGetTasks_withJitterSeconds() {
Task task = cloudTasksUtils.createGetTaskWithJitter("/the/path", "myservice", params, Optional.of(100));
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");
Instant scheduleTime = Instant.ofEpochSecond(task.getScheduleTime().getSeconds());
Instant lowerBoundTime = Instant.ofEpochMilli(clock.nowUtc().getMillis());
Instant upperBound = Instant.ofEpochMilli(clock.nowUtc().plusSeconds(100).getMillis());
assertThat(scheduleTime.isBefore(lowerBoundTime)).isFalse();
assertThat(upperBound.isBefore(scheduleTime)).isFalse();
}
use of com.google.cloud.tasks.v2.Task in project nomulus by google.
the class CloudTasksUtilsTest method testSuccess_createGetTasks.
@Test
void testSuccess_createGetTasks() {
Task task = cloudTasksUtils.createGetTask("/the/path", "myservice", params);
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(task.getScheduleTime().getSeconds()).isEqualTo(0);
}
use of com.google.cloud.tasks.v2.Task in project petals-se-flowable by petalslink.
the class ServiceProviderCallActivityProcessTest method nominal.
/**
* <p>
* Check the message processing where: a valid request is sent to create a new process instance from web channel.
* </p>
* <p>
* Expected results:
* </p>
* <ul>
* <li>the process instance is correctly created in the Flowable engine,</li>
* <li>the process instance is automatically completed with the right service call.</li>
* </ul>
*/
@Test
public void nominal() throws Exception {
final GregorianCalendar now = new GregorianCalendar();
// Create a new instance of the process definition
final StringBuilder callActivityId_level1 = new StringBuilder();
final StringBuilder callActivityId_level2 = new StringBuilder();
{
final Start start = new Start();
start.setCustomer(BPMN_USER);
start.setAddress(CUSTOMER_ADRESS);
start.setDate(now.getTime());
// Send the 1st valid request for start event 'request
final RequestToProviderMessage request_1 = new RequestToProviderMessage(COMPONENT_UNDER_TEST, CALL_ACTIVITY_PROVIDER_SU, OPERATION_START, AbsItfOperation.MEPPatternConstants.IN_OUT.value(), toByteArray(start));
// Assert the response of the 1st valid request
final ServiceProviderImplementation archiverServiceImpl = this.getArchiveAttachmentsServiceImpl(new ArchiverResponse(), now, callActivityId_level2);
COMPONENT.sendAndCheckResponseAndSendStatus(request_1, archiverServiceImpl, new MessageChecks() {
@Override
public void checks(final Message message) throws Exception {
// Check the reply
final Source fault = message.getFault();
assertNull("Unexpected fault", (fault == null ? null : SourceHelper.toString(fault)));
assertNotNull("No XML payload in response", message.getPayload());
final Object responseObj = UNMARSHALLER.unmarshal(message.getPayload());
assertTrue(responseObj instanceof StartResponse);
final StartResponse response = (StartResponse) responseObj;
assertNotNull(response.getCaseFileNumber());
callActivityId_level1.append(response.getCaseFileNumber());
}
}, ExchangeStatus.DONE);
}
// Wait the request of the 2nd service task
final String callActivityId_level3;
{
final RequestMessage coreServiceRequestMsg = COMPONENT_UNDER_TEST.pollRequestFromConsumer();
assertNotNull("No XML payload in response", coreServiceRequestMsg.getPayload());
final Object coreServiceRequestObj = UNMARSHALLER.unmarshal(coreServiceRequestMsg.getPayload());
assertTrue(coreServiceRequestObj instanceof Execute);
final Execute coreServiceRequest = (Execute) coreServiceRequestObj;
callActivityId_level3 = coreServiceRequest.getOrderId();
final ResponseMessage coreServiceResponseMsg = new ResponseToConsumerMessage(coreServiceRequestMsg, toByteArray(new ExecuteResponse()));
COMPONENT_UNDER_TEST.pushResponseToConsumer(coreServiceResponseMsg);
final StatusMessage coreServiceStatusMsg = COMPONENT_UNDER_TEST.pollStatusFromConsumer();
assertEquals(ExchangeStatus.DONE, coreServiceStatusMsg.getStatus());
}
this.assertProcessInstancePending(callActivityId_level1.toString(), "processLevel1");
this.assertProcessInstancePending(callActivityId_level2.toString(), "processLevel2");
// TODO: Investigate why the process instance level 3 is not finished here. Perhaps not yet in historic part
// assertProcessInstanceFinished(callActivityId_level3);
this.waitUserTaskAssignment(callActivityId_level2.toString(), "usertask1", BPMN_USER);
this.assertCurrentUserTask(callActivityId_level2.toString(), "usertask1", BPMN_USER);
// Check some variables of process instances
{
final ProcessInstanceQuery processInstQuery = this.flowableClient.getRuntimeService().createProcessInstanceQuery();
final ProcessInstance processInstance = processInstQuery.processInstanceId(callActivityId_level1.toString()).includeProcessVariables().singleResult();
assertNotNull(processInstance.getProcessVariables().get("date"));
// 'date' is a java.util.Date
assertEquals(now.getTime(), processInstance.getProcessVariables().get("date"));
}
{
final ProcessInstanceQuery processInstQuery = this.flowableClient.getRuntimeService().createProcessInstanceQuery();
final ProcessInstance processInstance = processInstQuery.processInstanceId(callActivityId_level2.toString()).includeProcessVariables().singleResult();
assertNotNull(processInstance.getProcessVariables().get("dateLevel2"));
// 'dateLevel2' is a date represented as a String using ISO format
assertEquals(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX").format(now.getTime()), processInstance.getProcessVariables().get("dateLevel2"));
}
// Retrieve the user task basket using integration service
{
final GetTasks getTasksReq = new GetTasks();
getTasksReq.setActive(true);
getTasksReq.setAssignee(BPMN_USER);
// getTasksReq.setProcessInstanceIdentifier(processInstanceId);
final RequestToProviderMessage requestM = new RequestToProviderMessage(COMPONENT_UNDER_TEST, NATIVE_TASKS_SVC_CFG, ITG_OP_GETTASKS, AbsItfOperation.MEPPatternConstants.IN_OUT.value(), toByteArray(getTasksReq));
final ResponseMessage getTaskRespMsg = COMPONENT.sendAndGetResponse(requestM);
assertNotNull("No XML payload in response", getTaskRespMsg.getPayload());
final Object getTaskRespObj = UNMARSHALLER.unmarshal(getTaskRespMsg.getPayload());
assertTrue(getTaskRespObj instanceof GetTasksResponse);
final GetTasksResponse getTaskResp = (GetTasksResponse) getTaskRespObj;
assertNotNull(getTaskResp.getTasks());
assertNotNull(getTaskResp.getTasks().getTask());
assertEquals(1, getTaskResp.getTasks().getTask().size());
final Task task = getTaskResp.getTasks().getTask().get(0);
assertEquals("processLevel2", task.getProcessDefinitionIdentifier());
assertEquals(callActivityId_level2.toString(), task.getProcessInstanceIdentifier());
assertEquals("usertask1", task.getTaskIdentifier());
COMPONENT.sendDoneStatus(getTaskRespMsg);
}
// Complete the user task
{
final Unlock userTaskRequest = new Unlock();
userTaskRequest.setCallActivityId(callActivityId_level2.toString());
userTaskRequest.setUnlocker(BPMN_USER);
final RequestToProviderMessage userTaskRequestMsg = new RequestToProviderMessage(COMPONENT_UNDER_TEST, CALL_ACTIVITY_PROVIDER_SU, OPERATION_UNLOCK, AbsItfOperation.MEPPatternConstants.IN_OUT.value(), toByteArray(userTaskRequest));
final ResponseMessage userTaskResponseMsg = COMPONENT.sendAndGetResponse(userTaskRequestMsg);
COMPONENT.sendStatus(new StatusToProviderMessage(userTaskResponseMsg, ExchangeStatus.DONE), false);
// Check the reply
assertNull("Unexpected fault", (userTaskResponseMsg.isFault() ? SourceHelper.toString(userTaskResponseMsg.getFault()) : null));
assertNotNull("No XML payload in response", userTaskResponseMsg.getPayload());
final Object userTaskResponseObj = UNMARSHALLER.unmarshal(userTaskResponseMsg.getPayload());
assertTrue(userTaskResponseObj instanceof UnlockAck);
}
// Wait the end of the process instance
this.waitEndOfProcessInstance(callActivityId_level1.toString());
// Assertions about state of process instance at Flowable Level
this.assertProcessInstanceFinished(callActivityId_level1.toString());
// Check MONIT traces
final List<LogRecord> allMonitLogs = IN_MEMORY_LOG_HANDLER.getAllRecords(Level.MONIT);
final LogRecord firstLogOfProcessService = new MonitLogFilter(allMonitLogs).traceCode(TraceCode.PROVIDE_FLOW_STEP_BEGIN).interfaceName(new QName("http://petals.ow2.org/se-flowable/unit-test/call-activity/level1", "call-activity")).serviceName(new QName("http://petals.ow2.org/se-flowable/unit-test/call-activity/level1", "call-activity-service")).operationName(new QName("http://petals.ow2.org/se-flowable/unit-test/call-activity/level1", "start")).singleResult();
final String flowInstanceIdProcessService = (String) ((FlowLogData) firstLogOfProcessService.getParameters()[0]).get(FlowLogData.FLOW_INSTANCE_ID_PROPERTY_NAME);
final LogRecord firstLogOfProcess = new MonitLogFilter(allMonitLogs).traceCode(TraceCode.CONSUME_EXT_FLOW_STEP_BEGIN).property(FlowLogData.CORRELATED_FLOW_INSTANCE_ID_PROPERTY_NAME, flowInstanceIdProcessService).singleResult();
final String flowInstanceIdProcess = (String) ((FlowLogData) firstLogOfProcess.getParameters()[0]).get(FlowLogData.FLOW_INSTANCE_ID_PROPERTY_NAME);
final List<LogRecord> processMonitLogs = new MonitLogFilter(allMonitLogs).flowInstanceId(flowInstanceIdProcess).results();
assertEquals(12, processMonitLogs.size());
final FlowLogData initialProcessFlowLogData = assertMonitConsumerExtBeginLog(processMonitLogs.get(0));
final String processInstanceId = (String) initialProcessFlowLogData.get(FlowableActivityFlowStepData.PROCESS_INSTANCE_ID_KEY);
assertNotNull("process instance id missing in log trace", processInstanceId);
final FlowLogData firstCallActivity = assertMonitProviderBeginLog(initialProcessFlowLogData, null, null, null, null, processMonitLogs.get(1));
assertEquals(processInstanceId, firstCallActivity.get(FlowableActivityFlowStepData.PROCESS_INSTANCE_ID_KEY));
assertEquals("processLevel2", firstCallActivity.get(FlowableActivityFlowStepData.CALL_ACTIVITY_DEFINITION_KEY));
final String callActivityInstanceId_1 = (String) firstCallActivity.get(FlowableActivityFlowStepData.CALL_ACTIVITY_INSTANCE_ID_KEY);
assertNotNull("call activity instance id missing in log trace", callActivityInstanceId_1);
final FlowLogData archiverFlowLogData = assertMonitProviderBeginLog(firstCallActivity, ARCHIVE_INTERFACE, ARCHIVE_SERVICE, ARCHIVE_ENDPOINT, ARCHIVER_OPERATION, processMonitLogs.get(2));
assertMonitProviderEndLog(archiverFlowLogData, processMonitLogs.get(3));
// TODO: Uncomment following block when problem about flowStepId/previousFlowStepId on two consecutive
// service tasks will be checked. See:
// https://cdeneux.framaboard.org/?controller=TaskViewController&action=show&task_id=251&project_id=1
/*
final FlowLogData secondCallActivity = assertMonitProviderBeginLog(archiverFlowLogData, null, null, null,
null, processMonitLogs.get(4));
assertEquals(callActivityInstanceId_1,
secondCallActivity.get(FlowableActivityFlowStepData.PROCESS_INSTANCE_ID_KEY));
assertEquals("processLevel3",
secondCallActivity.get(FlowableActivityFlowStepData.CALL_ACTIVITY_DEFINITION_KEY));
final String callActivityInstanceId_2 = (String) secondCallActivity
.get(FlowableActivityFlowStepData.CALL_ACTIVITY_INSTANCE_ID_KEY);
assertNotNull("call activity instance id missing in log trace", callActivityInstanceId_2);
assertMonitProviderEndLog(assertMonitProviderBeginLog(secondCallActivity, CORE_SVC_INTERFACE, CORE_SVC_SERVICE,
CORE_SVC_ENDPOINT, CORE_SVC_OPERATION, processMonitLogs.get(5)), processMonitLogs.get(6));
*/
}
use of com.google.cloud.tasks.v2.Task in project dekorate by dekorateio.
the class SpringBootWithTektonTest method shouldContainPipelineWithM2Workspace.
@Test
public void shouldContainPipelineWithM2Workspace() {
KubernetesList list = Serialization.unmarshalAsList(getClass().getClassLoader().getResourceAsStream("META-INF/dekorate/tekton-pipeline.yml"));
assertNotNull(list);
Pipeline p = findFirst(list, Pipeline.class).orElseThrow(() -> new IllegalStateException());
assertNotNull(p);
assertTrue(p.getSpec().getWorkspaces().stream().filter(w -> w.getName().equals("pipeline-m2-ws")).findAny().isPresent(), "Pipeline should contain workspace named 'pipeline-m2-ws'");
Optional<PipelineTask> buildTask = findTask("project-build", p);
assertTrue(buildTask.isPresent());
assertTrue(buildTask.get().getWorkspaces().stream().filter(w -> w.getName().equals("m2") && w.getWorkspace().equals("pipeline-m2-ws")).findAny().isPresent(), "Build task should contain workspace 'm2 -> pipeline-m2-ws'");
}
Aggregations