Akshat-Jain commented on code in PR #16420:
URL: https://github.com/apache/druid/pull/16420#discussion_r1595062689
##########
server/src/test/java/org/apache/druid/server/lookup/cache/LookupLoadingSpecTest.java:
##########
@@ -59,4 +66,62 @@ public void testLoadingOnlyRequiredLookupsWithNullList()
DruidException exception = Assert.assertThrows(DruidException.class, () ->
LookupLoadingSpec.loadOnly(null));
Assert.assertEquals("Expected non-null set of lookups to load.",
exception.getMessage());
}
+
+ @MethodSource("provideParamsForTestGetSpecFromContext")
+ @ParameterizedTest
+ public void testGetLookupLoadingSpecFromContext(Map<String, Object> context,
LookupLoadingSpec defaultSpec, LookupLoadingSpec expectedSpec)
+ {
+ LookupLoadingSpec specFromContext =
LookupLoadingSpec.getSpecFromContext(context, defaultSpec);
+ Assert.assertEquals(expectedSpec.getMode(), specFromContext.getMode());
+ Assert.assertEquals(expectedSpec.getLookupsToLoad(),
specFromContext.getLookupsToLoad());
+ }
+
+ public static Collection<Object[]> provideParamsForTestGetSpecFromContext()
+ {
+ ImmutableSet<String> lookupsToLoad = ImmutableSet.of("lookupName1",
"lookupName2");
+ final ImmutableMap<String, Object> contextWithModeOnlyRequired =
ImmutableMap.of(
+ LookupLoadingSpec.CTX_LOOKUPS_TO_LOAD, new ArrayList<>(lookupsToLoad),
+ LookupLoadingSpec.CTX_LOOKUP_LOADING_MODE,
LookupLoadingSpec.Mode.ONLY_REQUIRED);
+ final ImmutableMap<String, Object> contextWithModeNone = ImmutableMap.of(
+ LookupLoadingSpec.CTX_LOOKUP_LOADING_MODE,
LookupLoadingSpec.Mode.NONE);
+ final ImmutableMap<String, Object> contextWithModeAll = ImmutableMap.of(
+ LookupLoadingSpec.CTX_LOOKUP_LOADING_MODE, LookupLoadingSpec.Mode.ALL);
+ final ImmutableMap<String, Object> contextWithoutLookupKeys =
ImmutableMap.of();
+
+ // Return params: <context, default LookupLoadingSpec, expected
LookupLoadingSpec>
+ Object[][] params = new Object[][]{
+ // Default spec is returned in the case of context not having the
lookup keys.
Review Comment:
Sorry, I didn't get it. Could you please elaborate? Thanks!
Not sure if this helps, but the intention here was just to have
parameterized test as it would be cleaner than having separate test methods for
the different combinations. So `provideParamsForTestCreateFromContext` method
is just supplying params to `testGetLookupLoadingSpecFromContext` test via
`@MethodSource("provideParamsForTestCreateFromContext")`.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]