You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "kfaraz (via GitHub)" <gi...@apache.org> on 2024/12/17 08:50:29 UTC
Re: [PR] Upgrade Guice to 5.1.0 (druid)
kfaraz commented on code in PR #17578:
URL: https://github.com/apache/druid/pull/17578#discussion_r1888109376
##########
processing/src/test/java/org/apache/druid/guice/PolyBindTest.java:
##########
@@ -106,22 +107,16 @@ public void configure(Binder binder)
Assert.assertEquals("B", injector.getInstance(Gogo.class).go());
Assert.assertEquals("A", injector.getInstance(Key.get(Gogo.class, Names.named("reverse"))).go());
props.setProperty("billy", "c");
- try {
- Assert.assertEquals("A", injector.getInstance(Gogo.class).go());
- Assert.fail(); // should never be reached
- }
- catch (Exception e) {
- Assert.assertTrue(e instanceof ProvisionException);
- Assert.assertTrue(e.getMessage().contains("Unknown provider [c] of Key[type=org.apache.druid.guice.PolyBindTest$Gogo"));
- }
- try {
- Assert.assertEquals("B", injector.getInstance(Key.get(Gogo.class, Names.named("reverse"))).go());
- Assert.fail(); // should never be reached
- }
- catch (Exception e) {
- Assert.assertTrue(e instanceof ProvisionException);
- Assert.assertTrue(e.getMessage().contains("Unknown provider [c] of Key[type=org.apache.druid.guice.PolyBindTest$Gogo"));
- }
+
+ ExceptionMatcher
Review Comment:
Much cleaner now!
##########
processing/src/test/java/org/apache/druid/query/DruidProcessingConfigTest.java:
##########
@@ -133,14 +134,11 @@ public void testInvalidSizeBytes()
HEAP_SIZE,
props
);
- Throwable t = Assert.assertThrows(
- ProvisionException.class,
- () -> injector.getInstance(DruidProcessingConfig.class)
- );
- Assert.assertTrue(
- t.getMessage()
- .contains("Cannot construct instance of `org.apache.druid.java.util.common.HumanReadableBytes`, problem: Invalid format of number: -1. Negative value is not allowed.")
- );
+
+ ExceptionMatcher.of(ProvisionException.class)
+ .expectMessageContains(
+ "Cannot construct instance of `HumanReadableBytes`, problem: Invalid format of number: -1. Negative value is not allowed."
+ ).assertThrowsAndMatches(() -> injector.getInstance(DruidProcessingConfig.class));
Review Comment:
For a consistent formatting style:
```suggestion
ExceptionMatcher
.of(ProvisionException.class)
.expectMessageContains(
"Cannot construct instance of `HumanReadableBytes`, problem: Invalid format of number: -1. Negative value is not allowed."
)
.assertThrowsAndMatches(() -> injector.getInstance(DruidProcessingConfig.class));
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org