Skip to content

Commit 4beb9eb

Browse files
committed
Add test SomeNames with various property names
1 parent fedca1b commit 4beb9eb

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.example.customer.naming;
2+
3+
import io.avaje.jsonb.Json;
4+
5+
@Json
6+
public record SomeNames(
7+
@Json.Property("$a")
8+
String a,
9+
10+
String $b,
11+
12+
@Json.Property("#")
13+
String hash,
14+
15+
@Json.Property("$")
16+
String dollar,
17+
18+
@Json.Property("$foo")
19+
String dollarFoo,
20+
21+
@Json.Property("\"with quotes\"")
22+
String withQuotes
23+
) {
24+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.example.customer.naming;
2+
3+
import io.avaje.jsonb.JsonType;
4+
import io.avaje.jsonb.Jsonb;
5+
import org.junit.jupiter.api.Test;
6+
7+
import static org.assertj.core.api.Assertions.assertThat;
8+
import static org.junit.jupiter.api.Assertions.*;
9+
10+
class SomeNamesTest {
11+
12+
Jsonb jsonb = Jsonb.newBuilder().build();
13+
JsonType<SomeNames> jsonType = jsonb.type(SomeNames.class);
14+
15+
@Test
16+
void toFrom() {
17+
SomeNames bean = new SomeNames("a", "b","c","d", "e", "f");
18+
19+
String asJson = jsonType.toJson(bean);
20+
assertThat(asJson).isEqualTo("{\"$a\":\"a\",\"$b\":\"b\",\"#\":\"c\",\"$\":\"d\",\"$foo\":\"e\",\"\\\"with quotes\\\"\":\"f\"}");
21+
22+
SomeNames fromJson = jsonType.fromJson(asJson);
23+
assertEquals(fromJson, bean);
24+
}
25+
}

0 commit comments

Comments
 (0)