Skip to content

Commit

Permalink
Respond from NotificationEventHandler when analytics disabled (#1014)
Browse files Browse the repository at this point in the history
  • Loading branch information
BraslavskiyAndrey authored Nov 17, 2020
1 parent e087682 commit 54bb1ad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
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

0 comments on commit 54bb1ad

Please sign in to comment.