Skip to content

Commit

Permalink
Merge branch 'release/1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
matus-tomlein committed Nov 6, 2023
2 parents b2c85c2 + f0708e6 commit 285339e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Java 1.0.1 (2023-11-06)
-----------------------
Fix Issue with OkHttpClientAdapter (#366) (thanks to @eusorov for the contribution!)

Java 1.0.0 (2022-09-06)
-----------------------
Add close() to Emitter interface and Tracker (#357)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ wrapper.gradleVersion = '6.5.0'

group = 'com.snowplowanalytics'
archivesBaseName = 'snowplow-java-tracker'
version = '1.0.0'
version = '1.0.1'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ public int doGet(String url) {
try (Response response = httpClient.newCall(request).execute()) {
if (!response.isSuccessful()) {
LOGGER.error("OkHttpClient GET Request failed: {}", response);
} else {
returnValue = response.code();
}
returnValue = response.code();
} catch (IOException e) {
LOGGER.error("OkHttpClient GET Request failed: {}", e.getMessage());
}
Expand Down Expand Up @@ -154,9 +153,8 @@ public int doPost(String url, String payload) {
try (Response response = httpClient.newCall(request).execute()) {
if (!response.isSuccessful()) {
LOGGER.error("OkHttpClient POST Request failed: {}", response);
} else {
returnValue = response.code();
}
returnValue = response.code();
} catch (IOException e) {
LOGGER.error("OkHttpClient POST Request failed: {}", e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ public void testCreateWithConfiguration() {
@Test
public void testGetTrackerVersion() {
Tracker tracker = new Tracker(new TrackerConfiguration("namespace", "an-app-id"), mockEmitter);
assertEquals("java-1.0.0", tracker.getTrackerVersion());
assertEquals("java-1.0.1", tracker.getTrackerVersion());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,28 @@ public void post_withSuccessfulStatusCode_isOk() throws InterruptedException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200));

// When
adapter.post(new SelfDescribingJson("schema", Collections.singletonMap("foo", "bar")));
int responseCode = adapter.post(new SelfDescribingJson("schema", Collections.singletonMap("foo", "bar")));

// Then
assertEquals(200, responseCode);
assertEquals(1, mockWebServer.getRequestCount());
RecordedRequest recordedRequest = mockWebServer.takeRequest();
assertEquals("/com.snowplowanalytics.snowplow/tp2", recordedRequest.getPath());
assertEquals("{\"schema\":\"schema\",\"data\":{\"foo\":\"bar\"}}", recordedRequest.getBody().readUtf8());
assertEquals("POST", recordedRequest.getMethod());
assertEquals("application/json; charset=utf-8", recordedRequest.getHeader("Content-Type"));
}

@Test
public void post_withUnsuccessfulStatusCode_isOk() throws InterruptedException {
// Given
mockWebServer.enqueue(new MockResponse().setResponseCode(404));

// When
int responseCode = adapter.post(new SelfDescribingJson("schema", Collections.singletonMap("foo", "bar")));

// Then
assertEquals(404, responseCode);
assertEquals(1, mockWebServer.getRequestCount());
RecordedRequest recordedRequest = mockWebServer.takeRequest();
assertEquals("/com.snowplowanalytics.snowplow/tp2", recordedRequest.getPath());
Expand Down

0 comments on commit 285339e

Please sign in to comment.