From 6b5c8f028fba92cdb0d202db09f73d39d10c6007 Mon Sep 17 00:00:00 2001 From: "Hochrieser, Matthias" Date: Wed, 17 Jul 2024 10:49:32 +0200 Subject: [PATCH] Pull request #263: Feature/RUM-20521 openkit java .net native should use long instead of int for bytessent and Merge in OP/openkit-java from feature/RUM-20521-openkit-java-.net-native-should-use-long-instead-of-int-for-bytessent-and to main * commit 'a4e498097bf5c8e628a498c4aa8a86ee3a882821': RUM-20521 PR Fixes RUM-20521 Updating Tests and Changelog RUM-20521 Adding API and changing tests GitOrigin-RevId: a03e010c1f0e915fb7026a951a5b4643f339ab02 --- CHANGELOG.md | 8 +++ .../openkit/api/WebRequestTracer.java | 22 ++++++ .../core/objects/NullWebRequestTracer.java | 10 +++ .../objects/WebRequestTracerBaseImpl.java | 18 +++-- .../dynatrace/openkit/protocol/Beacon.java | 14 ++++ .../objects/NullWebRequestTracerTest.java | 26 +++++++ .../objects/WebRequestTracerBaseImplTest.java | 69 +++++++++++++++++-- .../openkit/protocol/BeaconTest.java | 40 +++++------ .../objects/WebRequestTracerBaseImplTest.java | 12 ++-- .../openkit/protocol/BeaconTest.java | 40 +++++------ 10 files changed, 203 insertions(+), 56 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6e2040c..e2d1ed56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ ## [Unreleased](https://github.com/Dynatrace/openkit-java/compare/v3.2.0...HEAD) +### Added +- `WebRequestTracer.setBytesSent(long bytes)` to increase the size range +- `WebRequestTracer.setBytesReceived(long bytes)` to increase the size range + +### Changed +- Deprecated `WebRequestTracer.setBytesSent(int bytes)` due to datatype limitations +- Deprecated `WebRequestTracer.setBytesReceived(int bytes)` due to datatype limitations + ## 3.2.0 [Release date: 2023-12-06] [GitHub Releases](https://github.com/Dynatrace/openkit-java/releases/tag/v3.2.0) diff --git a/src/main/java/com/dynatrace/openkit/api/WebRequestTracer.java b/src/main/java/com/dynatrace/openkit/api/WebRequestTracer.java index c00af8e3..b1be6201 100644 --- a/src/main/java/com/dynatrace/openkit/api/WebRequestTracer.java +++ b/src/main/java/com/dynatrace/openkit/api/WebRequestTracer.java @@ -35,17 +35,39 @@ public interface WebRequestTracer extends Closeable { /** * Sets the amount of sent data of this web request. Has to be called before {@link WebRequestTracer#stop(int)}. * + * @deprecated + * This method should no longer be used due its datatype limitation. Use {@link WebRequestTracer#setBytesSent(long)} instead. + * * @param bytesSent number of bytes */ + @Deprecated WebRequestTracer setBytesSent(int bytesSent); + /** + * Sets the amount of sent data of this web request. Has to be called before {@link WebRequestTracer#stop(int)}. + * + * @param bytesSent number of bytes + */ + WebRequestTracer setBytesSent(long bytesSent); + /** * Sets the amount of received data of this web request. Has to be called before {@link WebRequestTracer#stop(int)}. * + * @deprecated + * This method should no longer be used due its datatype limitation. Use {@link WebRequestTracer#setBytesReceived(long)} instead. + * * @param bytesReceived number of bytes */ + @Deprecated WebRequestTracer setBytesReceived(int bytesReceived); + /** + * Sets the amount of received data of this web request. Has to be called before {@link WebRequestTracer#stop(int)}. + * + * @param bytesReceived number of bytes + */ + WebRequestTracer setBytesReceived(long bytesReceived); + /** * Starts the web request timing. Should be called when the web request is initiated. */ diff --git a/src/main/java/com/dynatrace/openkit/core/objects/NullWebRequestTracer.java b/src/main/java/com/dynatrace/openkit/core/objects/NullWebRequestTracer.java index 622f6176..bc638341 100644 --- a/src/main/java/com/dynatrace/openkit/core/objects/NullWebRequestTracer.java +++ b/src/main/java/com/dynatrace/openkit/core/objects/NullWebRequestTracer.java @@ -41,11 +41,21 @@ public WebRequestTracer setBytesSent(int bytesSent) { return this; } + @Override + public WebRequestTracer setBytesSent(long bytesSent) { + return this; + } + @Override public WebRequestTracer setBytesReceived(int bytesReceived) { return this; } + @Override + public WebRequestTracer setBytesReceived(long bytesReceived) { + return this; + } + @Override public WebRequestTracer start() { return this; diff --git a/src/main/java/com/dynatrace/openkit/core/objects/WebRequestTracerBaseImpl.java b/src/main/java/com/dynatrace/openkit/core/objects/WebRequestTracerBaseImpl.java index 58aa84ac..ce3a0bc5 100644 --- a/src/main/java/com/dynatrace/openkit/core/objects/WebRequestTracerBaseImpl.java +++ b/src/main/java/com/dynatrace/openkit/core/objects/WebRequestTracerBaseImpl.java @@ -53,9 +53,9 @@ public abstract class WebRequestTracerBaseImpl implements WebRequestTracer, Canc /** The response code received from the request */ private int responseCode = -1; /** The number of bytes sent */ - private int bytesSent = -1; + private long bytesSent = -1; /** The number of bytes received */ - private int bytesReceived = -1; + private long bytesReceived = -1; /** Start time of the web request, set in {@link #start()} */ private long startTime; @@ -103,6 +103,11 @@ public String getTag() { @Override public WebRequestTracer setBytesSent(int bytesSent) { + return setBytesSent((long) bytesSent); + } + + @Override + public WebRequestTracer setBytesSent(long bytesSent) { synchronized (lockObject) { if (!isStopped()) { this.bytesSent = bytesSent; @@ -113,6 +118,11 @@ public WebRequestTracer setBytesSent(int bytesSent) { @Override public WebRequestTracer setBytesReceived(int bytesReceived) { + return setBytesReceived((long) bytesReceived); + } + + @Override + public WebRequestTracer setBytesReceived(long bytesReceived) { synchronized (lockObject) { if (!isStopped()) { this.bytesReceived = bytesReceived; @@ -201,11 +211,11 @@ public int getEndSequenceNo() { return endSequenceNo; } - public int getBytesSent() { + public long getBytesSent() { return bytesSent; } - public int getBytesReceived() { + public long getBytesReceived() { return bytesReceived; } diff --git a/src/main/java/com/dynatrace/openkit/protocol/Beacon.java b/src/main/java/com/dynatrace/openkit/protocol/Beacon.java index 1f6ad90f..25985db1 100644 --- a/src/main/java/com/dynatrace/openkit/protocol/Beacon.java +++ b/src/main/java/com/dynatrace/openkit/protocol/Beacon.java @@ -1267,6 +1267,20 @@ private void addKeyValuePairIfNotNegative(StringBuilder builder, String key, int } } + /** + * Serialization helper method for adding key/value pairs with int values + * + * the key value pair is only added to the string builder when the int is not negative + * + * @param builder The string builder storing serialized data. + * @param key The key to add. + * @param longValue The value to add. + */ + private void addKeyValuePairIfNotNegative(StringBuilder builder, String key, long longValue) { + if (longValue >= 0) { + addKeyValuePair(builder, key, longValue); + } + } /** * Serialization helper method for adding key/value pairs with double values diff --git a/src/test/java/com/dynatrace/openkit/core/objects/NullWebRequestTracerTest.java b/src/test/java/com/dynatrace/openkit/core/objects/NullWebRequestTracerTest.java index 1abee68a..4a210c05 100644 --- a/src/test/java/com/dynatrace/openkit/core/objects/NullWebRequestTracerTest.java +++ b/src/test/java/com/dynatrace/openkit/core/objects/NullWebRequestTracerTest.java @@ -51,6 +51,19 @@ public void setBytesSentReturnsSelf() { assertThat((NullWebRequestTracer)obtained, is(sameInstance(target))); } + @Test + public void setBytesSentLongReturnsSelf() { + // given + NullWebRequestTracer target = NullWebRequestTracer.INSTANCE; + + // when + WebRequestTracer obtained = target.setBytesSent(37L); + + // then + assertThat(obtained, instanceOf(NullWebRequestTracer.class)); + assertThat((NullWebRequestTracer)obtained, is(sameInstance(target))); + } + @Test public void setBytesReceivedReturnsSelf() { // given @@ -64,6 +77,19 @@ public void setBytesReceivedReturnsSelf() { assertThat((NullWebRequestTracer)obtained, is(sameInstance(target))); } + @Test + public void setBytesReceivedLongReturnsSelf() { + // given + NullWebRequestTracer target = NullWebRequestTracer.INSTANCE; + + // when + WebRequestTracer obtained = target.setBytesReceived(73L); + + // then + assertThat(obtained, instanceOf(NullWebRequestTracer.class)); + assertThat((NullWebRequestTracer)obtained, is(sameInstance(target))); + } + @Test public void startReturnsSelf() { // given diff --git a/src/test/java/com/dynatrace/openkit/core/objects/WebRequestTracerBaseImplTest.java b/src/test/java/com/dynatrace/openkit/core/objects/WebRequestTracerBaseImplTest.java index 8e00c0fb..c6ada15c 100644 --- a/src/test/java/com/dynatrace/openkit/core/objects/WebRequestTracerBaseImplTest.java +++ b/src/test/java/com/dynatrace/openkit/core/objects/WebRequestTracerBaseImplTest.java @@ -71,8 +71,8 @@ public void defaultValues() { assertThat(target.getEndTime(), is(-1L)); assertThat(target.getStartSequenceNo(), is(SEQUENCE_NUMBER)); assertThat(target.getEndSequenceNo(), is(-1)); - assertThat(target.getBytesSent(), is(-1)); - assertThat(target.getBytesReceived(), is(-1)); + assertThat(target.getBytesSent(), is(-1L)); + assertThat(target.getBytesReceived(), is(-1L)); assertThat(target.getParent(), is(sameInstance(parentOpenKitObject))); // and verify that the sequence number was retrieved from beacon, as well as the tag @@ -158,7 +158,21 @@ public void setBytesSentSetsTheNumberOfSentBytes() { WebRequestTracer obtained = target.setBytesSent(1234); // then - assertThat(target.getBytesSent(), is(1234)); + assertThat(target.getBytesSent(), is(1234L)); + assertThat(obtained, is(sameInstance((WebRequestTracer)target))); + } + + @Test + public void setBytesSentLongSetsTheNumberOfSentBytes() { + + // given + WebRequestTracerBaseImpl target = new TestWebRequestTracerBaseImpl(logger, parentOpenKitObject, mockBeacon); + + // when setting the sent bytes + WebRequestTracer obtained = target.setBytesSent(1234L); + + // then + assertThat(target.getBytesSent(), is(1234L)); assertThat(obtained, is(sameInstance((WebRequestTracer)target))); } @@ -173,7 +187,22 @@ public void setBytesSentDoesNotSetAnythingIfStoppedWithResponseCode() { WebRequestTracer obtained = target.setBytesSent(1234); // then - assertThat(target.getBytesSent(), is(-1)); + assertThat(target.getBytesSent(), is(-1L)); + assertThat(obtained, is(sameInstance((WebRequestTracer)target))); + } + + @Test + public void setBytesSentLongDoesNotSetAnythingIfStoppedWithResponseCode() { + + // given + WebRequestTracerBaseImpl target = new TestWebRequestTracerBaseImpl(logger, parentOpenKitObject, mockBeacon); + target.stop(200); + + // when setting the sent bytes + WebRequestTracer obtained = target.setBytesSent(1234L); + + // then + assertThat(target.getBytesSent(), is(-1L)); assertThat(obtained, is(sameInstance((WebRequestTracer)target))); } @@ -187,7 +216,21 @@ public void setBytesReceivedSetsTheNumberOfReceivedBytes() { WebRequestTracer obtained = target.setBytesReceived(4321); // then - assertThat(target.getBytesReceived(), is(4321)); + assertThat(target.getBytesReceived(), is(4321L)); + assertThat(obtained, is(sameInstance((WebRequestTracer)target))); + } + + @Test + public void setBytesReceivedLongSetsTheNumberOfReceivedBytes() { + + // given + WebRequestTracerBaseImpl target = new TestWebRequestTracerBaseImpl(logger, parentOpenKitObject, mockBeacon); + + // when setting the received bytes + WebRequestTracer obtained = target.setBytesReceived(4321L); + + // then + assertThat(target.getBytesReceived(), is(4321L)); assertThat(obtained, is(sameInstance((WebRequestTracer)target))); } @@ -201,7 +244,21 @@ public void setBytesReceivedDoesNotSetAnythingIfStoppedWithResponseCode() { WebRequestTracer obtained = target.setBytesReceived(4321); // then - assertThat(target.getBytesReceived(), is(-1)); + assertThat(target.getBytesReceived(), is(-1L)); + assertThat(obtained, is(sameInstance((WebRequestTracer)target))); + } + + @Test + public void setBytesReceivedLongDoesNotSetAnythingIfStoppedWithResponseCode() { + // given + WebRequestTracerBaseImpl target = new TestWebRequestTracerBaseImpl(logger, parentOpenKitObject, mockBeacon); + target.stop(200); + + // when setting the received bytes + WebRequestTracer obtained = target.setBytesReceived(4321L); + + // then + assertThat(target.getBytesReceived(), is(-1L)); assertThat(obtained, is(sameInstance((WebRequestTracer)target))); } diff --git a/src/test/java/com/dynatrace/openkit/protocol/BeaconTest.java b/src/test/java/com/dynatrace/openkit/protocol/BeaconTest.java index f3de7056..0f405e6d 100644 --- a/src/test/java/com/dynatrace/openkit/protocol/BeaconTest.java +++ b/src/test/java/com/dynatrace/openkit/protocol/BeaconTest.java @@ -3234,8 +3234,8 @@ public void addWebRequest() throws UnsupportedEncodingException { String encodedUrl = URLEncoder.encode(rawUrl, "UTF-8"); WebRequestTracerBaseImpl webRequestTracer = mock(WebRequestTracerBaseImpl.class); when(webRequestTracer.getURL()).thenReturn(rawUrl); - when(webRequestTracer.getBytesSent()).thenReturn(13); - when(webRequestTracer.getBytesReceived()).thenReturn(14); + when(webRequestTracer.getBytesSent()).thenReturn(13L); + when(webRequestTracer.getBytesReceived()).thenReturn(14L); when(webRequestTracer.getResponseCode()).thenReturn(15); final Beacon target = createBeacon().build(); @@ -3316,8 +3316,8 @@ public void canAddSentBytesEqualToZeroToWebRequestTracer() throws UnsupportedEnc String encodedUrl = URLEncoder.encode(rawUrl, "UTF-8"); WebRequestTracerBaseImpl webRequestTracer = mock(WebRequestTracerBaseImpl.class); when(webRequestTracer.getURL()).thenReturn(rawUrl); - when(webRequestTracer.getBytesSent()).thenReturn(0); - when(webRequestTracer.getBytesReceived()).thenReturn(14); + when(webRequestTracer.getBytesSent()).thenReturn(0L); + when(webRequestTracer.getBytesReceived()).thenReturn(14L); when(webRequestTracer.getResponseCode()).thenReturn(15); final Beacon target = createBeacon().build(); @@ -3353,8 +3353,8 @@ public void cannotAddSentBytesLessThanZeroToWebRequestTracer() throws Unsupporte String encodedUrl = URLEncoder.encode(rawUrl, "UTF-8"); WebRequestTracerBaseImpl webRequestTracer = mock(WebRequestTracerBaseImpl.class); when(webRequestTracer.getURL()).thenReturn(rawUrl); - when(webRequestTracer.getBytesSent()).thenReturn(-1); - when(webRequestTracer.getBytesReceived()).thenReturn(14); + when(webRequestTracer.getBytesSent()).thenReturn(-1L); + when(webRequestTracer.getBytesReceived()).thenReturn(14L); when(webRequestTracer.getResponseCode()).thenReturn(15); final Beacon target = createBeacon().build(); @@ -3389,8 +3389,8 @@ public void canAddReceivedBytesEqualToZeroToWebRequestTracer() throws Unsupporte String encodedUrl = URLEncoder.encode(rawUrl, "UTF-8"); WebRequestTracerBaseImpl webRequestTracer = mock(WebRequestTracerBaseImpl.class); when(webRequestTracer.getURL()).thenReturn(rawUrl); - when(webRequestTracer.getBytesSent()).thenReturn(13); - when(webRequestTracer.getBytesReceived()).thenReturn(0); + when(webRequestTracer.getBytesSent()).thenReturn(13L); + when(webRequestTracer.getBytesReceived()).thenReturn(0L); when(webRequestTracer.getResponseCode()).thenReturn(15); final Beacon target = createBeacon().build(); @@ -3426,8 +3426,8 @@ public void cannotAddReceivedBytesLessThanZeroToWebRequestTracer() throws Unsupp String encodedUrl = URLEncoder.encode(rawUrl, "UTF-8"); WebRequestTracerBaseImpl webRequestTracer = mock(WebRequestTracerBaseImpl.class); when(webRequestTracer.getURL()).thenReturn(rawUrl); - when(webRequestTracer.getBytesSent()).thenReturn(13); - when(webRequestTracer.getBytesReceived()).thenReturn(-1); + when(webRequestTracer.getBytesSent()).thenReturn(13L); + when(webRequestTracer.getBytesReceived()).thenReturn(-1L); when(webRequestTracer.getResponseCode()).thenReturn(15); final Beacon target = createBeacon().build(); @@ -3462,8 +3462,8 @@ public void canAddResponseCodeEqualToZeroToWebRequestTracer() throws Unsupported String encodedUrl = URLEncoder.encode(rawUrl, "UTF-8"); WebRequestTracerBaseImpl webRequestTracer = mock(WebRequestTracerBaseImpl.class); when(webRequestTracer.getURL()).thenReturn(rawUrl); - when(webRequestTracer.getBytesSent()).thenReturn(13); - when(webRequestTracer.getBytesReceived()).thenReturn(14); + when(webRequestTracer.getBytesSent()).thenReturn(13L); + when(webRequestTracer.getBytesReceived()).thenReturn(14L); when(webRequestTracer.getResponseCode()).thenReturn(0); final Beacon target = createBeacon().build(); @@ -3499,8 +3499,8 @@ public void cannotAddResponseCodeLessThanZeroToWebRequestTracer() throws Unsuppo String encodedUrl = URLEncoder.encode(rawUrl, "UTF-8"); WebRequestTracerBaseImpl webRequestTracer = mock(WebRequestTracerBaseImpl.class); when(webRequestTracer.getURL()).thenReturn(rawUrl); - when(webRequestTracer.getBytesSent()).thenReturn(13); - when(webRequestTracer.getBytesReceived()).thenReturn(14); + when(webRequestTracer.getBytesSent()).thenReturn(13L); + when(webRequestTracer.getBytesReceived()).thenReturn(14L); when(webRequestTracer.getResponseCode()).thenReturn(-1); final Beacon target = createBeacon().build(); @@ -3533,8 +3533,8 @@ public void noWebRequestIsReportedIfDataSendingIsDisallowed() { // given WebRequestTracerBaseImpl webRequestTracer = mock(WebRequestTracerBaseImpl.class); when(webRequestTracer.getURL()).thenReturn("https://www.google.com"); - when(webRequestTracer.getBytesSent()).thenReturn(13); - when(webRequestTracer.getBytesReceived()).thenReturn(14); + when(webRequestTracer.getBytesSent()).thenReturn(13L); + when(webRequestTracer.getBytesReceived()).thenReturn(14L); when(webRequestTracer.getResponseCode()).thenReturn(15); when(mockServerConfiguration.isSendingDataAllowed()).thenReturn(false); @@ -3553,8 +3553,8 @@ public void noWebRequestIsReportedIfWebRequestTracingDisallowed() { // given WebRequestTracerBaseImpl webRequestTracer = mock(WebRequestTracerBaseImpl.class); when(webRequestTracer.getURL()).thenReturn("https://www.google.com"); - when(webRequestTracer.getBytesSent()).thenReturn(13); - when(webRequestTracer.getBytesReceived()).thenReturn(14); + when(webRequestTracer.getBytesSent()).thenReturn(13L); + when(webRequestTracer.getBytesReceived()).thenReturn(14L); when(webRequestTracer.getResponseCode()).thenReturn(15); when(mockPrivacyConfiguration.isWebRequestTracingAllowed()).thenReturn(false); @@ -3574,8 +3574,8 @@ public void noWebRequestIsReportedIfDisallowedByTrafficControl() { // given WebRequestTracerBaseImpl webRequestTracer = mock(WebRequestTracerBaseImpl.class); when(webRequestTracer.getURL()).thenReturn("https://www.google.com"); - when(webRequestTracer.getBytesSent()).thenReturn(13); - when(webRequestTracer.getBytesReceived()).thenReturn(14); + when(webRequestTracer.getBytesSent()).thenReturn(13L); + when(webRequestTracer.getBytesReceived()).thenReturn(14L); when(webRequestTracer.getResponseCode()).thenReturn(15); int trafficControlPercentage = 50; diff --git a/src/test7/java/com/dynatrace/openkit/core/objects/WebRequestTracerBaseImplTest.java b/src/test7/java/com/dynatrace/openkit/core/objects/WebRequestTracerBaseImplTest.java index 02a8587b..7c81bcad 100644 --- a/src/test7/java/com/dynatrace/openkit/core/objects/WebRequestTracerBaseImplTest.java +++ b/src/test7/java/com/dynatrace/openkit/core/objects/WebRequestTracerBaseImplTest.java @@ -71,8 +71,8 @@ public void defaultValues() { assertThat(target.getEndTime(), is(-1L)); assertThat(target.getStartSequenceNo(), is(SEQUENCE_NUMBER)); assertThat(target.getEndSequenceNo(), is(-1)); - assertThat(target.getBytesSent(), is(-1)); - assertThat(target.getBytesReceived(), is(-1)); + assertThat(target.getBytesSent(), is(-1l)); + assertThat(target.getBytesReceived(), is(-1l)); assertThat(target.getParent(), is(sameInstance(parentOpenKitObject))); // and verify that the sequence number was retrieved from beacon, as well as the tag @@ -158,7 +158,7 @@ public void setBytesSentSetsTheNumberOfSentBytes() { WebRequestTracer obtained = target.setBytesSent(1234); // then - assertThat(target.getBytesSent(), is(1234)); + assertThat(target.getBytesSent(), is(1234l)); assertThat(obtained, is(sameInstance((WebRequestTracer)target))); } @@ -173,7 +173,7 @@ public void setBytesSentDoesNotSetAnythingIfStoppedWithResponseCode() { WebRequestTracer obtained = target.setBytesSent(1234); // then - assertThat(target.getBytesSent(), is(-1)); + assertThat(target.getBytesSent(), is(-1l)); assertThat(obtained, is(sameInstance((WebRequestTracer)target))); } @@ -187,7 +187,7 @@ public void setBytesReceivedSetsTheNumberOfReceivedBytes() { WebRequestTracer obtained = target.setBytesReceived(4321); // then - assertThat(target.getBytesReceived(), is(4321)); + assertThat(target.getBytesReceived(), is(4321l)); assertThat(obtained, is(sameInstance((WebRequestTracer)target))); } @@ -201,7 +201,7 @@ public void setBytesReceivedDoesNotSetAnythingIfStoppedWithResponseCode() { WebRequestTracer obtained = target.setBytesReceived(4321); // then - assertThat(target.getBytesReceived(), is(-1)); + assertThat(target.getBytesReceived(), is(-1l)); assertThat(obtained, is(sameInstance((WebRequestTracer)target))); } diff --git a/src/test7/java/com/dynatrace/openkit/protocol/BeaconTest.java b/src/test7/java/com/dynatrace/openkit/protocol/BeaconTest.java index 55ff083c..b4b0abd7 100644 --- a/src/test7/java/com/dynatrace/openkit/protocol/BeaconTest.java +++ b/src/test7/java/com/dynatrace/openkit/protocol/BeaconTest.java @@ -3233,8 +3233,8 @@ public void addWebRequest() throws UnsupportedEncodingException { String encodedUrl = URLEncoder.encode(rawUrl, "UTF-8"); WebRequestTracerBaseImpl webRequestTracer = mock(WebRequestTracerBaseImpl.class); when(webRequestTracer.getURL()).thenReturn(rawUrl); - when(webRequestTracer.getBytesSent()).thenReturn(13); - when(webRequestTracer.getBytesReceived()).thenReturn(14); + when(webRequestTracer.getBytesSent()).thenReturn(13L); + when(webRequestTracer.getBytesReceived()).thenReturn(14L); when(webRequestTracer.getResponseCode()).thenReturn(15); final Beacon target = createBeacon().build(); @@ -3315,8 +3315,8 @@ public void canAddSentBytesEqualToZeroToWebRequestTracer() throws UnsupportedEnc String encodedUrl = URLEncoder.encode(rawUrl, "UTF-8"); WebRequestTracerBaseImpl webRequestTracer = mock(WebRequestTracerBaseImpl.class); when(webRequestTracer.getURL()).thenReturn(rawUrl); - when(webRequestTracer.getBytesSent()).thenReturn(0); - when(webRequestTracer.getBytesReceived()).thenReturn(14); + when(webRequestTracer.getBytesSent()).thenReturn(0L); + when(webRequestTracer.getBytesReceived()).thenReturn(14L); when(webRequestTracer.getResponseCode()).thenReturn(15); final Beacon target = createBeacon().build(); @@ -3352,8 +3352,8 @@ public void cannotAddSentBytesLessThanZeroToWebRequestTracer() throws Unsupporte String encodedUrl = URLEncoder.encode(rawUrl, "UTF-8"); WebRequestTracerBaseImpl webRequestTracer = mock(WebRequestTracerBaseImpl.class); when(webRequestTracer.getURL()).thenReturn(rawUrl); - when(webRequestTracer.getBytesSent()).thenReturn(-1); - when(webRequestTracer.getBytesReceived()).thenReturn(14); + when(webRequestTracer.getBytesSent()).thenReturn(-1L); + when(webRequestTracer.getBytesReceived()).thenReturn(14L); when(webRequestTracer.getResponseCode()).thenReturn(15); final Beacon target = createBeacon().build(); @@ -3388,8 +3388,8 @@ public void canAddReceivedBytesEqualToZeroToWebRequestTracer() throws Unsupporte String encodedUrl = URLEncoder.encode(rawUrl, "UTF-8"); WebRequestTracerBaseImpl webRequestTracer = mock(WebRequestTracerBaseImpl.class); when(webRequestTracer.getURL()).thenReturn(rawUrl); - when(webRequestTracer.getBytesSent()).thenReturn(13); - when(webRequestTracer.getBytesReceived()).thenReturn(0); + when(webRequestTracer.getBytesSent()).thenReturn(13L); + when(webRequestTracer.getBytesReceived()).thenReturn(0L); when(webRequestTracer.getResponseCode()).thenReturn(15); final Beacon target = createBeacon().build(); @@ -3425,8 +3425,8 @@ public void cannotAddReceivedBytesLessThanZeroToWebRequestTracer() throws Unsupp String encodedUrl = URLEncoder.encode(rawUrl, "UTF-8"); WebRequestTracerBaseImpl webRequestTracer = mock(WebRequestTracerBaseImpl.class); when(webRequestTracer.getURL()).thenReturn(rawUrl); - when(webRequestTracer.getBytesSent()).thenReturn(13); - when(webRequestTracer.getBytesReceived()).thenReturn(-1); + when(webRequestTracer.getBytesSent()).thenReturn(13L); + when(webRequestTracer.getBytesReceived()).thenReturn(-1L); when(webRequestTracer.getResponseCode()).thenReturn(15); final Beacon target = createBeacon().build(); @@ -3461,8 +3461,8 @@ public void canAddResponseCodeEqualToZeroToWebRequestTracer() throws Unsupported String encodedUrl = URLEncoder.encode(rawUrl, "UTF-8"); WebRequestTracerBaseImpl webRequestTracer = mock(WebRequestTracerBaseImpl.class); when(webRequestTracer.getURL()).thenReturn(rawUrl); - when(webRequestTracer.getBytesSent()).thenReturn(13); - when(webRequestTracer.getBytesReceived()).thenReturn(14); + when(webRequestTracer.getBytesSent()).thenReturn(13L); + when(webRequestTracer.getBytesReceived()).thenReturn(14L); when(webRequestTracer.getResponseCode()).thenReturn(0); final Beacon target = createBeacon().build(); @@ -3498,8 +3498,8 @@ public void cannotAddResponseCodeLessThanZeroToWebRequestTracer() throws Unsuppo String encodedUrl = URLEncoder.encode(rawUrl, "UTF-8"); WebRequestTracerBaseImpl webRequestTracer = mock(WebRequestTracerBaseImpl.class); when(webRequestTracer.getURL()).thenReturn(rawUrl); - when(webRequestTracer.getBytesSent()).thenReturn(13); - when(webRequestTracer.getBytesReceived()).thenReturn(14); + when(webRequestTracer.getBytesSent()).thenReturn(13L); + when(webRequestTracer.getBytesReceived()).thenReturn(14L); when(webRequestTracer.getResponseCode()).thenReturn(-1); final Beacon target = createBeacon().build(); @@ -3532,8 +3532,8 @@ public void noWebRequestIsReportedIfDataSendingIsDisallowed() { // given WebRequestTracerBaseImpl webRequestTracer = mock(WebRequestTracerBaseImpl.class); when(webRequestTracer.getURL()).thenReturn("https://www.google.com"); - when(webRequestTracer.getBytesSent()).thenReturn(13); - when(webRequestTracer.getBytesReceived()).thenReturn(14); + when(webRequestTracer.getBytesSent()).thenReturn(13L); + when(webRequestTracer.getBytesReceived()).thenReturn(14L); when(webRequestTracer.getResponseCode()).thenReturn(15); when(mockServerConfiguration.isSendingDataAllowed()).thenReturn(false); @@ -3552,8 +3552,8 @@ public void noWebRequestIsReportedIfWebRequestTracingDisallowed() { // given WebRequestTracerBaseImpl webRequestTracer = mock(WebRequestTracerBaseImpl.class); when(webRequestTracer.getURL()).thenReturn("https://www.google.com"); - when(webRequestTracer.getBytesSent()).thenReturn(13); - when(webRequestTracer.getBytesReceived()).thenReturn(14); + when(webRequestTracer.getBytesSent()).thenReturn(13L); + when(webRequestTracer.getBytesReceived()).thenReturn(14L); when(webRequestTracer.getResponseCode()).thenReturn(15); when(mockPrivacyConfiguration.isWebRequestTracingAllowed()).thenReturn(false); @@ -3573,8 +3573,8 @@ public void noWebRequestIsReportedIfDisallowedByTrafficControl() { // given WebRequestTracerBaseImpl webRequestTracer = mock(WebRequestTracerBaseImpl.class); when(webRequestTracer.getURL()).thenReturn("https://www.google.com"); - when(webRequestTracer.getBytesSent()).thenReturn(13); - when(webRequestTracer.getBytesReceived()).thenReturn(14); + when(webRequestTracer.getBytesSent()).thenReturn(13L); + when(webRequestTracer.getBytesReceived()).thenReturn(14L); when(webRequestTracer.getResponseCode()).thenReturn(15); int trafficControlPercentage = 50;