public Optional<JobTriggerDto> cancelTriggerByQuery(Bson query) {
        final var update = set(FIELD_IS_CANCELLED, true);

        return Optional.ofNullable(collection.findOneAndUpdate(query, update));
    }
@Test
    @MongoDBFixtures("locked-job-triggers.json")
    public void cancelTriggerByQuery() {
        // Must return an empty Optional if the query didn't match any trigger
        assertThat(dbJobTriggerService.cancelTriggerByQuery(DBQuery.is("foo", "bar"))).isEmpty();

        final JobTriggerDto lockedTrigger = dbJobTriggerService.get("54e3deadbeefdeadbeef0001").orElseThrow(AssertionError::new);

        assertThat(lockedTrigger.isCancelled()).isFalse();

        assertThat(dbJobTriggerService.cancelTriggerByQuery(DBQuery.is("_id", "54e3deadbeefdeadbeef0001"))).isPresent();

        final JobTriggerDto cancelledTrigger = dbJobTriggerService.get(lockedTrigger.id()).orElseThrow(AssertionError::new);

        assertThat(cancelledTrigger.isCancelled()).isTrue();
    }