Skip to content

Commit 27596cd

Browse files
Test for keyword "exists" created
1 parent d8fd82a commit 27596cd

3 files changed

Lines changed: 138 additions & 0 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright © 2023 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.keywords;
17+
18+
import org.junit.jupiter.api.Assertions;
19+
import org.junit.jupiter.api.Disabled;
20+
import org.junit.jupiter.api.Test;
21+
import org.springframework.beans.factory.annotation.Autowired;
22+
import org.springframework.test.context.TestPropertySource;
23+
24+
import software.xdev.spring.data.eclipse.store.helper.TestUtil;
25+
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.IsolatedTestAnnotations;
26+
import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage;
27+
28+
29+
/**
30+
* These tests should show that all or most of the following keywords are available in this library: <a
31+
* href="https://docs.spring.io/spring-data/jpa/reference/repositories/query-keywords-reference.html">Repository query
32+
* keywords</a>
33+
*/
34+
@IsolatedTestAnnotations
35+
@TestPropertySource(
36+
properties =
37+
"org.eclipse.store.storage-directory=./target/keywords-tests-storage"
38+
)
39+
class KeywordsTest
40+
{
41+
@Autowired
42+
private EclipseStoreStorage storage;
43+
44+
@Test
45+
@Disabled("For now we don't need 'existsBy'")
46+
void simpleStoreAndRead(final MinimalRepository repository)
47+
{
48+
repository.save(new MinimalDaoObject("1"));
49+
50+
TestUtil.doBeforeAndAfterRestartOfDatastore(
51+
this.storage,
52+
() -> {
53+
Assertions.assertTrue(repository.existsByValue("1"));
54+
Assertions.assertFalse(repository.existsByValue("2"));
55+
}
56+
);
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright © 2023 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.keywords;
17+
18+
import jakarta.persistence.GeneratedValue;
19+
import jakarta.persistence.GenerationType;
20+
import jakarta.persistence.Id;
21+
22+
23+
public class MinimalDaoObject
24+
{
25+
@Id
26+
@GeneratedValue(strategy = GenerationType.AUTO)
27+
private int id;
28+
private String value;
29+
30+
public MinimalDaoObject(final String value)
31+
{
32+
this.value = value;
33+
}
34+
35+
public int getId()
36+
{
37+
return this.id;
38+
}
39+
40+
public void setId(final int id)
41+
{
42+
this.id = id;
43+
}
44+
45+
public String getValue()
46+
{
47+
return this.value;
48+
}
49+
50+
public void setValue(final String value)
51+
{
52+
this.value = value;
53+
}
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright © 2023 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.keywords;
17+
18+
import org.springframework.data.repository.Repository;
19+
20+
21+
public interface MinimalRepository extends Repository<MinimalDaoObject, Integer>
22+
{
23+
MinimalDaoObject save(MinimalDaoObject entity);
24+
25+
boolean existsByValue(String lastName);
26+
}

0 commit comments

Comments
 (0)