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

chore(java-sdk): update for interfaces and dependency bumps #251

Merged
merged 3 commits into from
Dec 11, 2023
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
20 changes: 10 additions & 10 deletions config/clients/java/template/.github/workflows/main.yml.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
matrix:
java: [ '11', '17', '20' ]
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.2
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v3.5.2
- name: Set up JDK
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # v3.12.0
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
{{=< >=}}
java-version: ${{ matrix.java }}
Expand All @@ -37,10 +37,10 @@ jobs:
needs: [test]

steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.2
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v3.5.2

- name: Set up JDK
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # v3.12.0
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
java-version: 11
distribution: 'temurin'
Expand All @@ -49,7 +49,7 @@ jobs:
uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # v1.1.0

- name: Publish package
uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # v2.8.0
uses: gradle/gradle-build-action@87a9a15658c426a54dd469d4fc7dc1a73ca9d4a6 # v2.10.0
with:
# Tasks created by https://github.com/gradle-nexus/publish-plugin
arguments: publishToSonatype closeAndReleaseSonatypeStagingRepository
Expand All @@ -68,10 +68,10 @@ jobs:
needs: [test]

steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.2
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v3.5.2

- name: Set up JDK
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # v3.12.0
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
java-version: 11
distribution: 'temurin'
Expand All @@ -80,7 +80,7 @@ jobs:
uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # v1.1.0

