|
| 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.issues.gh2328; |
| 17 | + |
| 18 | +import reactor.core.publisher.Mono; |
| 19 | +import reactor.test.StepVerifier; |
| 20 | + |
| 21 | +import java.util.UUID; |
| 22 | + |
| 23 | +import org.junit.jupiter.api.Test; |
| 24 | +import org.neo4j.driver.Driver; |
| 25 | +import org.springframework.beans.factory.annotation.Autowired; |
| 26 | +import org.springframework.context.annotation.Bean; |
| 27 | +import org.springframework.context.annotation.Configuration; |
| 28 | +import org.springframework.data.neo4j.config.AbstractReactiveNeo4jConfig; |
| 29 | +import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository; |
| 30 | +import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories; |
| 31 | +import org.springframework.data.neo4j.test.Neo4jIntegrationTest; |
| 32 | +import org.springframework.transaction.annotation.EnableTransactionManagement; |
| 33 | + |
| 34 | +/** |
| 35 | + * @author Michael J. Simons |
| 36 | + * @soundtrack Motörhead - Better Motörhead Than Dead - Live At Hammersmith |
| 37 | + */ |
| 38 | +@Neo4jIntegrationTest |
| 39 | +class ReactiveGH2328IT extends TestBase { |
| 40 | + |
| 41 | + @Test |
| 42 | + void queriesFromCustomLocationsShouldBeFound(@Autowired SomeRepository someRepository) { |
| 43 | + |
| 44 | + someRepository.getSomeEntityViaNamedQuery() |
| 45 | + .as(StepVerifier::create) |
| 46 | + .expectNextMatches(this::requirements) |
| 47 | + .verifyComplete(); |
| 48 | + } |
| 49 | + |
| 50 | + public interface SomeRepository extends ReactiveNeo4jRepository<SomeEntity, UUID> { |
| 51 | + |
| 52 | + // Without a custom query, repository creation would fail with |
| 53 | + // Could not create query for |
| 54 | + // public abstract org.springframework.data.neo4j.integration.issues.gh2328.SomeEntity org.springframework.data.neo4j.integration.issues.gh2328.GH2328IT$SomeRepository.getSomeEntityViaNamedQuery()! |
| 55 | + // Reason: No property getSomeEntityViaNamedQuery found for type SomeEntity!; |
| 56 | + Mono<SomeEntity> getSomeEntityViaNamedQuery(); |
| 57 | + } |
| 58 | + |
| 59 | + @Configuration |
| 60 | + @EnableTransactionManagement |
| 61 | + @EnableReactiveNeo4jRepositories(considerNestedRepositories = true, namedQueriesLocation = "more-custom-queries.properties") |
| 62 | + static class Config extends AbstractReactiveNeo4jConfig { |
| 63 | + |
| 64 | + @Bean |
| 65 | + public Driver driver() { |
| 66 | + |
| 67 | + return neo4jConnectionSupport.getDriver(); |
| 68 | + } |
| 69 | + } |
| 70 | +} |
0 commit comments