Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ private Timeout createTimeout(Long timeout) {
}

private static ObjectNode accountConfigFor(Account account, HookId hookId) {
final AccountHooksConfiguration accountHooksConfiguration = account.getHooks();
final AccountHooksConfiguration accountHooksConfiguration = account != null ? account.getHooks() : null;
final Map<String, ObjectNode> modulesConfiguration =
accountHooksConfiguration != null ? accountHooksConfiguration.getModules() : Collections.emptyMap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2828,6 +2828,48 @@ null, singletonMap("module-alpha", mapper.createObjectNode()), null))
}));
}

@Test
public void shouldExecuteAuctionResponseHooksAndTolerateNullAccount(VertxTestContext context) {
// given
final AuctionResponseHookImpl hookImpl = spy(
AuctionResponseHookImpl.of(immediateHook(InvocationResultUtils.succeeded(identity()))));
given(hookCatalog.hookById(eqHook("module-alpha", "hook-a"), eq(StageWithHookType.AUCTION_RESPONSE)))
.willReturn(hookImpl);

final HookStageExecutor executor = createExecutor(
executionPlan(singletonMap(
Endpoint.openrtb2_auction,
EndpointExecutionPlan.of(singletonMap(
Stage.auction_response, execPlanOneGroupOneHook("module-alpha", "hook-a"))))));

final HookExecutionContext hookExecutionContext = HookExecutionContext.of(Endpoint.openrtb2_auction);

// when
final Future<HookStageExecutionResult<AuctionResponsePayload>> future = executor.executeAuctionResponseStage(
BidResponse.builder().build(),
AuctionContext.builder()
.bidRequest(BidRequest.builder().build())
.account(null)
.hookExecutionContext(hookExecutionContext)
.debugContext(DebugContext.empty())
.build());

// then
future.onComplete(context.succeeding(result -> {
final ArgumentCaptor<AuctionInvocationContext> invocationContextCaptor =
ArgumentCaptor.forClass(AuctionInvocationContext.class);
verify(hookImpl).call(any(), invocationContextCaptor.capture());

assertThat(invocationContextCaptor.getValue()).satisfies(invocationContext -> {
assertThat(invocationContext.endpoint()).isNotNull();
assertThat(invocationContext.timeout()).isNotNull();
assertThat(invocationContext.accountConfig()).isNull();
});

context.completeNow();
}));
}

@Test
public void shouldExecuteAuctionResponseHooksAndIgnoreRejection(VertxTestContext context) {
// given
Expand Down
Loading