Skip to content

Commit 7370106

Browse files
Restructured query tests
1 parent 522804b commit 7370106

10 files changed

Lines changed: 865 additions & 408 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Copyright © 2024 XDEV Software (https://xdev.software)
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+
* http://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 software.xdev.spring.data.eclipse.store.integration.isolated.tests.query.by.string;
17+
18+
import java.util.Objects;
19+
20+
21+
public class Child
22+
{
23+
private String firstName;
24+
private String lastName;
25+
26+
public Child(final String firstName, final String lastName)
27+
{
28+
this.firstName = firstName;
29+
this.lastName = lastName;
30+
}
31+
32+
public String getFirstName()
33+
{
34+
return this.firstName;
35+
}
36+
37+
public void setFirstName(final String firstName)
38+
{
39+
this.firstName = firstName;
40+
}
41+
42+
public String getLastName()
43+
{
44+
return this.lastName;
45+
}
46+
47+
public void setLastName(final String lastName)
48+
{
49+
this.lastName = lastName;
50+
}
51+
52+
@Override
53+
public String toString()
54+
{
55+
return String.format(
56+
"Child[firstName='%s', lastName='%s']",
57+
this.firstName, this.lastName);
58+
}
59+
60+
@Override
61+
public boolean equals(final Object o)
62+
{
63+
if(this == o)
64+
{
65+
return true;
66+
}
67+
if(o == null || this.getClass() != o.getClass())
68+
{
69+
return false;
70+
}
71+
final Child customer = (Child)o;
72+
return Objects.equals(this.firstName, customer.firstName) && Objects.equals(
73+
this.lastName,
74+
customer.lastName);
75+
}
76+
77+
@Override
78+
public int hashCode()
79+
{
80+
return Objects.hash(this.firstName, this.lastName);
81+
}
82+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* Copyright © 2024 XDEV Software (https://xdev.software)
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+
* http://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 software.xdev.spring.data.eclipse.store.integration.isolated.tests.query.by.string;
17+
18+
import java.util.List;
19+
import java.util.Objects;
20+
21+
22+
public class Customer
23+
{
24+
private String firstName;
25+
private String lastName;
26+
27+
public Customer(final String firstName, final String lastName)
28+
{
29+
this.firstName = firstName;
30+
this.lastName = lastName;
31+
}
32+
33+
public String getFirstName()
34+
{
35+
return this.firstName;
36+
}
37+
38+
public void setFirstName(final String firstName)
39+
{
40+
this.firstName = firstName;
41+
}
42+
43+
public String getLastName()
44+
{
45+
return this.lastName;
46+
}
47+
48+
public void setLastName(final String lastName)
49+
{
50+
this.lastName = lastName;
51+
}
52+
53+
@Override
54+
public String toString()
55+
{
56+
return String.format(
57+
"Customer[firstName='%s', lastName='%s']",
58+
this.firstName, this.lastName);
59+
}
60+
61+
@Override
62+
public boolean equals(final Object o)
63+
{
64+
if(this == o)
65+
{
66+
return true;
67+
}
68+
if(o == null || this.getClass() != o.getClass())
69+
{
70+
return false;
71+
}
72+
final Customer customer = (Customer)o;
73+
return Objects.equals(this.firstName, customer.firstName) && Objects.equals(
74+
this.lastName,
75+
customer.lastName);
76+
}
77+
78+
@Override
79+
public int hashCode()
80+
{
81+
return Objects.hash(this.firstName, this.lastName);
82+
}
83+
84+
@SuppressWarnings("OptionalGetWithoutIsPresent")
85+
public static Customer getCustomerWithFirstName(final List<Customer> customers, final String firstName)
86+
{
87+
return customers.stream().filter(customer -> customer.getFirstName().equals(firstName)).findFirst().get();
88+
}
89+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright © 2024 XDEV Software (https://xdev.software)
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+
* http://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 software.xdev.spring.data.eclipse.store.integration.isolated.tests.query.by.string;
17+
18+
import java.util.List;
19+
import java.util.Optional;
20+
21+
import org.springframework.data.domain.Page;
22+
import org.springframework.data.domain.Pageable;
23+
import org.springframework.data.domain.Sort;
24+
import org.springframework.data.repository.CrudRepository;
25+
import org.springframework.data.repository.PagingAndSortingRepository;
26+
27+
28+
public interface CustomerRepository
29+
extends CrudRepository<Customer, String>, PagingAndSortingRepository<Customer, String>
30+
{
31+
Optional<Customer> findByFirstName(String firstName);
32+
33+
Iterable<Customer> findAllByLastName(String lastName);
34+
35+
@Override
36+
Page<Customer> findAll(Pageable pageable);
37+
38+
Page<Customer> findAllByLastName(String lastName, Pageable pageable);
39+
40+
List<Customer> findByOrderByLastNameAsc();
41+
42+
Iterable<Customer> findAllByLastName(String lastName, Sort sort);
43+
44+
List<Customer> findAllByFirstName(String lastName, Pageable pageable);
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/*
2+
* Copyright © 2024 XDEV Software (https://xdev.software)
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+
* http://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 software.xdev.spring.data.eclipse.store.integration.isolated.tests.query.by.string;
17+
18+
import java.util.List;
19+
import java.util.Objects;
20+
21+
22+
public class CustomerWithChild
23+
{
24+
private String firstName;
25+
private String lastName;
26+
27+
private Child child;
28+
29+
public CustomerWithChild(final String firstName, final String lastName, final Child child)
30+
{
31+
this.firstName = firstName;
32+
this.lastName = lastName;
33+
this.child = child;
34+
}
35+
36+
public String getFirstName()
37+
{
38+
return this.firstName;
39+
}
40+
41+
public void setFirstName(final String firstName)
42+
{
43+
this.firstName = firstName;
44+
}
45+
46+
public String getLastName()
47+
{
48+
return this.lastName;
49+
}
50+
51+
public void setLastName(final String lastName)
52+
{
53+
this.lastName = lastName;
54+
}
55+
56+
public Child getChild()
57+
{
58+
return this.child;
59+
}
60+
61+
public void setChild(final Child child)
62+
{
63+
this.child = child;
64+
}
65+
66+
@Override
67+
public String toString()
68+
{
69+
return String.format(
70+
"Customer[firstName='%s', lastName='%s']",
71+
this.firstName, this.lastName);
72+
}
73+
74+
@Override
75+
public boolean equals(final Object o)
76+
{
77+
if(this == o)
78+
{
79+
return true;
80+
}
81+
if(o == null || this.getClass() != o.getClass())
82+
{
83+
return false;
84+
}
85+
final CustomerWithChild customer = (CustomerWithChild)o;
86+
return Objects.equals(this.firstName, customer.firstName) && Objects.equals(
87+
this.lastName,
88+
customer.lastName);
89+
}
90+
91+
@Override
92+
public int hashCode()
93+
{
94+
return Objects.hash(this.firstName, this.lastName);
95+
}
96+
97+
@SuppressWarnings("OptionalGetWithoutIsPresent")
98+
public static CustomerWithChild getCustomerWithFirstName(
99+
final List<CustomerWithChild> customers,
100+
final String firstName)
101+
{
102+
return customers.stream().filter(customer -> customer.getFirstName().equals(firstName)).findFirst().get();
103+
}
104+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright © 2024 XDEV Software (https://xdev.software)
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+
* http://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 software.xdev.spring.data.eclipse.store.integration.isolated.tests.query.by.string;
17+
18+
import java.util.Optional;
19+
20+
import org.springframework.data.repository.CrudRepository;
21+
22+
23+
public interface CustomerWithChildRepository extends CrudRepository<CustomerWithChild, String>
24+
{
25+
Optional<CustomerWithChild> findByChild(Child child);
26+
}

0 commit comments

Comments
 (0)