@@ -307,13 +307,25 @@ public Optional<TestCase> findTestCaseBy(TestCaseStarted testCaseStarted) {
307
307
requireNonNull (testCaseStarted );
308
308
return ofNullable (testCaseById .get (testCaseStarted .getTestCaseId ()));
309
309
}
310
+
311
+ public Optional <TestCase > findTestCaseBy (TestCaseFinished testCaseFinished ) {
312
+ requireNonNull (testCaseFinished );
313
+ return findTestCaseStartedBy (testCaseFinished )
314
+ .flatMap (this ::findTestCaseBy );
315
+ }
310
316
311
317
public Optional <TestCase > findTestCaseBy (TestStepStarted testStepStarted ) {
312
318
requireNonNull (testStepStarted );
313
319
return findTestCaseStartedBy (testStepStarted )
314
320
.flatMap (this ::findTestCaseBy );
315
321
}
316
322
323
+ public Optional <TestCase > findTestCaseBy (TestStepFinished testStepFinished ) {
324
+ requireNonNull (testStepFinished );
325
+ return findTestCaseStartedBy (testStepFinished )
326
+ .flatMap (this ::findTestCaseBy );
327
+ }
328
+
317
329
public Optional <Duration > findTestCaseDurationBy (TestCaseStarted testCaseStarted ) {
318
330
requireNonNull (testCaseStarted );
319
331
Timestamp started = testCaseStarted .getTimestamp ();
@@ -324,13 +336,36 @@ public Optional<Duration> findTestCaseDurationBy(TestCaseStarted testCaseStarted
324
336
Convertor .toInstant (finished )
325
337
));
326
338
}
339
+
340
+ public Optional <Duration > findTestCaseDurationBy (TestCaseFinished testCaseFinished ) {
341
+ requireNonNull (testCaseFinished );
342
+ Timestamp finished = testCaseFinished .getTimestamp ();
343
+ return findTestCaseStartedBy (testCaseFinished )
344
+ .map (TestCaseStarted ::getTimestamp )
345
+ .map (started -> Duration .between (
346
+ Convertor .toInstant (started ),
347
+ Convertor .toInstant (finished )
348
+ ));
349
+ }
327
350
328
351
public Optional <TestCaseStarted > findTestCaseStartedBy (TestStepStarted testStepStarted ) {
329
352
requireNonNull (testStepStarted );
330
353
String testCaseStartedId = testStepStarted .getTestCaseStartedId ();
331
354
return ofNullable (testCaseStartedById .get (testCaseStartedId ));
332
355
}
333
356
357
+ private Optional <TestCaseStarted > findTestCaseStartedBy (TestCaseFinished testCaseFinished ) {
358
+ requireNonNull (testCaseFinished );
359
+ String testCaseStartedId = testCaseFinished .getTestCaseStartedId ();
360
+ return ofNullable (testCaseStartedById .get (testCaseStartedId ));
361
+ }
362
+
363
+ public Optional <TestCaseStarted > findTestCaseStartedBy (TestStepFinished testStepFinished ) {
364
+ requireNonNull (testStepFinished );
365
+ String testCaseStartedId = testStepFinished .getTestCaseStartedId ();
366
+ return ofNullable (testCaseStartedById .get (testCaseStartedId ));
367
+ }
368
+
334
369
public Optional <TestCaseFinished > findTestCaseFinishedBy (TestCaseStarted testCaseStarted ) {
335
370
requireNonNull (testCaseStarted );
336
371
return ofNullable (testCaseFinishedByTestCaseStartedId .get (testCaseStarted .getId ()));
0 commit comments