|
22 | 22 | import org.junit.jupiter.api.Test; |
23 | 23 | import org.springframework.beans.factory.annotation.Autowired; |
24 | 24 |
|
25 | | -import software.xdev.spring.data.eclipse.store.jpa.DefaultTestAnnotations; |
26 | | -import software.xdev.spring.data.eclipse.store.jpa.integration.repository.PersonToTest; |
27 | | -import software.xdev.spring.data.eclipse.store.jpa.integration.repository.PersonToTestRepository; |
| 25 | +import software.xdev.spring.data.eclipse.store.importer.EclipseStoreDataImporterComponent; |
| 26 | +import software.xdev.spring.data.eclipse.store.jpa.integration.repository.PersonToTestInEclipseStore; |
| 27 | +import software.xdev.spring.data.eclipse.store.jpa.integration.repository.PersonToTestInEclipseStoreRepository; |
| 28 | +import software.xdev.spring.data.eclipse.store.jpa.integration.repository.PersonToTestInJpa; |
| 29 | +import software.xdev.spring.data.eclipse.store.jpa.integration.repository.PersonToTestInJpaRepository; |
| 30 | +import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage; |
| 31 | +import software.xdev.spring.data.eclipse.store.repository.support.SimpleEclipseStoreRepository; |
28 | 32 |
|
29 | 33 |
|
30 | 34 | @DefaultTestAnnotations |
31 | | -public class IntegrationTest |
| 35 | +class IntegrationTest |
32 | 36 | { |
33 | 37 | @Autowired |
34 | | - private PersonToTestRepository personToTestRepository; |
| 38 | + private PersonToTestInEclipseStoreRepository personToTestInEclipseStoreRepository; |
| 39 | + |
| 40 | + @Autowired |
| 41 | + private PersonToTestInJpaRepository personToTestInJpaRepository; |
| 42 | + |
| 43 | + @Autowired |
| 44 | + private EclipseStoreDataImporterComponent eclipseStoreDataImporter; |
| 45 | + |
| 46 | + @Autowired |
| 47 | + private EclipseStoreStorage eclipseStoreStorage; |
35 | 48 |
|
36 | 49 | /** |
37 | 50 | * Super simple test if there are any start-up errors when running parallel to a JPA configuration |
38 | 51 | */ |
39 | 52 | @Test |
40 | 53 | void testBasicSaveAndFindSingleRecords() |
41 | 54 | { |
42 | | - final PersonToTest customer = new PersonToTest("", ""); |
43 | | - this.personToTestRepository.save(customer); |
| 55 | + final PersonToTestInEclipseStore customer = new PersonToTestInEclipseStore("", ""); |
| 56 | + this.personToTestInEclipseStoreRepository.save(customer); |
44 | 57 |
|
45 | | - final List<PersonToTest> customers = this.personToTestRepository.findAll(); |
| 58 | + final List<PersonToTestInEclipseStore> customers = this.personToTestInEclipseStoreRepository.findAll(); |
46 | 59 | Assertions.assertEquals(1, customers.size()); |
47 | 60 | Assertions.assertEquals(customer, customers.get(0)); |
48 | 61 | } |
| 62 | + |
| 63 | + @Test |
| 64 | + void testEclipseStoreImport() |
| 65 | + { |
| 66 | + final PersonToTestInJpa customer = new PersonToTestInJpa("1", "", ""); |
| 67 | + this.personToTestInJpaRepository.save(customer); |
| 68 | + |
| 69 | + final List<SimpleEclipseStoreRepository<?, ?>> simpleEclipseStoreRepositories = |
| 70 | + this.eclipseStoreDataImporter.importData(); |
| 71 | + Assertions.assertEquals(1, simpleEclipseStoreRepositories.size()); |
| 72 | + final List<?> allEntities = simpleEclipseStoreRepositories.get(0).findAll(); |
| 73 | + Assertions.assertEquals(1, allEntities.size()); |
| 74 | + |
| 75 | + this.eclipseStoreStorage.stop(); |
| 76 | + Assertions.assertEquals( |
| 77 | + 1, |
| 78 | + this.eclipseStoreStorage.getEntityCount(PersonToTestInJpa.class), |
| 79 | + "After restart the imported entities are not there anymore."); |
| 80 | + } |
| 81 | + |
| 82 | + @Test |
| 83 | + void testEclipseStoreEmptyImport() |
| 84 | + { |
| 85 | + final List<SimpleEclipseStoreRepository<?, ?>> simpleEclipseStoreRepositories = |
| 86 | + this.eclipseStoreDataImporter.importData(); |
| 87 | + Assertions.assertEquals(1, simpleEclipseStoreRepositories.size()); |
| 88 | + final List<?> allEntities = simpleEclipseStoreRepositories.get(0).findAll(); |
| 89 | + Assertions.assertEquals(0, allEntities.size()); |
| 90 | + } |
49 | 91 | } |
0 commit comments