@@ -280,13 +280,25 @@ public Optional<TestCase> findTestCaseBy(TestCaseStarted testCaseStarted) {
280
280
requireNonNull (testCaseStarted );
281
281
return ofNullable (testCaseById .get (testCaseStarted .getTestCaseId ()));
282
282
}
283
+
284
+ public Optional <TestCase > findTestCaseBy (TestCaseFinished testCaseFinished ) {
285
+ requireNonNull (testCaseFinished );
286
+ return findTestCaseStartedBy (testCaseFinished )
287
+ .flatMap (this ::findTestCaseBy );
288
+ }
283
289
284
290
public Optional <TestCase > findTestCaseBy (TestStepStarted testStepStarted ) {
285
291
requireNonNull (testStepStarted );
286
292
return findTestCaseStartedBy (testStepStarted )
287
293
.flatMap (this ::findTestCaseBy );
288
294
}
289
295
296
+ public Optional <TestCase > findTestCaseBy (TestStepFinished testStepFinished ) {
297
+ requireNonNull (testStepFinished );
298
+ return findTestCaseStartedBy (testStepFinished )
299
+ .flatMap (this ::findTestCaseBy );
300
+ }
301
+
290
302
public Optional <Duration > findTestCaseDurationBy (TestCaseStarted testCaseStarted ) {
291
303
requireNonNull (testCaseStarted );
292
304
Timestamp started = testCaseStarted .getTimestamp ();
@@ -297,13 +309,36 @@ public Optional<Duration> findTestCaseDurationBy(TestCaseStarted testCaseStarted
297
309
Convertor .toInstant (finished )
298
310
));
299
311
}
312
+
313
+ public Optional <Duration > findTestCaseDurationBy (TestCaseFinished testCaseFinished ) {
314
+ requireNonNull (testCaseFinished );
315
+ Timestamp finished = testCaseFinished .getTimestamp ();
316
+ return findTestCaseStartedBy (testCaseFinished )
317
+ .map (TestCaseStarted ::getTimestamp )
318
+ .map (started -> Duration .between (
319
+ Convertor .toInstant (started ),
320
+ Convertor .toInstant (finished )
321
+ ));
322
+ }
300
323
301
324
public Optional <TestCaseStarted > findTestCaseStartedBy (TestStepStarted testStepStarted ) {
302
325
requireNonNull (testStepStarted );
303
326
String testCaseStartedId = testStepStarted .getTestCaseStartedId ();
304
327
return ofNullable (testCaseStartedById .get (testCaseStartedId ));
305
328
}
306
329
330
+ private Optional <TestCaseStarted > findTestCaseStartedBy (TestCaseFinished testCaseFinished ) {
331
+ requireNonNull (testCaseFinished );
332
+ String testCaseStartedId = testCaseFinished .getTestCaseStartedId ();
333
+ return ofNullable (testCaseStartedById .get (testCaseStartedId ));
334
+ }
335
+
336
+ public Optional <TestCaseStarted > findTestCaseStartedBy (TestStepFinished testStepFinished ) {
337
+ requireNonNull (testStepFinished );
338
+ String testCaseStartedId = testStepFinished .getTestCaseStartedId ();
339
+ return ofNullable (testCaseStartedById .get (testCaseStartedId ));
340
+ }
341
+
307
342
public Optional <TestCaseFinished > findTestCaseFinishedBy (TestCaseStarted testCaseStarted ) {
308
343
requireNonNull (testCaseStarted );
309
344
return ofNullable (testCaseFinishedByTestCaseStartedId .get (testCaseStarted .getId ()));
0 commit comments