Skip to content

Commit 7ed2ed7

Browse files
committed
DATAJDBC-172 - Polishing.
Formatting. Added @author tag.
1 parent 3065160 commit 7ed2ed7

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

src/main/java/org/springframework/data/jdbc/repository/support/JdbcRepositoryQuery.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* method.
2727
*
2828
* @author Jens Schauder
29+
* @author Kazuki Shimizu
2930
*/
3031
class JdbcRepositoryQuery implements RepositoryQuery {
3132

@@ -57,6 +58,7 @@ public Object execute(Object[] objects) {
5758
if (queryMethod.isCollectionQuery() || queryMethod.isStreamQuery()) {
5859
return context.getTemplate().query(query, parameters, rowMapper);
5960
} else {
61+
6062
try {
6163
return context.getTemplate().queryForObject(query, parameters, rowMapper);
6264
} catch (EmptyResultDataAccessException e) {

src/test/java/org/springframework/data/jdbc/repository/query/QueryAnnotationHsqlIntegrationTests.java

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@
1515
*/
1616
package org.springframework.data.jdbc.repository.query;
1717

18-
import static org.assertj.core.api.Assertions.*;
19-
20-
import java.util.List;
21-
import java.util.Optional;
22-
import java.util.stream.Stream;
23-
2418
import org.junit.ClassRule;
2519
import org.junit.Rule;
2620
import org.junit.Test;
@@ -39,21 +33,29 @@
3933
import org.springframework.test.context.junit4.rules.SpringMethodRule;
4034
import org.springframework.transaction.annotation.Transactional;
4135

36+
import java.util.List;
37+
import java.util.Optional;
38+
import java.util.stream.Stream;
39+
4240
import static org.assertj.core.api.Assertions.*;
4341

4442
/**
4543
* Tests the execution of queries from {@link Query} annotations on repository methods.
4644
*
4745
* @author Jens Schauder
46+
* @author Kazuki Shimizu
4847
*/
4948
@ContextConfiguration
5049
@Transactional
5150
public class QueryAnnotationHsqlIntegrationTests {
5251

53-
@Autowired DummyEntityRepository repository;
52+
@Autowired
53+
DummyEntityRepository repository;
5454

55-
@ClassRule public static final SpringClassRule classRule = new SpringClassRule();
56-
@Rule public SpringMethodRule methodRule = new SpringMethodRule();
55+
@ClassRule
56+
public static final SpringClassRule classRule = new SpringClassRule();
57+
@Rule
58+
public SpringMethodRule methodRule = new SpringMethodRule();
5759

5860
@Test // DATAJDBC-164
5961
public void executeCustomQueryWithoutParameter() {
@@ -65,8 +67,8 @@ public void executeCustomQueryWithoutParameter() {
6567
List<DummyEntity> entities = repository.findByNameContainingCapitalLetter();
6668

6769
assertThat(entities) //
68-
.extracting(e -> e.name) //
69-
.containsExactlyInAnyOrder("Example", "EXAMPLE");
70+
.extracting(e -> e.name) //
71+
.containsExactlyInAnyOrder("Example", "EXAMPLE");
7072

7173
}
7274

@@ -80,18 +82,17 @@ public void executeCustomQueryWithNamedParameters() {
8082
List<DummyEntity> entities = repository.findByNamedRangeWithNamedParameter("a", "c");
8183

8284
assertThat(entities) //
83-
.extracting(e -> e.name) //
84-
.containsExactlyInAnyOrder("b");
85+
.extracting(e -> e.name) //
86+
.containsExactlyInAnyOrder("b");
8587

8688
}
8789

8890
@Test // DATAJDBC-172
8991
public void executeCustomQueryWithReturnTypeIsOptional() {
9092

91-
DummyEntity dummyEntity = dummyEntity("a");
92-
repository.save(dummyEntity);
93+
repository.save(dummyEntity("a"));
9394

94-
Optional<DummyEntity> entity = repository.findByIdWithReturnTypeIsOptional(dummyEntity.id);
95+
Optional<DummyEntity> entity = repository.findByNameAsOptional("a");
9596

9697
assertThat(entity).map(e -> e.name).contains("a");
9798

@@ -160,8 +161,8 @@ public void executeCustomQueryWithReturnTypeIsStream() {
160161
Stream<DummyEntity> entities = repository.findAllWithReturnTypeIsStream();
161162

162163
assertThat(entities) //
163-
.extracting(e -> e.name) //
164-
.containsExactlyInAnyOrder("a", "b");
164+
.extracting(e -> e.name) //
165+
.containsExactlyInAnyOrder("a", "b");
165166

166167
}
167168

@@ -185,7 +186,8 @@ Class<?> testClass() {
185186

186187
private static class DummyEntity {
187188

188-
@Id Long id;
189+
@Id
190+
Long id;
189191

190192
String name;
191193
}

0 commit comments

Comments
 (0)