Skip to content

Commit 767b909

Browse files
committed
Polishing.
Fix formatting. See #664
1 parent ea17c12 commit 767b909

File tree

10 files changed

+400
-415
lines changed

10 files changed

+400
-415
lines changed

couchbase/example/src/test/java/example/springdata/couchbase/repository/AirlineRepositoryIntegrationTests.java

+67-69
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
import static org.assertj.core.api.Assertions.*;
1919

20+
import example.springdata.couchbase.model.Airline;
21+
import example.springdata.couchbase.util.EnabledOnCouchbaseAvailable;
22+
2023
import java.util.List;
2124

2225
import org.junit.jupiter.api.BeforeEach;
@@ -26,9 +29,6 @@
2629
import org.springframework.boot.test.context.SpringBootTest;
2730
import org.springframework.data.couchbase.core.CouchbaseOperations;
2831

29-
import example.springdata.couchbase.model.Airline;
30-
import example.springdata.couchbase.util.EnabledOnCouchbaseAvailable;
31-
3232
/**
3333
* Integration tests showing basic CRUD operations through {@link AirlineRepository}.
3434
*
@@ -38,70 +38,68 @@
3838
@EnabledOnCouchbaseAvailable
3939
public class AirlineRepositoryIntegrationTests {
4040

41-
@Autowired
42-
AirlineRepository airlineRepository;
43-
44-
@Autowired
45-
CouchbaseOperations couchbaseOperations;
46-
47-
@BeforeEach
48-
public void before() {
49-
if (couchbaseOperations.existsById().one("LH")) {
50-
couchbaseOperations.removeById().one("LH");
51-
}
52-
}
53-
54-
/**
55-
* The derived query executes a N1QL query emitting a single element.
56-
*/
57-
@Test
58-
public void shouldFindAirlineN1ql() {
59-
60-
List<Airline> airlines = airlineRepository.findByIata("TQ");
61-
assertThat(airlines.get(0).getCallsign()).isEqualTo("TXW");
62-
}
63-
64-
/**
65-
* The derived query executes a N1QL query and the emitted element is used to invoke
66-
* {@link org.springframework.data.repository.reactive.ReactiveCrudRepository#findById(Object)} for an Id-based lookup.
67-
* Queries without a result do not emit a value.
68-
*/
69-
@Test
70-
public void shouldFindById() {
71-
72-
Airline airline = airlineRepository.findByIata("TQ").get(0);
73-
assertThat(airlineRepository.findById(airline.getId()).isPresent());
74-
}
75-
76-
/**
77-
* Find all {@link Airline}s applying the {@code airlines/all} view.
78-
*/
79-
@Test
80-
public void shouldFindByView() {
81-
82-
List<Airline> airlines = airlineRepository.findAllBy();
83-
84-
assertThat(airlines).hasSizeGreaterThan(100);
85-
}
86-
87-
/**
88-
* Created elements are emitted by the
89-
* {@link org.springframework.data.repository.reactive.ReactiveCrudRepository#save(Object)} method.
90-
*/
91-
@Test
92-
public void shouldCreateAirline() {
93-
94-
Airline airline = new Airline();
95-
96-
airline.setId("LH");
97-
airline.setIata("LH");
98-
airline.setIcao("DLH");
99-
airline.setCallsign("Lufthansa");
100-
airline.setName("Lufthansa");
101-
airline.setCountry("Germany");
102-
103-
airlineRepository.save(airline);
104-
105-
assertThat(airlineRepository.findById("LH")).contains(airline);
106-
}
41+
@Autowired AirlineRepository airlineRepository;
42+
43+
@Autowired CouchbaseOperations couchbaseOperations;
44+
45+
@BeforeEach
46+
public void before() {
47+
if (couchbaseOperations.existsById().one("LH")) {
48+
couchbaseOperations.removeById().one("LH");
49+
}
50+
}
51+
52+
/**
53+
* The derived query executes a N1QL query emitting a single element.
54+
*/
55+
@Test
56+
public void shouldFindAirlineN1ql() {
57+
58+
List<Airline> airlines = airlineRepository.findByIata("TQ");
59+
assertThat(airlines.get(0).getCallsign()).isEqualTo("TXW");
60+
}
61+
62+
/**
63+
* The derived query executes a N1QL query and the emitted element is used to invoke
64+
* {@link org.springframework.data.repository.reactive.ReactiveCrudRepository#findById(Object)} for an Id-based
65+
* lookup. Queries without a result do not emit a value.
66+
*/
67+
@Test
68+
public void shouldFindById() {
69+
70+
Airline airline = airlineRepository.findByIata("TQ").get(0);
71+
assertThat(airlineRepository.findById(airline.getId()).isPresent());
72+
}
73+
74+
/**
75+
* Find all {@link Airline}s applying the {@code airlines/all} view.
76+
*/
77+
@Test
78+
public void shouldFindByView() {
79+
80+
List<Airline> airlines = airlineRepository.findAllBy();
81+
82+
assertThat(airlines).hasSizeGreaterThan(100);
83+
}
84+
85+
/**
86+
* Created elements are emitted by the
87+
* {@link org.springframework.data.repository.reactive.ReactiveCrudRepository#save(Object)} method.
88+
*/
89+
@Test
90+
public void shouldCreateAirline() {
91+
92+
Airline airline = new Airline();
93+
94+
airline.setId("LH");
95+
airline.setIata("LH");
96+
airline.setIcao("DLH");
97+
airline.setCallsign("Lufthansa");
98+
airline.setName("Lufthansa");
99+
airline.setCountry("Germany");
100+
101+
airlineRepository.save(airline);
102+
103+
assertThat(airlineRepository.findById("LH")).contains(airline);
104+
}
107105
}

