public function provideMessages()
 {
     $localTaskListPosition = TaskListPosition::at(TaskListId::linkWith(NodeName::defaultName(), ProcessId::generate()), 1);
     $remoteTaskListPosition = TaskListPosition::at(TaskListId::linkWith(NodeName::fromString("remote-system"), ProcessId::generate()), 1);
     $wfMessageWithoutTaskListPosition = WorkflowMessage::collectDataOf(TestUser::prototype(), 'test-case', 'localhost');
     $expectedDataWfMessageWithoutTaskListPosition = ['message_id' => $wfMessageWithoutTaskListPosition->uuid()->toString(), 'message_name' => $wfMessageWithoutTaskListPosition->messageName(), 'version' => $wfMessageWithoutTaskListPosition->version(), 'task_list_position' => null, 'process_id' => null, 'status' => MessageStatus::PENDING, 'failure_msg' => null];
     $wfMessageWithTaskListPosition = WorkflowMessage::collectDataOf(TestUser::prototype(), 'test-case', 'localhost');
     $wfMessageWithTaskListPosition->connectToProcessTask($localTaskListPosition);
     $expectedDataWfMessageWithTaskListPosition = ['message_id' => $wfMessageWithTaskListPosition->uuid()->toString(), 'message_name' => $wfMessageWithTaskListPosition->messageName(), 'version' => $wfMessageWithTaskListPosition->version(), 'task_list_position' => $wfMessageWithTaskListPosition->processTaskListPosition()->toString(), 'process_id' => $wfMessageWithTaskListPosition->processTaskListPosition()->taskListId()->processId()->toString(), 'status' => MessageStatus::PENDING, 'failure_msg' => null];
     $logMessage = LogMessage::logDebugMsg("Log message", $wfMessageWithTaskListPosition);
     $expectedDataLogMessage = ['message_id' => $logMessage->uuid()->toString(), 'message_name' => $logMessage->messageName(), 'version' => 1, 'task_list_position' => $logMessage->processTaskListPosition()->toString(), 'process_id' => $logMessage->processTaskListPosition()->taskListId()->processId()->toString(), 'status' => MessageStatus::PENDING, 'failure_msg' => null];
     $startSubProcess = StartSubProcess::at($localTaskListPosition, ["process_type" => "faked"], false, "remote-system");
     $expectedDataStartSubProcess = ['message_id' => $startSubProcess->uuid()->toString(), 'message_name' => $startSubProcess->messageName(), 'version' => $startSubProcess->version(), 'task_list_position' => $startSubProcess->parentTaskListPosition()->toString(), 'process_id' => $startSubProcess->parentTaskListPosition()->taskListId()->processId()->toString(), 'status' => MessageStatus::PENDING, 'failure_msg' => null];
     $wfMessageWithRemoteTaskListPosition = WorkflowMessage::collectDataOf(TestUser::prototype(), 'test-case', 'localhost');
     $wfMessageWithRemoteTaskListPosition->connectToProcessTask($remoteTaskListPosition);
     $logMessageSubProcess = LogMessage::logErrorMsg("Faked error", $wfMessageWithRemoteTaskListPosition);
     $subProcessFinished = SubProcessFinished::record(NodeName::fromString("remote-system"), $remoteTaskListPosition->taskListId()->processId(), false, $logMessageSubProcess, $localTaskListPosition);
     $expectedDataSubProcessFinished = ['message_id' => $subProcessFinished->uuid()->toString(), 'message_name' => $subProcessFinished->messageName(), 'version' => $subProcessFinished->version(), 'task_list_position' => $logMessageSubProcess->processTaskListPosition()->toString(), 'process_id' => $logMessageSubProcess->processTaskListPosition()->taskListId()->processId()->toString(), 'status' => MessageStatus::PENDING, 'failure_msg' => null];
     return [[$wfMessageWithoutTaskListPosition, $expectedDataWfMessageWithoutTaskListPosition], [$wfMessageWithoutTaskListPosition->toServiceBusMessage(), $expectedDataWfMessageWithoutTaskListPosition], [$wfMessageWithTaskListPosition, $expectedDataWfMessageWithTaskListPosition], [$wfMessageWithTaskListPosition->toServiceBusMessage(), $expectedDataWfMessageWithTaskListPosition], [$logMessage, $expectedDataLogMessage], [$logMessage->toServiceBusMessage(), $expectedDataLogMessage], [$startSubProcess, $expectedDataStartSubProcess], [$startSubProcess->toServiceBusMessage(), $expectedDataStartSubProcess], [$subProcessFinished, $expectedDataSubProcessFinished], [$subProcessFinished->toServiceBusMessage(), $expectedDataSubProcessFinished]];
 }
