Convert Lettuce 4.0 tests from groovy to java#9419
Conversation
Awesome! 🚀
We usually use awaitility for these kinds of things. AFAIR it should even be automatically imported in the |
|
|
||
| @Test | ||
| void testCommandChainedWithThenAccept() throws Throwable { | ||
| AsyncConditions conditions = new AsyncConditions(); |
There was a problem hiding this comment.
Instead of that you could use either an AtomicReference or a CompletableFuture that you would set from the redisFuture.thenAccept() callback; and then assert on that ref/future using Awaitility.await()
There was a problem hiding this comment.
thank you for this suggestion, I believe I have implemented the proposed change
…mentation into lettuce-4.0
…d utilize AutoCleanupExtension
mateuszrzeszutek
left a comment
There was a problem hiding this comment.
This is looking great, thanks! Left just a couple small comments
| static RedisCommands<String, String> syncCommands; | ||
|
|
||
| @BeforeAll | ||
| public static void setUp() { |
There was a problem hiding this comment.
Nit: JUnit 5 test lifecycle methods need not be public
| public static void setUp() { | |
| static void setUp() { |
| equalTo(SemanticAttributes.NET_PEER_NAME, host), | ||
| equalTo(SemanticAttributes.NET_PEER_PORT, port), | ||
| equalTo(SemanticAttributes.DB_SYSTEM, "redis")))); | ||
| testConnection.close(); |
There was a problem hiding this comment.
It'd be safer to use the AutoCleanupExtension; the connection would get closed even if the assertion fails.
Related to #7195
A few notes:
The groovy tests used a spock helper classUpdated to use Awaitibilityspock.util.concurrent.AsyncConditions, which I ended up re-creating, but if there's another existing class or strategy I should use in place of that, please let me know and I can make those adjustments