-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from komamitsu/add-ci
Add CI
- Loading branch information
Showing
5 changed files
with
180 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
java_version: [11, 17] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK ${{ matrix.java_version }} | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: temurin | ||
java-version: ${{ matrix.java_version }} | ||
- name: Setup and execute Gradle 'check' task | ||
uses: gradle/gradle-build-action@v2 | ||
with: | ||
arguments: check | ||
- name: Upload Gradle test reports | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: gradle_test_reports | ||
path: build/reports/tests/test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 13 additions & 18 deletions
31
src/main/java/org/komamitsu/retrofit/converter/msgpack/MessagePackRequestBodyConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,24 @@ | ||
package org.komamitsu.retrofit.converter.msgpack; | ||
|
||
import com.fasterxml.jackson.databind.ObjectWriter; | ||
import java.io.IOException; | ||
import okhttp3.MediaType; | ||
import okhttp3.RequestBody; | ||
import retrofit2.Converter; | ||
|
||
import java.io.IOException; | ||
|
||
class MessagePackRequestBodyConverter<T> | ||
implements Converter<T, RequestBody> | ||
{ | ||
private static final MediaType MEDIA_TYPE = MediaType.parse("application/x-msgpack; charset=UTF-8"); | ||
class MessagePackRequestBodyConverter<T> implements Converter<T, RequestBody> { | ||
private static final MediaType MEDIA_TYPE = | ||
MediaType.parse("application/x-msgpack; charset=UTF-8"); | ||
|
||
private final ObjectWriter adapter; | ||
private final ObjectWriter adapter; | ||
|
||
MessagePackRequestBodyConverter(ObjectWriter adapter) | ||
{ | ||
this.adapter = adapter; | ||
} | ||
MessagePackRequestBodyConverter(ObjectWriter adapter) { | ||
this.adapter = adapter; | ||
} | ||
|
||
@Override | ||
public RequestBody convert(T value) | ||
throws IOException | ||
{ | ||
byte[] bytes = adapter.writeValueAsBytes(value); | ||
return RequestBody.create(MEDIA_TYPE, bytes); | ||
} | ||
@Override | ||
public RequestBody convert(T value) throws IOException { | ||
byte[] bytes = adapter.writeValueAsBytes(value); | ||
return RequestBody.create(MEDIA_TYPE, bytes); | ||
} | ||
} |
29 changes: 12 additions & 17 deletions
29
src/main/java/org/komamitsu/retrofit/converter/msgpack/MessagePackResponseBodyConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,22 @@ | ||
package org.komamitsu.retrofit.converter.msgpack; | ||
|
||
import com.fasterxml.jackson.databind.ObjectReader; | ||
import okhttp3.ResponseBody; | ||
import retrofit2.Converter; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import okhttp3.ResponseBody; | ||
import retrofit2.Converter; | ||
|
||
class MessagePackResponseBodyConverter<T> | ||
implements Converter<ResponseBody, T> | ||
{ | ||
private final ObjectReader adapter; | ||
class MessagePackResponseBodyConverter<T> implements Converter<ResponseBody, T> { | ||
private final ObjectReader adapter; | ||
|
||
MessagePackResponseBodyConverter(ObjectReader adapter) | ||
{ | ||
this.adapter = adapter; | ||
} | ||
MessagePackResponseBodyConverter(ObjectReader adapter) { | ||
this.adapter = adapter; | ||
} | ||
|
||
@Override | ||
public T convert(ResponseBody value) throws IOException | ||
{ | ||
try (InputStream in = value.byteStream()) { | ||
return adapter.readValue(in); | ||
} | ||
@Override | ||
public T convert(ResponseBody value) throws IOException { | ||
try (InputStream in = value.byteStream()) { | ||
return adapter.readValue(in); | ||
} | ||
} | ||
} |
Oops, something went wrong.