Skip to content

Commit c5d095c

Browse files
Refactored ID tests to be isolated
1 parent 0e794a0 commit c5d095c

16 files changed

Lines changed: 82 additions & 35 deletions

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/TestConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public EmbeddedStorageFoundation<?> createEmbeddedStorageFoundation()
5555
}
5656

5757
@EventListener
58-
public void handleContextRefresh(final ContextRefreshedEvent event)
58+
public void handleContextRefresh(final ContextRefreshedEvent event) throws IOException
5959
{
6060
// Init with empty root object
6161
this.getStorageInstance().clearData();

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/tests/IdTest.java renamed to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/id/IdTest.java

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package software.xdev.spring.data.eclipse.store.integration.shared.tests;
16+
package software.xdev.spring.data.eclipse.store.integration.isolated.tests.id;
1717

1818
import static software.xdev.spring.data.eclipse.store.helper.TestUtil.restartDatastore;
1919

@@ -23,33 +23,39 @@
2323
import org.junit.jupiter.api.Assertions;
2424
import org.junit.jupiter.api.Test;
2525
import org.springframework.beans.factory.annotation.Autowired;
26+
import org.springframework.test.context.ContextConfiguration;
2627

2728
import software.xdev.spring.data.eclipse.store.helper.TestData;
2829
import software.xdev.spring.data.eclipse.store.helper.TestUtil;
29-
import software.xdev.spring.data.eclipse.store.integration.shared.DefaultTestAnnotations;
30-
import software.xdev.spring.data.eclipse.store.integration.shared.SharedTestConfiguration;
31-
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.id.CustomerWithIdInt;
32-
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.id.CustomerWithIdIntRepository;
33-
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.id.CustomerWithIdInteger;
34-
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.id.CustomerWithIdIntegerNoAutoGenerate;
35-
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.id.CustomerWithIdIntegerNoAutoGenerateRepository;
36-
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.id.CustomerWithIdIntegerRepository;
37-
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.id.CustomerWithIdLong;
38-
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.id.CustomerWithIdLongRepository;
39-
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.id.CustomerWithIdString;
40-
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.id.CustomerWithIdStringRepository;
41-
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.id.CustomerWithPurchase;
42-
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.id.CustomerWithPurchaseRepository;
43-
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.id.Purchase;
30+
import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations;
31+
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.CustomerWithIdInt;
32+
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.CustomerWithIdIntRepository;
33+
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.CustomerWithIdInteger;
34+
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.CustomerWithIdIntegerNoAutoGenerate;
35+
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.CustomerWithIdIntegerNoAutoGenerateRepository;
36+
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.CustomerWithIdIntegerRepository;
37+
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.CustomerWithIdLong;
38+
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.CustomerWithIdLongRepository;
39+
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.CustomerWithIdString;
40+
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.CustomerWithIdStringRepository;
41+
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.CustomerWithPurchase;
42+
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.CustomerWithPurchaseRepository;
43+
import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model.Purchase;
4444
import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage;
4545

4646

4747
@SuppressWarnings("OptionalGetWithoutIsPresent")
48-
@DefaultTestAnnotations
48+
@IsolatedTestAnnotations
49+
@ContextConfiguration(classes = {IdTestConfiguration.class})
4950
class IdTest
5051
{
52+
private final IdTestConfiguration configuration;
53+
5154
@Autowired
52-
private SharedTestConfiguration configuration;
55+
public IdTest(final IdTestConfiguration configuration)
56+
{
57+
this.configuration = configuration;
58+
}
5359

5460
@Test
5561
void testCreateSingleWithAutoIdInteger(@Autowired final CustomerWithIdIntegerRepository customerRepository)
@@ -90,7 +96,8 @@ void testSaveSingleWithoutAnyPreviousCall(@Autowired final CustomerWithIdInteger
9096

9197
@Test
9298
void testCreateSingleWithAutoIdIntegerWorkingCopyIdSet(
93-
@Autowired final CustomerWithIdIntegerRepository customerRepository)
99+
@Autowired final CustomerWithIdIntegerRepository customerRepository
100+
)
94101
{
95102
final CustomerWithIdInteger customer1 = new CustomerWithIdInteger(TestData.FIRST_NAME, TestData.LAST_NAME);
96103
Assertions.assertNull(customer1.getId());
@@ -120,7 +127,8 @@ void testCreateMultipleWithAutoIdInteger(@Autowired final CustomerWithIdIntegerR
120127

121128
@Test
122129
void testCreateMultipleWithAutoIdIntegerSingleFinds(
123-
@Autowired final CustomerWithIdIntegerRepository customerRepository)
130+
@Autowired final CustomerWithIdIntegerRepository customerRepository
131+
)
124132
{
125133
final CustomerWithIdInteger customer1 = new CustomerWithIdInteger(TestData.FIRST_NAME, TestData.LAST_NAME);
126134
customerRepository.save(customer1);
@@ -274,7 +282,8 @@ void testCreateMultipleWithNoAutoIdInteger(
274282

275283
@Test
276284
void testSaveSingleWithAutoIdInteger(
277-
@Autowired final CustomerWithIdIntegerRepository customerRepository)
285+
@Autowired final CustomerWithIdIntegerRepository customerRepository
286+
)
278287
{
279288
final CustomerWithIdInteger customer1 =
280289
new CustomerWithIdInteger();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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.id;
17+
18+
import org.eclipse.store.integrations.spring.boot.types.configuration.EclipseStoreProperties;
19+
import org.eclipse.store.integrations.spring.boot.types.factories.EmbeddedStorageFoundationFactory;
20+
import org.springframework.beans.factory.annotation.Autowired;
21+
import org.springframework.context.annotation.Configuration;
22+
23+
import software.xdev.spring.data.eclipse.store.integration.TestConfiguration;
24+
import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
25+
26+
27+
@Configuration
28+
@EnableEclipseStoreRepositories
29+
public class IdTestConfiguration extends TestConfiguration
30+
{
31+
@Autowired
32+
protected IdTestConfiguration(
33+
final EclipseStoreProperties defaultEclipseStoreProperties,
34+
final EmbeddedStorageFoundationFactory defaultEclipseStoreProvider)
35+
{
36+
super(defaultEclipseStoreProperties, defaultEclipseStoreProvider);
37+
}
38+
}

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/id/CustomerWithIdInt.java renamed to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/id/model/CustomerWithIdInt.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package software.xdev.spring.data.eclipse.store.integration.shared.repositories.id;
16+
package software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model;
1717

1818
import java.util.List;
1919
import java.util.Objects;

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/id/CustomerWithIdIntRepository.java renamed to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/id/model/CustomerWithIdIntRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package software.xdev.spring.data.eclipse.store.integration.shared.repositories.id;
16+
package software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model;
1717

1818
import org.springframework.data.repository.CrudRepository;
1919

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/id/CustomerWithIdInteger.java renamed to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/id/model/CustomerWithIdInteger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package software.xdev.spring.data.eclipse.store.integration.shared.repositories.id;
16+
package software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model;
1717

1818
import java.util.List;
1919
import java.util.Objects;

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/id/CustomerWithIdIntegerNoAutoGenerate.java renamed to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/id/model/CustomerWithIdIntegerNoAutoGenerate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package software.xdev.spring.data.eclipse.store.integration.shared.repositories.id;
16+
package software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model;
1717

1818
import java.util.List;
1919
import java.util.Objects;

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/id/CustomerWithIdIntegerNoAutoGenerateRepository.java renamed to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/id/model/CustomerWithIdIntegerNoAutoGenerateRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package software.xdev.spring.data.eclipse.store.integration.shared.repositories.id;
16+
package software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model;
1717

1818
import org.springframework.data.repository.CrudRepository;
1919

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/id/CustomerWithIdIntegerRepository.java renamed to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/id/model/CustomerWithIdIntegerRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package software.xdev.spring.data.eclipse.store.integration.shared.repositories.id;
16+
package software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model;
1717

1818
import org.springframework.data.repository.CrudRepository;
1919

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/repositories/id/CustomerWithIdLong.java renamed to spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/id/model/CustomerWithIdLong.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package software.xdev.spring.data.eclipse.store.integration.shared.repositories.id;
16+
package software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.model;
1717

1818
import java.util.Objects;
1919

0 commit comments

Comments
 (0)