Skip to content
This repository was archived by the owner on Jun 7, 2025. It is now read-only.

Commit f485563

Browse files
committed
Fix tests
1 parent bc2cb7f commit f485563

4 files changed

Lines changed: 27 additions & 14 deletions

File tree

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<lib.datanucleus-rdbms.version>6.0.8</lib.datanucleus-rdbms.version>
6969
<lib.junit-jupiter.version>5.11.0</lib.junit-jupiter.version>
7070
<lib.postgresql.version>42.7.4</lib.postgresql.version>
71+
<lib.slf4j.version>2.0.16</lib.slf4j.version>
7172
<lib.testcontainers.version>1.20.1</lib.testcontainers.version>
7273

7374
<!-- Default SCM Properties -->
@@ -127,6 +128,12 @@
127128
<artifactId>postgresql</artifactId>
128129
<version>${lib.testcontainers.version}</version>
129130
</dependency>
131+
132+
<dependency>
133+
<groupId>org.slf4j</groupId>
134+
<artifactId>slf4j-simple</artifactId>
135+
<version>${lib.slf4j.version}</version>
136+
</dependency>
130137
</dependencies>
131138
</dependencyManagement>
132139

test/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@
6464
<artifactId>postgresql</artifactId>
6565
<scope>test</scope>
6666
</dependency>
67+
68+
<dependency>
69+
<groupId>org.slf4j</groupId>
70+
<artifactId>slf4j-simple</artifactId>
71+
<scope>test</scope>
72+
</dependency>
6773
</dependencies>
6874

6975
<build>

test/src/main/java/io/github/nscuro/datanucleus/postgresql/test/model/Person.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class Person {
4040
@Extension(vendorName = "datanucleus", key = "insert-function", value = "(?::JSONB)"),
4141
@Extension(vendorName = "datanucleus", key = "update-function", value = "(?::JSONB)")
4242
})
43-
private String propertiesJson;
43+
private String properties;
4444

4545
public long getId() {
4646
return id;
@@ -58,12 +58,12 @@ public void setName(final String name) {
5858
this.name = name;
5959
}
6060

61-
public String getPropertiesJson() {
62-
return propertiesJson;
61+
public String getProperties() {
62+
return properties;
6363
}
6464

65-
public void setPropertiesJson(final String propertiesJson) {
66-
this.propertiesJson = propertiesJson;
65+
public void setProperties(final String properties) {
66+
this.properties = properties;
6767
}
6868

6969
}

test/src/test/java/io/github/nscuro/datanucleus/postgresql/method/JsonbContainsMethodTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static void afterAll() {
7878
@Test
7979
void shouldMatchWithStringParameter() {
8080
final var person = new Person();
81-
person.setPropertiesJson(/* language=JSON */ """
81+
person.setProperties(/* language=JSON */ """
8282
[
8383
{
8484
"foo": "bar",
@@ -89,7 +89,7 @@ void shouldMatchWithStringParameter() {
8989
pm.makePersistent(person);
9090

9191
final Query<Person> query = pm.newQuery(Person.class);
92-
query.setFilter("addressesJson.jsonbContains(:foo)");
92+
query.setFilter("properties.jsonbContains(:foo)");
9393
query.setParameters("[{\"baz\":111}]");
9494

9595
final Person queryResult = query.executeUnique();
@@ -99,7 +99,7 @@ void shouldMatchWithStringParameter() {
9999
@Test
100100
void shouldMatchWithStringLiteral() {
101101
final var person = new Person();
102-
person.setPropertiesJson(/* language=JSON */ """
102+
person.setProperties(/* language=JSON */ """
103103
[
104104
{
105105
"foo": "bar",
@@ -110,7 +110,7 @@ void shouldMatchWithStringLiteral() {
110110
pm.makePersistent(person);
111111

112112
final Query<Person> query = pm.newQuery(Person.class);
113-
query.setFilter("addressesJson.jsonbContains('[{\"baz\":111}]')");
113+
query.setFilter("properties.jsonbContains('[{\"baz\":111}]')");
114114

115115
final Person queryResult = query.executeUnique();
116116
assertThat(queryResult).isNotNull();
@@ -119,7 +119,7 @@ void shouldMatchWithStringLiteral() {
119119
@Test
120120
void shouldThrowForNonJsonStringArgument() {
121121
final var person = new Person();
122-
person.setPropertiesJson(/* language=JSON */ """
122+
person.setProperties(/* language=JSON */ """
123123
[
124124
{
125125
"foo": "bar",
@@ -130,7 +130,7 @@ void shouldThrowForNonJsonStringArgument() {
130130
pm.makePersistent(person);
131131

132132
final Query<Person> query = pm.newQuery(Person.class);
133-
query.setFilter("addressesJson.jsonbContains('not-json')");
133+
query.setFilter("properties.jsonbContains('not-json')");
134134
query.setParameters(123);
135135

136136
assertThatExceptionOfType(JDOException.class)
@@ -140,14 +140,14 @@ void shouldThrowForNonJsonStringArgument() {
140140
.withMessage("""
141141
ERROR: invalid input syntax for type json
142142
Detail: Token "not" is invalid.
143-
Position: 189
143+
Position: 172
144144
Where: JSON data, line 1: not...""");
145145
}
146146

147147
@Test
148148
void shouldThrowForNonStringArgument() {
149149
final var person = new Person();
150-
person.setPropertiesJson(/* language=JSON */ """
150+
person.setProperties(/* language=JSON */ """
151151
[
152152
{
153153
"foo": "bar",
@@ -158,7 +158,7 @@ void shouldThrowForNonStringArgument() {
158158
pm.makePersistent(person);
159159

160160
final Query<Person> query = pm.newQuery(Person.class);
161-
query.setFilter("addressesJson.jsonbContains(:foo)");
161+
query.setFilter("properties.jsonbContains(:foo)");
162162
query.setParameters(123);
163163

164164
assertThatExceptionOfType(JDOException.class)

0 commit comments

Comments
 (0)