test(json-service): increase coverage to 100%
All checks were successful
Build, test and publish the Quarkus libraries / build (push) Successful in 2m1s
All checks were successful
Build, test and publish the Quarkus libraries / build (push) Successful in 2m1s
This commit is contained in:
parent
483c5b1b57
commit
fa1578f667
2 changed files with 21 additions and 1 deletions
|
@ -42,7 +42,7 @@
|
|||
<limit>
|
||||
<counter>INSTRUCTION</counter>
|
||||
<value>COVEREDRATIO</value>
|
||||
<minimum>0.83</minimum>
|
||||
<minimum>1</minimum>
|
||||
</limit>
|
||||
</limits>
|
||||
</rule>
|
||||
|
|
|
@ -17,6 +17,15 @@ class JsonServiceImplTest {
|
|||
|
||||
record TestRecord(String name, int age) {}
|
||||
|
||||
static class CircularReference {
|
||||
CircularReference reference;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CircularReference";
|
||||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
JsonServiceImpl jsonService;
|
||||
|
||||
|
@ -29,6 +38,17 @@ class JsonServiceImplTest {
|
|||
assertThat(actual).as("Json should match expected value").isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
void toJsonWithCircularReference() {
|
||||
var circularReference = new CircularReference();
|
||||
circularReference.reference = circularReference;
|
||||
|
||||
assertThatThrownBy(() -> jsonService.toJson(circularReference))
|
||||
.as("Should throw IllegalArgumentException when input is invalid")
|
||||
.isInstanceOf(IllegalArgumentException.class)
|
||||
.hasMessage("Unable to write object as json String: CircularReference");
|
||||
}
|
||||
|
||||
@Test
|
||||
void fromJsonWithClass() {
|
||||
var json = "{\"name\":\"John Doe\",\"age\":30}";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue