-
Notifications
You must be signed in to change notification settings - Fork 867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
convert redisscala tests from groovy to java #12553
Conversation
static void setUp() throws Exception { | ||
redisServer = new GenericContainer<>("redis:6.2.3-alpine").withExposedPorts(6379); | ||
redisServer.start(); | ||
// cleanup.deferCleanup(redisServer::stop); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this line
host = redisServer.getHost(); | ||
port = redisServer.getMappedPort(6379); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be local variables?
|
||
@AfterAll | ||
static void tearDown() throws Exception { | ||
if (system != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
groovy version also calls redisServer.stop()
import scala.Option; | ||
import scala.concurrent.Future; | ||
|
||
public class RediscalaClientTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usually we make test classes package private
0084ca7
to
b9c424c
Compare
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.shaded.org.apache.commons.lang3.tuple.Pair; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we avoid using classes shaded into other libraries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
.hasKind(CLIENT) | ||
.hasParent(trace.getSpan(0)) | ||
.hasAttributesSatisfyingExactly( | ||
equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add a static import for DB_SYSTEM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also could use DbIncubatingAttributes .DbIncubatingAttributes.REDIS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
return Pair.of(writeFuture, valueFuture); | ||
}); | ||
|
||
await().atMost(java.time.Duration.ofSeconds(3)).until(() -> result.getLeft().isCompleted()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could import java.time.Duration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
false, | ||
false, | ||
serializer)); | ||
await().atMost(java.time.Duration.ofSeconds(3)).until(value::isCompleted); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just wondering whether it would be better to use scala await class like the groovy test does or maybe even consider converting the whole test to scala
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think java class is enough to cover the instrument case
SettableFuture<Future<Object>> writeFutureRef = SettableFuture.create(); | ||
; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SettableFuture<Future<Object>> writeFutureRef = SettableFuture.create(); | |
; | |
SettableFuture<Future<Object>> writeFutureRef = SettableFuture.create(); |
#7195