/** * @param array $payload * @return ChapterStatus */ private static function payloadToChapterStatus(array $payload) { return ChapterStatus::fromHistoryStatus(ChapterName::fromString($payload['chapter_name']), ChapterNumber::fromString($payload['chapter_number']), $payload['status'], $payload['retry_count'], $payload['retry_limit']); }
/** * @test * @expectedException \Prooph\Done\Shared\Exception\ChapterStatus */ public function it_does_not_allow_to_mark_a_done_chapter_as_failed() { $chapterStatus = ChapterStatus::chapterWasStarted($this->getChapterName(), $this->getChapterNumber()); $chapterStatus = $chapterStatus->markChapterAsDone(); $chapterStatus->markChapterAsFailed(); }
/** * @param ChapterStatus $chapterStatus * @param ChapterTemplate $chapterTemplate * @param Message $receivedMessage * @param MessageConverter $messageConverter * @param MessageFactory $messageFactory * @param StoryName $storyName */ private function handleFailedChapter(ChapterStatus $chapterStatus, ChapterTemplate $chapterTemplate, Message $receivedMessage, MessageConverter $messageConverter, MessageFactory $messageFactory, StoryName $storyName) { $failedStatus = $chapterStatus->markChapterAsFailed(); $this->recordThat(ChapterFailed::withStatusByMessage($failedStatus, $messageConverter->convertToArray($receivedMessage))); if ($failedStatus->isRetryPossible()) { $retryStatus = $failedStatus->retry(); $startMessage = $this->getOriginalStartMessageForChapterNumber($retryStatus->chapterNumber(), $messageFactory); $chapterCommand = $chapterTemplate->startChapter($storyName, $retryStatus->chapterNumber(), $startMessage); $this->recordThat(ChapterRetryWasStarted::withStatusByMessage($retryStatus, $messageConverter->convertToArray($chapterCommand))); $this->nextCommands[] = $chapterCommand; return; } $this->recordThat(StoryFailed::withStoryIdAndName($failedStatus->chapterNumber()->storyId(), $storyName)); }