-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to Quarkus 3.8 and resteasy-reactive
- Loading branch information
Showing
23 changed files
with
170 additions
and
140 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
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
26 changes: 22 additions & 4 deletions
26
...rkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JsonConfiguration.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,18 +1,36 @@ | ||
package ch.schlau.pesche.apidocs.openapi.codefirst.rest; | ||
|
||
import jakarta.enterprise.context.Dependent; | ||
import jakarta.enterprise.inject.Instance; | ||
import jakarta.json.bind.Jsonb; | ||
import jakarta.json.bind.JsonbBuilder; | ||
import jakarta.json.bind.JsonbConfig; | ||
|
||
import ch.schlau.pesche.apidocs.openapi.codefirst.txproc.model.PanJsonAdapter; | ||
import lombok.experimental.UtilityClass; | ||
import io.quarkus.jsonb.JsonbConfigCustomizer; | ||
|
||
@UtilityClass | ||
public class JsonConfiguration { | ||
|
||
public static final JsonbConfig JSON_CONFIG = new JsonbConfig() | ||
public static JsonbConfig createJsonbConfig() { | ||
return new JsonbConfig() | ||
.withAdapters(new PanJsonAdapter()) | ||
; | ||
} | ||
|
||
public static final Jsonb JSONB = JsonbBuilder.create(JSON_CONFIG); | ||
public static Jsonb createJsonb() { | ||
return JsonbBuilder.create(createJsonbConfig()); | ||
} | ||
|
||
// Replaces the CDI producer for JsonbConfig built into Quarkus | ||
@Dependent | ||
JsonbConfig jsonConfig(Instance<JsonbConfigCustomizer> customizers) { | ||
JsonbConfig config = createJsonbConfig(); | ||
|
||
// Apply all JsonbConfigCustomizer beans (incl. Quarkus) | ||
for (JsonbConfigCustomizer customizer : customizers) { | ||
customizer.customize(config); | ||
} | ||
|
||
return config; | ||
} | ||
} |
22 changes: 0 additions & 22 deletions
22
...us/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JsonContextResolver.java
This file was deleted.
Oops, something went wrong.
12 changes: 8 additions & 4 deletions
12
.../src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckRequestTest.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
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
5 changes: 3 additions & 2 deletions
5
...us/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/EmvTagsTest.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
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
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
26 changes: 22 additions & 4 deletions
26
...gger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/JsonConfiguration.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,18 +1,36 @@ | ||
package ch.schlau.pesche.apidocs.swagger.codefirst.rest; | ||
|
||
import jakarta.enterprise.context.Dependent; | ||
import jakarta.enterprise.inject.Instance; | ||
import jakarta.json.bind.Jsonb; | ||
import jakarta.json.bind.JsonbBuilder; | ||
import jakarta.json.bind.JsonbConfig; | ||
|
||
import ch.schlau.pesche.apidocs.swagger.codefirst.txproc.model.PanJsonAdapter; | ||
import lombok.experimental.UtilityClass; | ||
import io.quarkus.jsonb.JsonbConfigCustomizer; | ||
|
||
@UtilityClass | ||
public class JsonConfiguration { | ||
|
||
public static final JsonbConfig JSON_CONFIG = new JsonbConfig() | ||
public static JsonbConfig createJsonbConfig() { | ||
return new JsonbConfig() | ||
.withAdapters(new PanJsonAdapter()) | ||
; | ||
} | ||
|
||
public static final Jsonb JSONB = JsonbBuilder.create(JSON_CONFIG); | ||
public static Jsonb createJsonb() { | ||
return JsonbBuilder.create(createJsonbConfig()); | ||
} | ||
|
||
// Replaces the CDI producer for JsonbConfig built into Quarkus | ||
@Dependent | ||
JsonbConfig jsonConfig(Instance<JsonbConfigCustomizer> customizers) { | ||
JsonbConfig config = createJsonbConfig(); | ||
|
||
// Apply all JsonbConfigCustomizer beans (incl. Quarkus) | ||
for (JsonbConfigCustomizer customizer : customizers) { | ||
customizer.customize(config); | ||
} | ||
|
||
return config; | ||
} | ||
} |
22 changes: 0 additions & 22 deletions
22
...er/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/JsonContextResolver.java
This file was deleted.
Oops, something went wrong.
14 changes: 9 additions & 5 deletions
14
.../src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/PinCheckRequestTest.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,37 +1,41 @@ | ||
package ch.schlau.pesche.apidocs.swagger.codefirst.txproc; | ||
|
||
import static ch.schlau.pesche.apidocs.swagger.codefirst.rest.JsonConfiguration.JSONB; | ||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
import java.util.UUID; | ||
|
||
import jakarta.json.bind.Jsonb; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import ch.schlau.pesche.apidocs.swagger.codefirst.rest.JsonConfiguration; | ||
import ch.schlau.pesche.apidocs.swagger.codefirst.txproc.model.Pan; | ||
|
||
class PinCheckRequestTest { | ||
|
||
@Test | ||
void json_roundtrip() { | ||
|
||
Jsonb jsonb = JsonConfiguration.createJsonb(); | ||
|
||
PinCheckRequest request = new PinCheckRequest(); | ||
request.setUuid(UUID.fromString("abcdabcd-1234-5678-aaaa-cccccccccccc")); | ||
|
||
// JSON serialization | ||
String jsonString1 = JSONB.toJson(request); | ||
String jsonString1 = jsonb.toJson(request); | ||
assertThat(jsonString1, is("{\"uuid\":\"abcdabcd-1234-5678-aaaa-cccccccccccc\"}")); | ||
|
||
// set the other properties as well | ||
request.setPan(new Pan("111222333444")); | ||
request.setPinBlock("-secret-"); | ||
String jsonString2 = JSONB.toJson(request); | ||
String jsonString2 = jsonb.toJson(request); | ||
assertThat(jsonString2, is("{\"pan\":\"111222333444\",\"pinBlock\":\"-secret-\",\"uuid\":\"abcdabcd-1234-5678-aaaa-cccccccccccc\"}")); | ||
|
||
// JSON deserialization | ||
PinCheckRequest roundtrip = JSONB.fromJson(jsonString2, PinCheckRequest.class); | ||
PinCheckRequest roundtrip = jsonb.fromJson(jsonString2, PinCheckRequest.class); | ||
assertThat(roundtrip.getUuid().toString(), is("abcdabcd-1234-5678-aaaa-cccccccccccc")); | ||
assertThat(roundtrip.getPan().getPan(), is("111222333444")); | ||
assertThat(roundtrip.getPinBlock(), is("-secret-")); | ||
} | ||
} | ||
} |
Oops, something went wrong.