|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Keboola\NotificationClient\Tests\Requests\PostEvent; |
| 6 | + |
| 7 | +use DateTimeImmutable; |
| 8 | +use Keboola\NotificationClient\Requests\PostEvent\JobData; |
| 9 | +use Keboola\NotificationClient\Requests\PostEvent\JobFailedEventData; |
| 10 | +use Keboola\NotificationClient\Requests\PostEvent\JobProcessingLongEventData; |
| 11 | +use PHPUnit\Framework\TestCase; |
| 12 | + |
| 13 | +class JobProcessingLongEventDataTest extends TestCase |
| 14 | +{ |
| 15 | + public function testJsonSerialize(): void |
| 16 | + { |
| 17 | + $jobData = new JobData( |
| 18 | + '23456', |
| 19 | + 'http://someUrl', |
| 20 | + new DateTimeImmutable('2020-01-01T11:11:00+00:00'), |
| 21 | + new DateTimeImmutable('2020-01-01T12:11:00+00:00'), |
| 22 | + 'keboola.orchestrator', |
| 23 | + 'Orchestrator', |
| 24 | + 'my-configuration', |
| 25 | + 'My configuration' |
| 26 | + ); |
| 27 | + $failedEventData = new JobProcessingLongEventData('1234', 'My project', 12.534, 23.854, 12.0, $jobData); |
| 28 | + self::assertSame( |
| 29 | + [ |
| 30 | + 'averageDuration' => 23.854, |
| 31 | + 'currentDuration' => 12.0, |
| 32 | + 'durationOvertimePercentage' => 12.534, |
| 33 | + 'job' => [ |
| 34 | + 'id' => '23456', |
| 35 | + 'url' => 'http://someUrl', |
| 36 | + 'component' => [ |
| 37 | + 'id' => 'keboola.orchestrator', |
| 38 | + 'name' => 'Orchestrator', |
| 39 | + ], |
| 40 | + 'tasks' => [], |
| 41 | + 'startTime' => '2020-01-01T11:11:00+00:00', |
| 42 | + 'endTime' => '2020-01-01T12:11:00+00:00', |
| 43 | + 'configuration' => [ |
| 44 | + 'id' => 'my-configuration', |
| 45 | + 'name' => 'My configuration', |
| 46 | + ], |
| 47 | + ], |
| 48 | + 'project' => [ |
| 49 | + 'id' => '1234', |
| 50 | + 'name' => 'My project', |
| 51 | + ], |
| 52 | + ], |
| 53 | + $failedEventData->jsonSerialize() |
| 54 | + ); |
| 55 | + self::assertEquals('job-processing-long', $failedEventData::getEventTypeName()); |
| 56 | + } |
| 57 | +} |
0 commit comments