- name: Publish package
uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # v2.8.0
uses: gradle/gradle-build-action@87a9a15658c426a54dd469d4fc7dc1a73ca9d4a6 # v2.10.0
with:
# Tasks created by https://docs.gradle.org/current/userguide/publishing_maven.html
arguments: publishAllPublicationsToGitHubPackagesRepository
Expand All @@ -95,9 +95,9 @@ jobs:
needs: [publish-maven-central, publish-github-packages]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: Roang-zero1/github-create-release-action@5cf058ddffa6fa04e5cda07c98570c757dc4a0e1
- uses: Roang-zero1/github-create-release-action@57eb9bdce7a964e48788b9e78b5ac766cb684803
with:
version_regex: ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public class OpenFgaApiIntegrationTest {
String authModelId = writeAuthModel(storeId);
WriteAssertionsRequest writeRequest = new WriteAssertionsRequest()
.assertions(List.of(new Assertion()
.tupleKey(new CheckRequestTupleKey()
.tupleKey(new AssertionTupleKey()
.user(DEFAULT_USER)
.relation("reader")
._object(DEFAULT_DOC))
Expand All @@ -297,7 +297,7 @@ public class OpenFgaApiIntegrationTest {
// Then
String responseJson = mapper.writeValueAsString(response.getAssertions());
assertEquals(
"[{\"tuple_key\":{\"user\":\"user:81684243-9356-4421-8fbf-a4f8d36aa31b\",\"relation\":\"reader\",\"object\":\"document:2021-budget\"},\"expectation\":true}]",
"[{\"tuple_key\":{\"object\":\"document:2021-budget\",\"relation\":\"reader\",\"user\":\"user:81684243-9356-4421-8fbf-a4f8d36aa31b\"},\"expectation\":true}]",
responseJson);
}

Expand Down
6 changes: 3 additions & 3 deletions config/clients/java/template/OpenFgaApiTest.java.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -1808,12 +1808,12 @@ public class OpenFgaApiTest {
// Given
String putUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J";
String expectedBody = String.format(
"{\"assertions\":[{\"tuple_key\":{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"},\"expectation\":true}]}",
DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT);
"{\"assertions\":[{\"tuple_key\":{\"object\":\"%s\",\"relation\":\"%s\",\"user\":\"%s\"},\"expectation\":true}]}",
DEFAULT_OBJECT, DEFAULT_RELATION, DEFAULT_USER);
mockHttpClient.onPut(putUrl).withBody(is(expectedBody)).doReturn(200, EMPTY_RESPONSE_BODY);
WriteAssertionsRequest request = new WriteAssertionsRequest()
.assertions(List.of(new Assertion()
.tupleKey(new CheckRequestTupleKey()
.tupleKey(new AssertionTupleKey()
._object(DEFAULT_OBJECT)
.relation(DEFAULT_RELATION)
.user(DEFAULT_USER))
Expand Down
10 changes: 5 additions & 5 deletions config/clients/java/template/build.gradle.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
// Quality
id 'jacoco'
id 'jvm-test-suite'
id 'com.diffplug.spotless' version '6.20.0'
id 'com.diffplug.spotless' version '6.23.3'

// IDE
id 'idea'
Expand Down Expand Up @@ -55,8 +55,8 @@ ext {
{{#swagger2AnnotationLibrary}}
swagger_annotations_version = "2.2.9"
{{/swagger2AnnotationLibrary}}
jackson_version = "2.14.1"
junit_version = "5.7.1"
jackson_version = "2.16.0"
junit_version = "5.10.1"
{{#hasFormParamsInSpec}}
httpmime_version = "4.5.13"
{{/hasFormParamsInSpec}}
Expand All @@ -74,7 +74,7 @@ dependencies {
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
implementation "org.openapitools:jackson-databind-nullable:0.2.1"
implementation "org.openapitools:jackson-databind-nullable:0.2.6"
{{#hasFormParamsInSpec}}
implementation "org.apache.httpcomponents:httpmime:$httpmime_version"
{{/hasFormParamsInSpec}}
Expand All @@ -88,7 +88,7 @@ testing {
dependencies {
implementation project()
implementation "org.junit.jupiter:junit-jupiter:$junit_version"
implementation "org.mockito:mockito-core:3.+"
implementation "org.mockito:mockito-core:5.+"
runtimeOnly "org.junit.platform:junit-platform-launcher"

// This test-only dependency is convenient but not widely used.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package {{invokerPackage}};

import {{modelPackage}}.Assertion;
import {{modelPackage}}.CheckRequestTupleKey;
import {{modelPackage}}.AssertionTupleKey;
import java.util.List;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -61,7 +61,7 @@ public class ClientAssertion {
}

public Assertion asAssertion() {
var tupleKey = new CheckRequestTupleKey().user(user).relation(relation)._object(_object);
var tupleKey = new AssertionTupleKey().user(user).relation(relation)._object(_object);
return new Assertion().tupleKey(tupleKey).expectation(expectation);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public class OpenFgaClientIntegrationTest {
// Then
String responseJson = mapper.writeValueAsString(response.getAssertions());
assertEquals(
"[{\"tuple_key\":{\"user\":\"user:81684243-9356-4421-8fbf-a4f8d36aa31b\",\"relation\":\"reader\",\"object\":\"document:2021-budget\"},\"expectation\":true}]",
"[{\"tuple_key\":{\"object\":\"document:2021-budget\",\"relation\":\"reader\",\"user\":\"user:81684243-9356-4421-8fbf-a4f8d36aa31b\"},\"expectation\":true}]",
responseJson);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2211,8 +2211,8 @@ public class OpenFgaClientTest {
String putUrl =
String.format("https://localhost/stores/%s/assertions/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID);
String expectedBody = String.format(
"{\"assertions\":[{\"tuple_key\":{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"},\"expectation\":true}]}",
DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT);
"{\"assertions\":[{\"tuple_key\":{\"object\":\"%s\",\"relation\":\"%s\",\"user\":\"%s\"},\"expectation\":true}]}",
DEFAULT_OBJECT, DEFAULT_RELATION, DEFAULT_USER);
mockHttpClient.onPut(putUrl).withBody(is(expectedBody)).doReturn(200, EMPTY_RESPONSE_BODY);
List<ClientAssertion> assertions = List.of(new ClientAssertion()
.user(DEFAULT_USER)
Expand Down
Loading