Skip to content

Commit b660422

Browse files
Fix failing test.
1 parent be722fd commit b660422

File tree

2 files changed

+72
-6
lines changed

2 files changed

+72
-6
lines changed

src/test/java/org/springframework/data/neo4j/integration/conversion_imperative/TypeConversionIT.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.springframework.data.neo4j.config.AbstractNeo4jConfig;
5454
import org.springframework.data.neo4j.core.convert.Neo4jConversions;
5555
import org.springframework.data.neo4j.core.Neo4jTemplate;
56+
import org.springframework.data.neo4j.integration.shared.common.AllArgsCtorNoBuilder;
5657
import org.springframework.data.neo4j.integration.shared.common.ThingWithAllCypherTypes2;
5758
import org.springframework.data.neo4j.integration.shared.conversion.Neo4jConversionsITBase;
5859
import org.springframework.data.neo4j.integration.shared.conversion.ThingWithAllAdditionalTypes;
@@ -97,19 +98,19 @@ class TypeConversionIT extends Neo4jConversionsITBase {
9798
}
9899

99100
@Test
100-
void thereShallBeNoDefaultValuesForNonExistingAttributes() {
101+
void thereShallBeNoDefaultValuesForNonExistingAttributes(@Autowired Neo4jTemplate template) {
101102

102103
Long id;
103104
try (Session session = neo4jConnectionSupport.getDriver().session()) {
104105

105-
id = session.writeTransaction(tx -> tx.run("CREATE (n:CypherTypes) RETURN id(n)").single().get(0).asLong());
106+
id = session.writeTransaction(tx -> tx.run("CREATE (n:AllArgsCtorNoBuilder) RETURN id(n)").single().get(0).asLong());
106107
}
107108

108109
assertThatExceptionOfType(MappingException.class)
109-
.isThrownBy(() -> cypherTypesRepository.findById(id))
110-
.withMessageMatching("Error mapping Record<\\{n: .*>")
111-
.withStackTraceContaining("Illegal arguments for constructor")
112-
.withRootCauseInstanceOf(IllegalArgumentException.class);
110+
.isThrownBy(() -> template.findById(id, AllArgsCtorNoBuilder.class))
111+
.withMessageMatching("Error mapping Record<\\{.+: .*>")
112+
.withRootCauseInstanceOf(IllegalArgumentException.class)
113+
.withStackTraceContaining("Parameter aBoolean must not be null!");
113114
}
114115

115116
@TestFactory
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright 2011-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.neo4j.integration.shared.common;
17+
18+
import org.springframework.data.neo4j.core.schema.GeneratedValue;
19+
import org.springframework.data.neo4j.core.schema.Id;
20+
import org.springframework.data.neo4j.core.schema.Node;
21+
22+
/**
23+
* Must require ctor instantiation and must not have a builder.
24+
* @author Michael J. Simons
25+
*/
26+
@Node
27+
public class AllArgsCtorNoBuilder {
28+
29+
@Id @GeneratedValue public Long id;
30+
31+
private boolean aBoolean;
32+
33+
private long aLong;
34+
35+
private double aDouble;
36+
37+
private String aString;
38+
39+
public AllArgsCtorNoBuilder(boolean aBoolean, long aLong, double aDouble, String aString) {
40+
this.aBoolean = aBoolean;
41+
this.aLong = aLong;
42+
this.aDouble = aDouble;
43+
this.aString = aString;
44+
}
45+
46+
public Long getId() {
47+
return id;
48+
}
49+
50+
public boolean isaBoolean() {
51+
return aBoolean;
52+
}
53+
54+
public long getaLong() {
55+
return aLong;
56+
}
57+
58+
public double getaDouble() {
59+
return aDouble;
60+
}
61+
62+
public String getaString() {
63+
return aString;
64+
}
65+
}

0 commit comments

Comments
 (0)