GH-8901: Add MockIntContext.substituteTriggerFor

Fixes: #8901

Provide a convenient API `MockIntegrationContext.substituteTriggerFor(String pollingAdapterId, Trigger trigger)`
to mitigate the time span which might be provided in the original configuration

* Add `MockIntegrationContext.substituteTriggerFor(String pollingAdapterId, Trigger trigger)`
* Refactor `MockIntegrationContext` for Java 17 code style
* Change `MockIntegrationContext.beans` to `MultiValueMap` since we may replace several properties of
the same endpoint
* Modify `MockMessageSourceTests.testMockMessageSource()` to use new `substituteTriggerFor()`, too
* Add Javadoc for the `OnlyOnceTrigger`
* Document the new feature and mention it with correlation to `OnlyOnceTrigger`
This commit is contained in:
Artem Bilan
2024-02-15 14:59:52 -05:00
parent c35982e0e2
commit 1d73ab59af
5 changed files with 96 additions and 50 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,12 @@ import org.springframework.scheduling.Trigger;
import org.springframework.scheduling.TriggerContext;
/**
* The {@link Trigger} implementation which returns the current time
* to schedule the task immediately and does that only once.
* <p>
* The {@link #reset()} method can be called to reuse this trigger from scratch.
* <p>
* The {@link #await()} method can be used for synchronization barriers.
*
* @author Gunnar Hillert
* @author Gary Russell