-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-748 - Fix return type for known entity classes.
Use null instead of an empty list when the target isn’t a collection as well. This verifies the indirect illegal argument exception in case target property and query won’t fit but keeps the lenient behaviour in place when a query returning collections actually returns single valued collections. The scopes of the logback dependencies have been clarified. Thanks to @nioertel for reporting the issue and helping to solve it. This fixes #748.
- Loading branch information
1 parent
95f5d18
commit 0c25e46
Showing
7 changed files
with
251 additions
and
82 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
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
74 changes: 74 additions & 0 deletions
74
...gm-tests/neo4j-ogm-integration-tests/src/main/java/org/neo4j/ogm/testutil/LoggerRule.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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright (c) 2002-2020 "Neo4j," | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.neo4j.ogm.testutil; | ||
|
||
import ch.qos.logback.classic.Logger; | ||
import ch.qos.logback.classic.spi.ILoggingEvent; | ||
import ch.qos.logback.core.read.ListAppender; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.junit.rules.TestRule; | ||
import org.junit.runner.Description; | ||
import org.junit.runners.model.Statement; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Naive rule to capture logging output. It assumes that logback is used during tests as SLF4J binding. | ||
* | ||
* @author Michael J. Simons | ||
*/ | ||
public class LoggerRule implements TestRule { | ||
|
||
private final ListAppender<ILoggingEvent> listAppender = new ListAppender<>(); | ||
private final Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); | ||
|
||
@Override | ||
public Statement apply(Statement base, Description description) { | ||
return new Statement() { | ||
@Override | ||
public void evaluate() throws Throwable { | ||
setup(); | ||
base.evaluate(); | ||
teardown(); | ||
} | ||
}; | ||
} | ||
|
||
private void setup() { | ||
logger.addAppender(listAppender); | ||
listAppender.start(); | ||
} | ||
|
||
private void teardown() { | ||
listAppender.stop(); | ||
listAppender.list.clear(); | ||
logger.detachAppender(listAppender); | ||
} | ||
|
||
public List<String> getMessages() { | ||
return listAppender.list.stream().map(e -> e.getMessage()).collect(Collectors.toList()); | ||
} | ||
|
||
public List<String> getFormattedMessages() { | ||
return listAppender.list.stream().map(e -> e.getFormattedMessage()).collect(Collectors.toList()); | ||
} | ||
|
||
} |
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
45 changes: 45 additions & 0 deletions
45
...ts/neo4j-ogm-integration-tests/src/test/java/org/neo4j/ogm/domain/gh551/ThingResult2.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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2002-2020 "Neo4j," | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.neo4j.ogm.domain.gh551; | ||
|
||
/** | ||
* @author Michael J. Simons | ||
*/ | ||
public class ThingResult2 { | ||
|
||
private String something; | ||
|
||
private ThingEntity entity; | ||
|
||
public String getSomething() { | ||
return something; | ||
} | ||
|
||
public void setSomething(String something) { | ||
this.something = something; | ||
} | ||
|
||
public ThingEntity getEntity() { | ||
return entity; | ||
} | ||
|
||
public void setEntity(ThingEntity entity) { | ||
this.entity = entity; | ||
} | ||
} |
Oops, something went wrong.