Exemplo n.º 2
0
 /**
  * @test
  */
 public function it_translates_to_service_bus_message_and_back()
 {
     $nodeName = NodeName::fromString('other_machine');
     $subProcessId = ProcessId::generate();
     $parentTaskListPosition = TaskListPosition::at(TaskListId::linkWith(NodeName::defaultName(), ProcessId::generate()), 1);
     $wfMessage = $this->getUserDataCollectedTestMessage();
     $wfMessage->connectToProcessTask(TaskListPosition::at(TaskListId::linkWith($nodeName, $subProcessId), 1));
     $message = LogMessage::logDebugMsg("Processing finished", $wfMessage);
     $event = SubProcessFinished::record($nodeName, $subProcessId, true, $message, $parentTaskListPosition);
     $sbMessage = $event->toServiceBusMessage();
     $this->assertInstanceOf('Prooph\\Common\\Messaging\\RemoteMessage', $sbMessage);
     $copyOfEvent = SubProcessFinished::fromServiceBusMessage($sbMessage);
     $this->assertInstanceOf('Prooph\\Processing\\Processor\\Event\\SubProcessFinished', $copyOfEvent);
     $this->assertTrue($nodeName->equals($copyOfEvent->processorNodeName()));
     $this->assertTrue($parentTaskListPosition->equals($copyOfEvent->parentTaskListPosition()));
     $this->assertEquals($parentTaskListPosition->taskListId()->nodeName()->toString(), $copyOfEvent->target());
     $this->assertTrue($subProcessId->equals($copyOfEvent->subProcessId()));
     $this->assertTrue($copyOfEvent->succeed());
     $this->assertEquals($message->technicalMsg(), $copyOfEvent->lastMessage()->technicalMsg());
 }
 /**
  * @test
  */
 public function it_sends_a_sub_process_finished_event_via_message_dispatcher_to_a_handler()
 {
     $taskListPosition = TaskListPosition::at(TaskListId::linkWith(NodeName::defaultName(), ProcessId::generate()), 1);
     $wfMessage = $this->getUserDataCollectedTestMessage();
     $wfMessage->connectToProcessTask($taskListPosition);
     $logMessage = LogMessage::logDebugMsg("Just a fake event", $wfMessage);
     $subProcessFinished = SubProcessFinished::record(NodeName::defaultName(), $taskListPosition->taskListId()->processId(), true, $logMessage, $taskListPosition);
     $eventBus = new EventBus();
     $eventRouter = new EventRouter();
     $eventRouter->route(SubProcessFinished::MSG_NAME)->to($this->messageDispatcher);
     $eventBus->utilize($eventRouter);
     $eventBus->utilize(new ForwardToRemoteMessageDispatcherStrategy(new FromProcessingMessageTranslator()));
     $eventBus->dispatch($subProcessFinished);
     /** @var $receivedMessage SubProcessFinished */
     $receivedMessage = $this->receivedMessage;
     $this->assertInstanceOf(get_class($subProcessFinished), $receivedMessage);
     $this->assertTrue($taskListPosition->taskListId()->processId()->equals($receivedMessage->subProcessId()));
     $this->assertTrue($taskListPosition->equals($receivedMessage->parentTaskListPosition()));
     $this->assertTrue($subProcessFinished->uuid()->equals($receivedMessage->uuid()));
     $this->assertTrue($logMessage->uuid()->equals($receivedMessage->lastMessage()->uuid()));
     $this->assertEquals($logMessage->technicalMsg(), $receivedMessage->lastMessage()->technicalMsg());
     $this->assertEquals($subProcessFinished->createdAt()->format('Y-m-d H:i:s'), $receivedMessage->createdAt()->format('Y-m-d H:i:s'));
 }
Exemplo n.º 4
0
 private function informParentProcessAboutSubProcess(Process $subProcess, $succeed, $lastAnswerReceivedForSubProcess)
 {
     $event = SubProcessFinished::record($this->nodeName, $subProcess->processId(), $succeed, $lastAnswerReceivedForSubProcess, $subProcess->parentTaskListPosition());
     $this->workflowEngine->dispatch($event);
 }
 /**
  * @test
  */
 public function it_dispatches_a_sub_process_finished_event()
 {
     $taskListPosition = TaskListPosition::at(TaskListId::linkWith(NodeName::defaultName(), ProcessId::generate()), 1);
     $wfMessage = $this->getUserDataCollectedTestMessage();
     $wfMessage->connectToProcessTask($taskListPosition);
     $logMessage = LogMessage::logDebugMsg("Just a fake event", $wfMessage);
     $subProcessFinished = SubProcessFinished::record(NodeName::defaultName(), $taskListPosition->taskListId()->processId(), true, $logMessage, $taskListPosition);
     $this->workflowEngine->dispatch($subProcessFinished);
     $this->assertSame($subProcessFinished, $this->receivedMessage);
 }