couchbase/reactive/src/test/java/example/springdata/couchbase/repository/ReactiveAirlineRepositoryIntegrationTests.java

+86-88
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717

1818
import static org.assertj.core.api.Assertions.*;
1919

20+
import example.springdata.couchbase.model.Airline;
21+
import example.springdata.couchbase.util.EnabledOnCouchbaseAvailable;
22+
import reactor.core.publisher.Mono;
23+
import reactor.test.StepVerifier;
24+
2025
import org.junit.jupiter.api.BeforeEach;
2126
import org.junit.jupiter.api.Test;
2227

2328
import org.springframework.beans.factory.annotation.Autowired;
2429
import org.springframework.boot.test.context.SpringBootTest;
2530
import org.springframework.data.couchbase.core.CouchbaseOperations;
2631

27-
import example.springdata.couchbase.model.Airline;
28-
import example.springdata.couchbase.util.EnabledOnCouchbaseAvailable;
29-
import reactor.core.publisher.Mono;
30-
import reactor.test.StepVerifier;
31-
3232
/**
3333
* Integration tests showing basic CRUD operations through {@link ReactiveAirlineRepository}
3434
*
@@ -38,87 +38,85 @@
3838
@EnabledOnCouchbaseAvailable
3939
public class ReactiveAirlineRepositoryIntegrationTests {
4040

41-
@Autowired
42-
ReactiveAirlineRepository airlineRepository;
43-
44-
@Autowired
45-
CouchbaseOperations couchbaseOperations;
46-
47-
@BeforeEach
48-
public void before() {
49-
if (couchbaseOperations.existsById().one("LH")) {
50-
couchbaseOperations.removeById().one("LH");
51-
}
52-
}
53-
54-
/**
55-
* The derived query executes a N1QL query emitting a single element.
56-
*/
57-
@Test
58-
public void shouldFindAirlineN1ql() {
59-
60-
airlineRepository.findByIata("TQ") //
61-
.as(StepVerifier::create) //
62-
.assertNext(it -> {
63-
assertThat(it.getCallsign()).isEqualTo("TXW");
64-
}).verifyComplete();
65-
}
66-
67-
/**
68-
* The derived query executes a N1QL query and the emitted element is used to invoke
69-
* {@link org.springframework.data.repository.reactive.ReactiveCrudRepository#findById(Object)} for an Id-based lookup.
70-
* Queries without a result do not emit a value.
71-
*/
72-
@Test
73-
public void shouldFindById() {
74-
75-
Mono<Airline> airline = airlineRepository.findByIata("TQ") //
76-
.map(Airline::getId) //
77-
.flatMap(airlineRepository::findById);
78-
79-
airline.as(StepVerifier::create) //
80-
.assertNext(it -> {
81-
82-
assertThat(it.getCallsign()).isEqualTo("TXW");
83-
}).verifyComplete();
84-
85-
}
86-
87-
/**
88-
* Find all {@link Airline}s applying the {@code airlines/all} view.
89-
*/
90-
@Test
91-
public void shouldFindAll() {
92-
airlineRepository.findAllBy().count() //
93-
.as(StepVerifier::create) //
94-
.assertNext(count -> {
95-
96-
assertThat(count).isGreaterThan(100);
97-
}).verifyComplete();
98-
}
99-
100-
/**
101-
* Created elements are emitted by the
102-
* {@link org.springframework.data.repository.reactive.ReactiveCrudRepository#save(Object)} method.
103-
*/
104-
@Test
105-
public void shouldCreateAirline() {
106-
107-
Airline airline = new Airline();
108-
109-
airline.setId("LH");
110-
airline.setIata("LH");
111-
airline.setIcao("DLH");
112-
airline.setCallsign("Lufthansa");
113-
airline.setName("Lufthansa");
114-
airline.setCountry("Germany");
115-
116-
Mono<Airline> airlineMono = airlineRepository.save(airline) //
117-
.map(Airline::getId) //
118-
.flatMap(airlineRepository::findById);
119-
120-
airlineMono.as(StepVerifier::create) //
121-
.expectNext(airline) //
122-
.verifyComplete();
123-
}
41+
@Autowired ReactiveAirlineRepository airlineRepository;
42+
43+
@Autowired CouchbaseOperations couchbaseOperations;
44+
45+
@BeforeEach
46+
public void before() {
47+
if (couchbaseOperations.existsById().one("LH")) {
48+
couchbaseOperations.removeById().one("LH");
49+
}
50+
}
51+
52+
/**
53+
* The derived query executes a N1QL query emitting a single element.
54+
*/
55+
@Test
56+
public void shouldFindAirlineN1ql() {
57+
58+
airlineRepository.findByIata("TQ") //
59+
.as(StepVerifier::create) //
60+
.assertNext(it -> {
61+
assertThat(it.getCallsign()).isEqualTo("TXW");
62+
}).verifyComplete();
63+
}
64+
65+
/**
66+
* The derived query executes a N1QL query and the emitted element is used to invoke
67+
* {@link org.springframework.data.repository.reactive.ReactiveCrudRepository#findById(Object)} for an Id-based
68+
* lookup. Queries without a result do not emit a value.
69+
*/
70+
@Test
71+
public void shouldFindById() {
72+
73+
Mono<Airline> airline = airlineRepository.findByIata("TQ") //
74+
.map(Airline::getId) //
75+
.flatMap(airlineRepository::findById);
76+
77+
airline.as(StepVerifier::create) //
78+
.assertNext(it -> {
79+
80+
assertThat(it.getCallsign()).isEqualTo("TXW");
81+
}).verifyComplete();
82+
83+
}
84+
85+
/**
86+
* Find all {@link Airline}s applying the {@code airlines/all} view.
87+
*/
88+
@Test
89+
public void shouldFindAll() {
90+
airlineRepository.findAllBy().count() //
91+
.as(StepVerifier::create) //
92+
.assertNext(count -> {
93+
94+
assertThat(count).isGreaterThan(100);
95+
}).verifyComplete();
96+
}
97+
98+
/**
99+
* Created elements are emitted by the
100+
* {@link org.springframework.data.repository.reactive.ReactiveCrudRepository#save(Object)} method.
101+
*/
102+
@Test
103+
public void shouldCreateAirline() {
104+
105+
Airline airline = new Airline();
106+
107+
airline.setId("LH");
108+
airline.setIata("LH");
109+
airline.setIcao("DLH");
110+
airline.setCallsign("Lufthansa");
111+
airline.setName("Lufthansa");
112+
airline.setCountry("Germany");
113+
114+
Mono<Airline> airlineMono = airlineRepository.save(airline) //
115+
.map(Airline::getId) //
116+
.flatMap(airlineRepository::findById);
117+
118+
airlineMono.as(StepVerifier::create) //
119+
.expectNext(airline) //
120+
.verifyComplete();
121+
}
124122
}

0 commit comments

Comments
 (0)