|
43 | 43 | import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.custom.model.CustomerWithIdLocalDate;
|
44 | 44 | import software.xdev.spring.data.eclipse.store.integration.isolated.tests.id.custom.model.CustomerWithIdLocalDateRepository;
|
45 | 45 | import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository;
|
| 46 | +import software.xdev.spring.data.eclipse.store.repository.root.v2_4.EntityData; |
46 | 47 |
|
47 | 48 |
|
48 | 49 | @SuppressWarnings("OptionalGetWithoutIsPresent")
|
@@ -141,6 +142,55 @@ <T, ID> void createDoubleWithCustomKey(
|
141 | 142 | );
|
142 | 143 | }
|
143 | 144 |
|
| 145 | + @ParameterizedTest |
| 146 | + @MethodSource("generateData") |
| 147 | + <T, ID> void createDoubleWithSameKey( |
| 148 | + final SingleTestDataset<T, ID> data, @Autowired final ApplicationContext context) |
| 149 | + { |
| 150 | + final EclipseStoreRepository<T, ID> repository = data.repositoryGenerator().apply(context); |
| 151 | + |
| 152 | + final T customer1 = data.enitityGenerator().apply(data.firstIdSupplier().get()); |
| 153 | + repository.save(customer1); |
| 154 | + |
| 155 | + final T customer2 = data.enitityGenerator().apply(data.firstIdSupplier().get()); |
| 156 | + repository.save(customer2); |
| 157 | + |
| 158 | + TestUtil.doBeforeAndAfterRestartOfDatastore( |
| 159 | + this.configuration, |
| 160 | + () -> { |
| 161 | + Assertions.assertEquals(1, repository.findAll().size()); |
| 162 | + Assertions.assertEquals( |
| 163 | + 1, |
| 164 | + repository.findAllById(List.of(data.firstIdSupplier().get())).size()); |
| 165 | + |
| 166 | + final Optional<T> loadedCustomer1 = repository.findById(data.firstIdSupplier().get()); |
| 167 | + Assertions.assertTrue(loadedCustomer1.isPresent()); |
| 168 | + Assertions.assertEquals(customer1, loadedCustomer1.get()); |
| 169 | + Assertions.assertEquals(customer2, loadedCustomer1.get()); |
| 170 | + } |
| 171 | + ); |
| 172 | + } |
| 173 | + |
| 174 | + @ParameterizedTest |
| 175 | + @MethodSource("generateData") |
| 176 | + <T, ID> void checkIfIdIsUsedInRepo( |
| 177 | + final SingleTestDataset<T, ID> data, |
| 178 | + @Autowired final ApplicationContext context, |
| 179 | + @Autowired final IdTestConfiguration currentConfiguration) |
| 180 | + { |
| 181 | + final EclipseStoreRepository<T, ID> repository = data.repositoryGenerator().apply(context); |
| 182 | + |
| 183 | + final T customer1 = data.enitityGenerator().apply(data.firstIdSupplier().get()); |
| 184 | + repository.save(customer1); |
| 185 | + |
| 186 | + final EntityData<?, Object> entityData = |
| 187 | + currentConfiguration.getStorageInstance() |
| 188 | + .getRoot() |
| 189 | + .getCurrentRootData() |
| 190 | + .getEntityData(customer1.getClass()); |
| 191 | + Assertions.assertEquals(customer1, entityData.getEntityById(data.firstIdSupplier().get())); |
| 192 | + } |
| 193 | + |
144 | 194 | @ParameterizedTest
|
145 | 195 | @MethodSource("generateData")
|
146 | 196 | <T, ID> void createNullWithCustomKey(
|
|
0 commit comments