Skip to content
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

Respond from NotificationEventHandler when analytics disabled #1014

Merged
merged 1 commit into from
Nov 17, 2020
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 @@ -90,6 +90,8 @@ public void handle(RoutingContext context) {
if (eventRequest.getAnalytics() == EventRequest.Analytics.enabled) {
getAccountById(eventRequest.getAccountId())
.setHandler(async -> handleEvent(async, eventRequest, context));
} else {
respondWithOkStatus(context, eventRequest.getFormat() == EventRequest.Format.image);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
Expand Down Expand Up @@ -302,6 +303,23 @@ public void shouldNotPassEventToAnalyticsReporterWhenAnalyticsValueIsZero() {
verifyZeroInteractions(analyticsReporter);
}

@Test
public void shouldRespondWhenAnalyticsValueIsZeroAndDoNotSetStatusManually() {
// given
given(httpRequest.params()).willReturn(MultiMap.caseInsensitiveMultiMap()
.add("t", "win")
.add("b", "bidId")
.add("a", "accountId")
.add("x", "0"));

// when
notificationHandler.handle(routingContext);

// then
verify(httpResponse, never()).setStatusCode(anyInt());
verify(httpResponse).end();
}

@Test
public void shouldRespondWithPixelAndContentTypeWhenRequestFormatIsImp() throws IOException {
// given
Expand Down