Skip to content

Commit 01f45da

Browse files
Added deletion test
1 parent 58c8fde commit 01f45da

7 files changed

Lines changed: 181 additions & 1 deletion

File tree

spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/lazy/SpringDataEclipseStoreLazyBinaryHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* The user creates a {@link SpringDataEclipseStoreLazy} and puts a object in it.
4242
* This object is stored as with a default {@link BinaryTypeHandler}. But when it gets loaded,
4343
* it <b>does not</b> load as the stored object, but it gets wrapped in a {@link Lazy#Reference(Object)}.
44-
* </p>
44+
* </p>
4545
* <p>
4646
* Second case:<br/>
4747
* The actual lazy object gets loaded from the actual storage. In this case the {@link ObjectSwizzling} is
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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.deletion;
17+
18+
import java.util.List;
19+
20+
import org.junit.jupiter.api.Assertions;
21+
import org.junit.jupiter.api.Test;
22+
import org.springframework.beans.factory.annotation.Autowired;
23+
import org.springframework.test.context.ContextConfiguration;
24+
25+
import software.xdev.spring.data.eclipse.store.helper.TestUtil;
26+
import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations;
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+
@ContextConfiguration(classes = {DeletionTestConfiguration.class})
36+
class DeletionTest
37+
{
38+
@Autowired
39+
private DeletionTestConfiguration configuration;
40+
41+
@Test
42+
void simpleStoreAndRead(
43+
final ReferencedRepository referencedRepository,
44+
final ReferencingRepository referencingRepository)
45+
{
46+
final ReferencedDaoObject referencedObject = new ReferencedDaoObject("someValue");
47+
final ReferencingDaoObject referencingDaoObject = new ReferencingDaoObject(referencedObject);
48+
referencingRepository.save(referencingDaoObject);
49+
50+
Assertions.assertEquals(1, TestUtil.iterableToList(referencingRepository.findAll()).size());
51+
Assertions.assertEquals(1, TestUtil.iterableToList(referencedRepository.findAll()).size());
52+
53+
referencedRepository.delete(referencedObject);
54+
55+
TestUtil.doBeforeAndAfterRestartOfDatastore(
56+
this.configuration,
57+
() -> {
58+
Assertions.assertTrue(TestUtil.iterableToList(referencedRepository.findAll()).isEmpty());
59+
final List<ReferencingDaoObject> referencingDaoObjects =
60+
TestUtil.iterableToList(referencingRepository.findAll());
61+
Assertions.assertEquals(1, referencingDaoObjects.size());
62+
Assertions.assertNotNull(referencingDaoObjects.get(0).value());
63+
}
64+
);
65+
}
66+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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.deletion;
17+
18+
import org.springframework.context.annotation.Configuration;
19+
20+
import software.xdev.spring.data.eclipse.store.integration.TestConfiguration;
21+
import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
22+
23+
24+
@Configuration
25+
@EnableEclipseStoreRepositories(clientConfigurationClass = DeletionTestConfiguration.class)
26+
public class DeletionTestConfiguration extends TestConfiguration
27+
{
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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.deletion;
17+
18+
public record ReferencedDaoObject(String value)
19+
{
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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.deletion;
17+
18+
import org.springframework.data.repository.CrudRepository;
19+
20+
21+
public interface ReferencedRepository extends CrudRepository<ReferencedDaoObject, Integer>
22+
{
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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.deletion;
17+
18+
public record ReferencingDaoObject(ReferencedDaoObject value)
19+
{
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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.deletion;
17+
18+
import org.springframework.data.repository.CrudRepository;
19+
20+
21+
public interface ReferencingRepository extends CrudRepository<ReferencingDaoObject, Integer>
22+
{
23+
}

0 commit comments

Comments
 (0)