diff --git a/.config/checkstyle/checkstyle.xml b/.config/checkstyle/checkstyle.xml index 506f37c0..a0d7f178 100644 --- a/.config/checkstyle/checkstyle.xml +++ b/.config/checkstyle/checkstyle.xml @@ -16,7 +16,7 @@ - + @@ -30,10 +30,6 @@ - - - - @@ -43,7 +39,15 @@ + + + + + + + + @@ -131,11 +135,5 @@ - - - - - - diff --git a/.github/workflows/checkBuild.yml b/.github/workflows/checkBuild.yml index c49a9c1d..5f2678b6 100644 --- a/.github/workflows/checkBuild.yml +++ b/.github/workflows/checkBuild.yml @@ -7,6 +7,7 @@ on: paths-ignore: - '**.md' - '.config/**' + - '.github/**' - '.idea/**' - 'assets/**' pull_request: @@ -14,6 +15,7 @@ on: paths-ignore: - '**.md' - '.config/**' + - '.github/**' - '.idea/**' - 'assets/**' diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml index bd37fc96..39335e05 100644 --- a/.github/workflows/sonar.yml +++ b/.github/workflows/sonar.yml @@ -7,6 +7,7 @@ on: paths-ignore: - '**.md' - '.config/**' + - '.github/**' - '.idea/**' - 'assets/**' pull_request: @@ -14,6 +15,7 @@ on: paths-ignore: - '**.md' - '.config/**' + - '.github/**' - '.idea/**' - 'assets/**' diff --git a/CHANGELOG.md b/CHANGELOG.md index ff3e150e..faad4e2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 1.0.3 + +* Added the EclipseStoreDataImporter to import data from JPA repositories. +* Updated EclipseStore to version 1.2.0 +* Updated Spring to version 3.2.3 + # 1.0.2 * Added the EclipseStoreCustomRepository which has no methods defined at all. diff --git a/LICENSE b/LICENSE index 2316c756..864bb41e 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2023 XDEV Software + Copyright 2024 XDEV Software Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index a0585e91..40cf0f50 100644 --- a/README.md +++ b/README.md @@ -53,13 +53,12 @@ With *Spring-Data-Eclipse-Store* every time an object is loaded from the datasto ## Installation [Installation guide for the latest release](https://github.com/xdev-software/spring-data-eclipse-store/releases/latest#Installation) -### Prerequisites +### Supported versions -| | Minimal Version | -|--------------|-----------------| -| Java | ``17`` | -| Spring Data | ``3.2.2`` | -| EclipseStore | ``1.1.0`` | +| Spring-Data-Eclipse-Store | Java | Spring Data | EclipseStore | +|---------------------------|--------|-------------|--------------| +| ``<= 1.0.2`` | ``17`` | ``3.2.2`` | ``1.1.0`` | +| ``1.0.3`` | ``17`` | ``3.2.3`` | ``1.2.0`` | ### Usage diff --git a/spring-data-eclipse-store-benchmark/pom.xml b/spring-data-eclipse-store-benchmark/pom.xml index 0f87fd78..d9d912b3 100644 --- a/spring-data-eclipse-store-benchmark/pom.xml +++ b/spring-data-eclipse-store-benchmark/pom.xml @@ -20,7 +20,7 @@ UTF-8 UTF-8 - 3.2.2 + 3.2.3 1.37 @@ -96,7 +96,7 @@ com.puppycrawl.tools checkstyle - 10.13.0 + 10.14.0 diff --git a/spring-data-eclipse-store-demo/pom.xml b/spring-data-eclipse-store-demo/pom.xml index fb8cb27b..770cdf8f 100644 --- a/spring-data-eclipse-store-demo/pom.xml +++ b/spring-data-eclipse-store-demo/pom.xml @@ -25,7 +25,7 @@ software.xdev.spring.data.eclipse.store.demo.complex.ComplexDemoApplication - 3.2.2 + 3.2.3 @@ -103,7 +103,7 @@ com.puppycrawl.tools checkstyle - 10.13.0 + 10.14.0 diff --git a/spring-data-eclipse-store-jpa/pom.xml b/spring-data-eclipse-store-jpa/pom.xml index 7f520573..17644c8e 100644 --- a/spring-data-eclipse-store-jpa/pom.xml +++ b/spring-data-eclipse-store-jpa/pom.xml @@ -25,7 +25,7 @@ software.xdev.spring.data.eclipse.store.demo.complex.ComplexDemoApplication - 3.2.2 + 3.2.3 @@ -123,7 +123,7 @@ com.puppycrawl.tools checkstyle - 10.12.7 + 10.14.0 diff --git a/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/DefaultTestAnnotations.java b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/DefaultTestAnnotations.java similarity index 89% rename from spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/DefaultTestAnnotations.java rename to spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/DefaultTestAnnotations.java index c2f5158a..2ab31c92 100644 --- a/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/DefaultTestAnnotations.java +++ b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/DefaultTestAnnotations.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.jpa; +package software.xdev.spring.data.eclipse.store.jpa.integration; import static org.springframework.test.annotation.DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD; @@ -28,8 +28,6 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit.jupiter.SpringExtension; -import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories; - @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @@ -37,7 +35,6 @@ @ContextConfiguration(classes = {TestConfiguration.class}) @DirtiesContext(classMode = BEFORE_EACH_TEST_METHOD) @TestPropertySource("/application.properties") -@EnableEclipseStoreRepositories public @interface DefaultTestAnnotations { } diff --git a/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/IntegrationTest.java b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/IntegrationTest.java index fca98c97..3a8f91d0 100644 --- a/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/IntegrationTest.java +++ b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/IntegrationTest.java @@ -22,16 +22,29 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import software.xdev.spring.data.eclipse.store.jpa.DefaultTestAnnotations; -import software.xdev.spring.data.eclipse.store.jpa.integration.repository.PersonToTest; -import software.xdev.spring.data.eclipse.store.jpa.integration.repository.PersonToTestRepository; +import software.xdev.spring.data.eclipse.store.importer.EclipseStoreDataImporterComponent; +import software.xdev.spring.data.eclipse.store.jpa.integration.repository.PersonToTestInEclipseStore; +import software.xdev.spring.data.eclipse.store.jpa.integration.repository.PersonToTestInEclipseStoreRepository; +import software.xdev.spring.data.eclipse.store.jpa.integration.repository.PersonToTestInJpa; +import software.xdev.spring.data.eclipse.store.jpa.integration.repository.PersonToTestInJpaRepository; +import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage; +import software.xdev.spring.data.eclipse.store.repository.support.SimpleEclipseStoreRepository; @DefaultTestAnnotations -public class IntegrationTest +class IntegrationTest { @Autowired - private PersonToTestRepository personToTestRepository; + private PersonToTestInEclipseStoreRepository personToTestInEclipseStoreRepository; + + @Autowired + private PersonToTestInJpaRepository personToTestInJpaRepository; + + @Autowired + private EclipseStoreDataImporterComponent eclipseStoreDataImporter; + + @Autowired + private EclipseStoreStorage eclipseStoreStorage; /** * Super simple test if there are any start-up errors when running parallel to a JPA configuration @@ -39,11 +52,40 @@ public class IntegrationTest @Test void testBasicSaveAndFindSingleRecords() { - final PersonToTest customer = new PersonToTest("", ""); - this.personToTestRepository.save(customer); + final PersonToTestInEclipseStore customer = new PersonToTestInEclipseStore("", ""); + this.personToTestInEclipseStoreRepository.save(customer); - final List customers = this.personToTestRepository.findAll(); + final List customers = this.personToTestInEclipseStoreRepository.findAll(); Assertions.assertEquals(1, customers.size()); Assertions.assertEquals(customer, customers.get(0)); } + + @Test + void testEclipseStoreImport() + { + final PersonToTestInJpa customer = new PersonToTestInJpa("1", "", ""); + this.personToTestInJpaRepository.save(customer); + + final List> simpleEclipseStoreRepositories = + this.eclipseStoreDataImporter.importData(); + Assertions.assertEquals(1, simpleEclipseStoreRepositories.size()); + final List allEntities = simpleEclipseStoreRepositories.get(0).findAll(); + Assertions.assertEquals(1, allEntities.size()); + + this.eclipseStoreStorage.stop(); + Assertions.assertEquals( + 1, + this.eclipseStoreStorage.getEntityCount(PersonToTestInJpa.class), + "After restart the imported entities are not there anymore."); + } + + @Test + void testEclipseStoreEmptyImport() + { + final List> simpleEclipseStoreRepositories = + this.eclipseStoreDataImporter.importData(); + Assertions.assertEquals(1, simpleEclipseStoreRepositories.size()); + final List allEntities = simpleEclipseStoreRepositories.get(0).findAll(); + Assertions.assertEquals(0, allEntities.size()); + } } diff --git a/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/TestConfiguration.java b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/TestConfiguration.java similarity index 83% rename from spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/TestConfiguration.java rename to spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/TestConfiguration.java index 002eb1fb..bb73884f 100644 --- a/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/TestConfiguration.java +++ b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/TestConfiguration.java @@ -13,13 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package software.xdev.spring.data.eclipse.store.jpa; +package software.xdev.spring.data.eclipse.store.jpa.integration; import java.nio.file.Path; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.context.event.EventListener; @@ -28,8 +31,12 @@ import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage; import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories; + @Configuration +@ComponentScan("software.xdev.spring.data.eclipse.store.importer") @EnableEclipseStoreRepositories +@SpringBootConfiguration +@EnableAutoConfiguration public class TestConfiguration implements DisposableBean { @Autowired diff --git a/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/repository/PersonToTest.java b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/repository/PersonToTestInEclipseStore.java similarity index 79% rename from spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/repository/PersonToTest.java rename to spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/repository/PersonToTestInEclipseStore.java index 652e91c2..f57f21e2 100644 --- a/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/repository/PersonToTest.java +++ b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/repository/PersonToTestInEclipseStore.java @@ -5,7 +5,7 @@ import org.springframework.data.annotation.Id; -public class PersonToTest +public class PersonToTestInEclipseStore { @Id private String id; @@ -13,7 +13,7 @@ public class PersonToTest private final String firstName; private final String lastName; - public PersonToTest(final String firstName, final String lastName) + public PersonToTestInEclipseStore(final String firstName, final String lastName) { this.firstName = firstName; this.lastName = lastName; @@ -30,7 +30,7 @@ public boolean equals(final Object o) { return false; } - final PersonToTest customer = (PersonToTest)o; + final PersonToTestInEclipseStore customer = (PersonToTestInEclipseStore)o; return Objects.equals(this.id, customer.id) && Objects.equals(this.firstName, customer.firstName) && Objects.equals(this.lastName, customer.lastName); } diff --git a/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/repository/PersonToTestRepository.java b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/repository/PersonToTestInEclipseStoreRepository.java similarity index 58% rename from spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/repository/PersonToTestRepository.java rename to spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/repository/PersonToTestInEclipseStoreRepository.java index 4f3ff7e8..1f2b5418 100644 --- a/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/repository/PersonToTestRepository.java +++ b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/repository/PersonToTestInEclipseStoreRepository.java @@ -3,6 +3,6 @@ import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreListCrudRepository; -public interface PersonToTestRepository extends EclipseStoreListCrudRepository +public interface PersonToTestInEclipseStoreRepository extends EclipseStoreListCrudRepository { } diff --git a/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/repository/PersonToTestInJpa.java b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/repository/PersonToTestInJpa.java new file mode 100644 index 00000000..a8c0fee4 --- /dev/null +++ b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/repository/PersonToTestInJpa.java @@ -0,0 +1,51 @@ +package software.xdev.spring.data.eclipse.store.jpa.integration.repository; + +import java.util.Objects; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; + + +@Entity +public class PersonToTestInJpa +{ + @Id + private String id; + + private String firstName; + private String lastName; + + public PersonToTestInJpa(final String id, final String firstName, final String lastName) + { + this.id = id; + this.firstName = firstName; + this.lastName = lastName; + } + + public PersonToTestInJpa() + { + + } + + @Override + public boolean equals(final Object o) + { + if(this == o) + { + return true; + } + if(o == null || this.getClass() != o.getClass()) + { + return false; + } + final PersonToTestInJpa customer = (PersonToTestInJpa)o; + return Objects.equals(this.id, customer.id) && Objects.equals(this.firstName, customer.firstName) + && Objects.equals(this.lastName, customer.lastName); + } + + @Override + public int hashCode() + { + return Objects.hash(this.id, this.firstName, this.lastName); + } +} diff --git a/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/repository/PersonToTestInJpaRepository.java b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/repository/PersonToTestInJpaRepository.java new file mode 100644 index 00000000..a9072413 --- /dev/null +++ b/spring-data-eclipse-store-jpa/src/test/java/software/xdev/spring/data/eclipse/store/jpa/integration/repository/PersonToTestInJpaRepository.java @@ -0,0 +1,8 @@ +package software.xdev.spring.data.eclipse.store.jpa.integration.repository; + +import org.springframework.data.jpa.repository.JpaRepository; + + +public interface PersonToTestInJpaRepository extends JpaRepository +{ +} diff --git a/spring-data-eclipse-store/pom.xml b/spring-data-eclipse-store/pom.xml index c76a5ac2..09d66c48 100644 --- a/spring-data-eclipse-store/pom.xml +++ b/spring-data-eclipse-store/pom.xml @@ -50,8 +50,8 @@ UTF-8 - 3.2.2 - 1.1.0 + 3.2.3 + 1.2.0 @@ -258,6 +258,11 @@ --add-opens java.base/java.util=ALL-UNNAMED + --add-opens java.base/java.math=ALL-UNNAMED + --add-opens java.base/java.time=ALL-UNNAMED + --add-opens java.base/java.time.zone=ALL-UNNAMED + --add-opens java.base/java.util.concurrent=ALL-UNNAMED + --add-opens java.base/sun.util.calendar=ALL-UNNAMED --add-exports java.base/jdk.internal.misc=ALL-UNNAMED @@ -334,7 +339,7 @@ com.puppycrawl.tools checkstyle - 10.13.0 + 10.14.0 diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/exceptions/DataTypeNotSupportedException.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/exceptions/DataTypeNotSupportedException.java new file mode 100644 index 00000000..c6184649 --- /dev/null +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/exceptions/DataTypeNotSupportedException.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.exceptions; + +import software.xdev.spring.data.eclipse.store.util.StringUtil; + + +public class DataTypeNotSupportedException extends RuntimeException +{ + public DataTypeNotSupportedException(final String message) + { + super(message); + } + + public DataTypeNotSupportedException(final Class clazz) + { + this( + String.format( + "Datatype %s is not supported right now. Please open a ticket at %s if you feel that this type should " + + "be supported.", + clazz.getSimpleName(), + StringUtil.REPOSITORY_URL + ) + ); + } +} diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/importer/EclipseStoreDataImporter.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/importer/EclipseStoreDataImporter.java new file mode 100644 index 00000000..d5256f34 --- /dev/null +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/importer/EclipseStoreDataImporter.java @@ -0,0 +1,221 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.importer; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; + +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.metamodel.EntityType; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage; +import software.xdev.spring.data.eclipse.store.repository.SupportedChecker; +import software.xdev.spring.data.eclipse.store.repository.support.SimpleEclipseStoreRepository; +import software.xdev.spring.data.eclipse.store.repository.support.copier.working.RecursiveWorkingCopier; + + +/** + * Imports entities from {@link EntityManagerFactory}s into the EclipseStore storage. + */ +public class EclipseStoreDataImporter +{ + private static final Logger LOG = LoggerFactory.getLogger(EclipseStoreDataImporter.class); + private final EclipseStoreStorage eclipseStoreStorage; + + public EclipseStoreDataImporter(final EclipseStoreStorage eclipseStoreStorage) + { + this.eclipseStoreStorage = eclipseStoreStorage; + } + + /** + * Imports entities from all given {@link EntityManagerFactory}s that are available into the EclipseStore storage. + *

+ * This should be done only once. Otherwise entities may be imported multiple times. + *

+ *

+ * After importing all the entities, the existing repositories should be converted to + * {@link software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository}. + *

+ * + * @param entityManagerFactories which are searched for entities + * @return all the newly created {@link SimpleEclipseStoreRepository} for the specific entities. + */ + @SuppressWarnings("java:S1452") + public List> importData(final EntityManagerFactory... entityManagerFactories) + { + return this.importData(Arrays.stream(entityManagerFactories)); + } + + /** + * Imports entities from all given {@link EntityManagerFactory}s that are available into the EclipseStore storage. + *

+ * This should be done only once. Otherwise entities may be imported multiple times. + *

+ *

+ * After importing all the entities, the existing repositories should be converted to + * {@link software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository}. + *

+ * + * @param entityManagerFactories which are searched for entities + * + * @return all the newly created {@link SimpleEclipseStoreRepository} for the specific entities. + */ + @SuppressWarnings("java:S1452") + public List> importData( + final Iterable entityManagerFactories + ) + { + return this.importData(StreamSupport.stream(entityManagerFactories.spliterator(), false)); + } + + /** + * Imports entities from all given {@link EntityManagerFactory}s that are available into the EclipseStore storage. + *

+ * This should be done only once. Otherwise entities may be imported multiple times. + *

+ *

+ * After importing all the entities, the existing repositories should be converted to + * {@link software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository}. + *

+ * + * @param entityManagerFactories which are searched for entities + * + * @return all the newly created {@link SimpleEclipseStoreRepository} for the specific entities. + */ + @SuppressWarnings({"java:S1452", "java:S6204"}) + public List> importData( + final Stream entityManagerFactories + ) + { + LOG.info("Start importing data from JPA Repositories to EclipseStore..."); + + // First create all repositories to register them in the EclipseStoreStorage + final List allRepositories = + entityManagerFactories + .map(this::createEclipseStoreRepositoriesFromEntityManager) + .toList(); + LOG.info("Found {} repositories to export data from.", allRepositories.size()); + + // Now copy the data + allRepositories.forEach( + entityManagerFactoryRepositoryListPair -> + entityManagerFactoryRepositoryListPair + .classRepositoryPairs + .forEach( + classRepositoryPair -> + this.copyData(entityManagerFactoryRepositoryListPair, classRepositoryPair) + ) + ); + LOG.info("Done importing data from JPA Repositories to EclipseStore."); + + return allRepositories + .stream() + .map(EntityManagerFactoryRepositoryListPair::classRepositoryPairs) + .flatMap(List::stream) + .map(ClassRepositoryPair::repository) + .collect(Collectors.toList()); + } + + private void copyData( + final EntityManagerFactoryRepositoryListPair entityManagerFactoryRepositoryListPair, + final ClassRepositoryPair classRepositoryPair) + { + final String className = classRepositoryPair.domainClass.getName(); + + LOG.info("Loading entities of {}...", className); + try(final EntityManager entityManager = + entityManagerFactoryRepositoryListPair.entityManagerFactory.createEntityManager()) + { + final List existingEntitiesToExport = + entityManager + .createQuery( + "SELECT c FROM " + className + " c", + classRepositoryPair.domainClass + ) + .getResultList(); + + LOG.info( + "Loaded {} entities of type {} to export.", + existingEntitiesToExport.size(), + className + ); + + LOG.info( + "Saving {} entities of type {} to the EclipseStore Repository...", + existingEntitiesToExport.size(), + className + ); + classRepositoryPair.repository.saveAll(existingEntitiesToExport); + LOG.info( + "Done saving entities of type {}. The EclipseStore now holds {} entities of that type.", + className, + classRepositoryPair.repository.count() + ); + } + } + + private EntityManagerFactoryRepositoryListPair createEclipseStoreRepositoriesFromEntityManager( + final EntityManagerFactory entityManagerFactory) + { + final List> repositoryList = new ArrayList<>(); + entityManagerFactory.getMetamodel().getEntities().forEach( + entityType -> this.createRepositoryForType(entityType, repositoryList) + ); + + return new EntityManagerFactoryRepositoryListPair(entityManagerFactory, repositoryList); + } + + private void createRepositoryForType( + final EntityType entityType, + final List> repositoryList) + { + final Class javaType = entityType.getJavaType(); + repositoryList.add(new ClassRepositoryPair<>(javaType, this.createEclipseStoreRepo(javaType))); + } + + private SimpleEclipseStoreRepository createEclipseStoreRepo(final Class domainClass) + { + return new SimpleEclipseStoreRepository<>( + this.eclipseStoreStorage, + new RecursiveWorkingCopier<>( + domainClass, + this.eclipseStoreStorage.getRegistry(), + this.eclipseStoreStorage, + this.eclipseStoreStorage, + new SupportedChecker.Implementation()), + domainClass); + } + + private record EntityManagerFactoryRepositoryListPair( + EntityManagerFactory entityManagerFactory, + List> classRepositoryPairs + ) + { + } + + + private record ClassRepositoryPair(Class domainClass, SimpleEclipseStoreRepository repository) + { + } +} diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/importer/EclipseStoreDataImporterComponent.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/importer/EclipseStoreDataImporterComponent.java new file mode 100644 index 00000000..adf1b878 --- /dev/null +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/importer/EclipseStoreDataImporterComponent.java @@ -0,0 +1,65 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.importer; + +import java.util.List; +import java.util.Map; + +import jakarta.persistence.EntityManagerFactory; + +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Component; + +import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage; +import software.xdev.spring.data.eclipse.store.repository.support.SimpleEclipseStoreRepository; + + +/** + * Imports entities from {@link EntityManagerFactory}s into the EclipseStore storage. + */ +@Component +public class EclipseStoreDataImporterComponent +{ + private final EclipseStoreDataImporter importer; + private final ApplicationContext applicationContext; + + public EclipseStoreDataImporterComponent( + final EclipseStoreStorage eclipseStoreStorage, + final ApplicationContext applicationContext) + { + this.importer = new EclipseStoreDataImporter(eclipseStoreStorage); + this.applicationContext = applicationContext; + } + + /** + * Imports entities from all {@link EntityManagerFactory}s that are available into the EclipseStore storage. + *

+ * This should be done only once. Otherwise entities may be imported multiple times. + *

+ *

+ * After importing all the entities, the existing repositories should be converted to + * {@link software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository}. + *

+ * + * @return all the newly created {@link SimpleEclipseStoreRepository} for the specific entities. + */ + public List> importData() + { + final Map beansOfEms = + this.applicationContext.getBeansOfType(EntityManagerFactory.class); + return this.importer.importData(beansOfEms.values()); + } +} diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java index 0bd12465..da2c3312 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java @@ -32,7 +32,6 @@ import org.eclipse.store.storage.types.StorageManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import software.xdev.spring.data.eclipse.store.core.IdentitySet; @@ -60,7 +59,6 @@ public class EclipseStoreStorage private final WorkingCopyRegistry registry = new WorkingCopyRegistry(); private RepositorySynchronizer repositorySynchronizer; - @Autowired public EclipseStoreStorage( final EclipseStoreProperties storeConfiguration, final EclipseStoreProvider storeProvider) @@ -138,6 +136,13 @@ public synchronized void registerEntity(final Class classToRegister) throw new AlreadyRegisteredException(entityName); } this.entityClassToRepositoryName.put(classToRegister, entityName); + + // If the storage is running and a new entity is registered, we need to stop the storage to restart + // again with the registered entity. + if(this.storageManager != null) + { + this.stop(); + } } private String getEntityName(final Class classToRegister) @@ -153,11 +158,21 @@ public synchronized IdentitySet getEntityList(final Class clazz) return (IdentitySet)this.root.getEntityLists().get(this.getEntityName(clazz)); } + @SuppressWarnings("unchecked") + @Override + public synchronized long getEntityCount(final Class clazz) + { + this.ensureEntitiesInRoot(); + final IdentitySet entityList = (IdentitySet)this.root.getEntityLists().get(this.getEntityName(clazz)); + return entityList == null ? 0 : entityList.size(); + } + public synchronized void store( final Collection nonEntitiesToStore, final Class clazz, final Iterable entitiesToStore) { + this.ensureEntitiesInRoot(); final Collection entitiesAndPossiblyNonEntitiesToStore = this.collectRootEntitiesToStore(clazz, entitiesToStore); entitiesAndPossiblyNonEntitiesToStore.addAll(nonEntitiesToStore); @@ -205,6 +220,7 @@ private Collection collectRootEntitiesToStore(final Class clazz, public synchronized void delete(final Class clazz, final T objectToRemove) { + this.ensureEntitiesInRoot(); final List> entityLists = this.entitySetCollector.getRelatedIdentitySets(clazz); entityLists.forEach(entityList -> @@ -239,6 +255,7 @@ public synchronized void deleteAll(final Class clazz) public synchronized void clearData() { + this.ensureEntitiesInRoot(); this.root = new Root(); final StorageManager instanceOfstorageManager = this.getInstanceOfStorageManager(); this.initRoot(); @@ -273,6 +290,7 @@ public synchronized void stop() @SuppressWarnings("unchecked") public IdSetter ensureIdSetter(final Class domainClass) { + this.ensureEntitiesInRoot(); return (IdSetter)this.entityClassToIdSetter.computeIfAbsent( domainClass, clazz -> diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EntityListProvider.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EntityListProvider.java index ef1edfd3..1be8b552 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EntityListProvider.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EntityListProvider.java @@ -21,4 +21,6 @@ public interface EntityListProvider { IdentitySet getEntityList(final Class clazz); + + long getEntityCount(final Class clazz); } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/PersistableChecker.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/PersistableChecker.java index c243618f..b342a204 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/PersistableChecker.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/PersistableChecker.java @@ -15,8 +15,16 @@ */ package software.xdev.spring.data.eclipse.store.repository; +/** + * Checks if a class is persistable by EclipseStore through the + * {@link org.eclipse.store.storage.embedded.types.EmbeddedStorage}. + */ @FunctionalInterface public interface PersistableChecker { + /** + * Checks if a class is persistable by EclipseStore through the + * {@link org.eclipse.store.storage.embedded.types.EmbeddedStorage}. + */ boolean isPersistable(Class clazz); } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/SupportedChecker.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/SupportedChecker.java new file mode 100644 index 00000000..9d9cfc7b --- /dev/null +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/SupportedChecker.java @@ -0,0 +1,71 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.repository; + +import java.util.Calendar; +import java.util.EnumMap; +import java.util.List; +import java.util.WeakHashMap; + +import org.eclipse.serializer.reference.Lazy; + + +/** + * Checks if a class is supported by the Spring-Data-Eclipse-Store library. + *

+ * Some classes are not supported, because Eclipse Store doesn't support them. + *

+ *

+ * {@link Lazy} is not supported, because a lot of hidden stuff must be done to keep Lazy-References really Lazy when + * creating a working copy. + *

+ */ +@FunctionalInterface +public interface SupportedChecker +{ + /** + * Checks if a class is supported by the Spring-Data-Eclipse-Store library. + *

+ * Some classes are not supported, because Eclipse Store doesn't support them. + *

+ *

+ * {@link Lazy} is not supported, because a lot of hidden stuff must be done to keep Lazy-References really Lazy + * when creating a working copy. + *

+ */ + boolean isSupported(Class clazz); + + class Implementation implements SupportedChecker + { + private static final List> UNSUPPORTED_DATA_TYPES = List.of( + // Is difficult to handle when creating working copies + Lazy.class, + // Here EclipseStore has problems: https://github.com/microstream-one/microstream/issues/173 + Calendar.class, + WeakHashMap.class, + // Here EclipseStore has problems too: https://github.com/microstream-one/microstream/issues/204 + EnumMap.class + ); + + @Override + public boolean isSupported(final Class clazz) + { + return !UNSUPPORTED_DATA_TYPES.stream().anyMatch( + unsupportedClazz -> unsupportedClazz.isAssignableFrom(clazz) + ); + } + } +} diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EnableEclipseStoreRepositories.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EnableEclipseStoreRepositories.java index 4df9335d..c200a994 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EnableEclipseStoreRepositories.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EnableEclipseStoreRepositories.java @@ -43,6 +43,7 @@ @Inherited @Import(EclipseStoreRepositoriesRegistrar.class) @ComponentScan({ + "software.xdev.spring.data.eclipse.store.importer", "software.xdev.spring.data.eclipse.store.repository", "org.eclipse.store.integrations.spring.boot.types"}) public @interface EnableEclipseStoreRepositories diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java index e8469e04..2f42894f 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/EclipseStoreRepositoryFactory.java @@ -32,6 +32,7 @@ import org.springframework.lang.Nullable; import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage; +import software.xdev.spring.data.eclipse.store.repository.SupportedChecker; import software.xdev.spring.data.eclipse.store.repository.support.copier.working.RecursiveWorkingCopier; import software.xdev.spring.data.eclipse.store.repository.support.copier.working.WorkingCopier; @@ -80,7 +81,13 @@ private WorkingCopier createWorkingCopier( final Class domainType, final EclipseStoreStorage storage) { - return new RecursiveWorkingCopier<>(domainType, storage.getRegistry(), storage, storage); + return new RecursiveWorkingCopier<>( + domainType, + storage.getRegistry(), + storage, + storage, + new SupportedChecker.Implementation() + ); } @Override diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java index 0752c852..b366c873 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java @@ -227,7 +227,7 @@ public List findAllById(@Nonnull final Iterable ids) @Override public long count() { - return this.storage.getEntityList(this.domainClass).size(); + return this.storage.getEntityCount(this.domainClass); } @Override diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/object/EclipseSerializerRegisteringCopier.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/object/EclipseSerializerRegisteringCopier.java index 76b98338..00f6f8e5 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/object/EclipseSerializerRegisteringCopier.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/object/EclipseSerializerRegisteringCopier.java @@ -32,6 +32,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import software.xdev.spring.data.eclipse.store.exceptions.DataTypeNotSupportedException; +import software.xdev.spring.data.eclipse.store.repository.SupportedChecker; import software.xdev.spring.data.eclipse.store.repository.WorkingCopyRegistry; import software.xdev.spring.data.eclipse.store.repository.support.copier.DataTypeUtil; @@ -45,16 +47,20 @@ public class EclipseSerializerRegisteringCopier implements RegisteringObjectCopi private static final Logger LOG = LoggerFactory.getLogger(EclipseSerializerRegisteringCopier.class); private final SerializerFoundation foundation; private PersistenceManager persistenceManager; + private final SupportedChecker supportedChecker; private final WorkingCopyRegistry registry; - public EclipseSerializerRegisteringCopier(final WorkingCopyRegistry registry) + public EclipseSerializerRegisteringCopier( + final WorkingCopyRegistry registry, + final SupportedChecker supportedChecker) { final SerializerFoundation newFoundation = SerializerFoundation.New(); newFoundation.registerCustomTypeHandler(BinaryHandlerImmutableCollectionsSet12.New()); newFoundation.registerCustomTypeHandler(BinaryHandlerImmutableCollectionsList12.New()); this.foundation = newFoundation; this.registry = registry; + this.supportedChecker = supportedChecker; } @Override @@ -105,8 +111,8 @@ private void lazyInit() * A storer is created. Then a loader. By then calling {@link PersistenceStorer#store(Object)} the source-object is * serialized in memory. Then the created objects are put in a Map which holds the EclipseStore-ObjectId and all * the - * serialized objects. By calling {@link PersistenceLoader#get()} the serilized objects are deserialized. Then we - * iterate over the deserlized objects and pair them with the corresponding source-objects through the + * serialized objects. By calling {@link PersistenceLoader#get()} the serialized objects are deserialized. Then we + * iterate over the deserialized objects and pair them with the corresponding source-objects through the * EclipseStore-ObjectId. *

*/ @@ -134,6 +140,10 @@ public synchronized T copy(final T source, final boolean invertRegistering) loader.iterateEntries( (id, copiedObject) -> { + if(copiedObject != null && !this.supportedChecker.isSupported(copiedObject.getClass())) + { + throw new DataTypeNotSupportedException(copiedObject.getClass()); + } summarizer.incrementCopiedObjectsCount(); if(DataTypeUtil.isPrimitiveType(copiedObject.getClass())) { @@ -142,7 +152,7 @@ public synchronized T copy(final T source, final boolean invertRegistering) final Object originalObject = originalObjects.get(id); if(originalObject != null) { - summarizer.incrementRegisteredObjectsCountt(); + summarizer.incrementRegisteredObjectsCount(); if(invertRegistering) { this.registry.invertRegister(copiedObject, originalObject); @@ -182,7 +192,7 @@ public void incrementCopiedObjectsCount() this.copiedObjectsCount += 1; } - public void incrementRegisteredObjectsCountt() + public void incrementRegisteredObjectsCount() { this.registeredObjectsCount += 1; } diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/RecursiveWorkingCopier.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/RecursiveWorkingCopier.java index 7aec5d35..a781da27 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/RecursiveWorkingCopier.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/working/RecursiveWorkingCopier.java @@ -19,7 +19,13 @@ import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.Collection; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.IdentityHashMap; +import java.util.LinkedHashMap; import java.util.Objects; +import java.util.TreeMap; +import java.util.TreeSet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,6 +33,7 @@ import software.xdev.spring.data.eclipse.store.exceptions.MergeFailedException; import software.xdev.spring.data.eclipse.store.repository.IdSetterProvider; import software.xdev.spring.data.eclipse.store.repository.PersistableChecker; +import software.xdev.spring.data.eclipse.store.repository.SupportedChecker; import software.xdev.spring.data.eclipse.store.repository.WorkingCopyRegistry; import software.xdev.spring.data.eclipse.store.repository.access.AccessHelper; import software.xdev.spring.data.eclipse.store.repository.access.modifier.FieldAccessModifier; @@ -51,11 +58,12 @@ public RecursiveWorkingCopier( final Class domainClass, final WorkingCopyRegistry registry, final IdSetterProvider idSetterProvider, - final PersistableChecker persistableChecker) + final PersistableChecker persistableChecker, + final SupportedChecker supportedChecker) { this.domainClass = domainClass; this.registry = registry; - this.objectCopier = new EclipseSerializerRegisteringCopier(registry); + this.objectCopier = new EclipseSerializerRegisteringCopier(registry, supportedChecker); this.idSetterProvider = idSetterProvider; this.persistableChecker = persistableChecker; } @@ -160,17 +168,24 @@ private void mergeValues( // alreadyMergedTargets prevent endless loops return; } - alreadyMergedTargets.collectMergedTarget(targetObject); - - if(sourceObject instanceof String) + try { - // no merge needed and no merge possible - return; + alreadyMergedTargets.collectMergedTarget(targetObject); + + if(sourceObject instanceof String) + { + // no merge needed and no merge possible + return; + } + AccessHelper.getInheritedPrivateFieldsByName(sourceObject.getClass()).values().forEach( + field -> + this.mergeValueOfField(sourceObject, targetObject, field, alreadyMergedTargets, changedCollector) + ); + } + catch(final Exception e) + { + throw new MergeFailedException(sourceObject, targetObject, e); } - AccessHelper.getInheritedPrivateFieldsByName(sourceObject.getClass()).values().forEach( - field -> - this.mergeValueOfField(sourceObject, targetObject, field, alreadyMergedTargets, changedCollector) - ); } private void mergeValueOfField( @@ -246,12 +261,23 @@ else if(DataTypeUtil.isObjectArray(valueOfSourceObject)) originalValueObjectOfSource, !targetObjectIsPartOfJavaPackage); } - // Merge after setting reference to avoid endless loops - this.mergeValues( - valueOfSourceObject, - originalValueObjectOfSource, - alreadyMergedTargets, - changedCollector); + + if(this.isSpecialCaseWhereOnlyAFullCopyWorks(valueOfSourceObject)) + { + fam.writeValueOfField( + targetObject, + this.onlyCreateCopy(valueOfSourceObject, true), + !targetObjectIsPartOfJavaPackage); + } + else + { + // Merge after setting reference to avoid endless loops + this.mergeValues( + valueOfSourceObject, + originalValueObjectOfSource, + alreadyMergedTargets, + changedCollector); + } } } } @@ -262,6 +288,24 @@ else if(DataTypeUtil.isObjectArray(valueOfSourceObject)) } } + /** + * Super special case for HashMap or similar java-classes which can't be merged nicely. Thus, we make a simple copy + * of the whole object. + */ + private boolean isSpecialCaseWhereOnlyAFullCopyWorks(final Object valueOfSourceObject) + { + return + valueOfSourceObject != null + && ( + valueOfSourceObject.getClass().isAssignableFrom(HashMap.class) + || valueOfSourceObject.getClass().isAssignableFrom(LinkedHashMap.class) + || valueOfSourceObject.getClass().isAssignableFrom(Hashtable.class) + || valueOfSourceObject.getClass().isAssignableFrom(TreeSet.class) + || valueOfSourceObject.getClass().isAssignableFrom(TreeMap.class) + || valueOfSourceObject.getClass().isAssignableFrom(IdentityHashMap.class) + ); + } + @SuppressWarnings("unchecked") private E[] createGenericObjectArray( final Class clazz, diff --git a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/util/StringUtil.java b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/util/StringUtil.java index d79f240b..bcf1a600 100644 --- a/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/util/StringUtil.java +++ b/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/util/StringUtil.java @@ -22,6 +22,8 @@ public final class StringUtil { + public static final String REPOSITORY_URL = "https://github.com/xdev-software/spring-data-eclipse-store"; + private StringUtil() { } diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/IsolatedTestAnnotations.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/IsolatedTestAnnotations.java new file mode 100644 index 00000000..61d27ef1 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/IsolatedTestAnnotations.java @@ -0,0 +1,38 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests; + +import static org.springframework.test.annotation.DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; + + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@ExtendWith(SpringExtension.class) +@ContextConfiguration(classes = {IsolatedTestConfiguration.class}) +@DirtiesContext(classMode = BEFORE_EACH_TEST_METHOD) +public @interface IsolatedTestAnnotations +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/IsolatedTestConfiguration.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/IsolatedTestConfiguration.java new file mode 100644 index 00000000..a5be2ce0 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/IsolatedTestConfiguration.java @@ -0,0 +1,57 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests; + +import java.nio.file.Path; + +import org.springframework.beans.factory.DisposableBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.context.event.EventListener; +import org.springframework.util.FileSystemUtils; + +import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage; +import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories; + + +@Configuration +@EnableEclipseStoreRepositories +public class IsolatedTestConfiguration implements DisposableBean +{ + @Autowired + EclipseStoreStorage storage; + + @Value("${org.eclipse.store.storage-directory}") + private String storageDirectory; + + @EventListener + public void handleContextRefresh(final ContextRefreshedEvent event) + { + // Init with empty root object + this.storage.clearData(); + } + + @Override + public void destroy() throws Exception + { + // End with empty root object + this.storage.clearData(); + this.storage.stop(); + FileSystemUtils.deleteRecursively(Path.of(this.storageDirectory)); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/KeywordsTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/KeywordsTest.java new file mode 100644 index 00000000..61c012ca --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/KeywordsTest.java @@ -0,0 +1,58 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.keywords; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.TestPropertySource; + +import software.xdev.spring.data.eclipse.store.helper.TestUtil; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.IsolatedTestAnnotations; +import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage; + + +/** + * These tests should show that all or most of the following keywords are available in this library: Repository query + * keywords + */ +@IsolatedTestAnnotations +@TestPropertySource( + properties = + "org.eclipse.store.storage-directory=./target/keywords-tests-storage" +) +class KeywordsTest +{ + @Autowired + private EclipseStoreStorage storage; + + @Test + @Disabled("For now we don't need 'existsBy'") + void simpleStoreAndRead(final MinimalRepository repository) + { + repository.save(new MinimalDaoObject("1")); + + TestUtil.doBeforeAndAfterRestartOfDatastore( + this.storage, + () -> { + Assertions.assertTrue(repository.existsByValue("1")); + Assertions.assertFalse(repository.existsByValue("2")); + } + ); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/MinimalDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/MinimalDaoObject.java new file mode 100644 index 00000000..f306c867 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/MinimalDaoObject.java @@ -0,0 +1,54 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.keywords; + +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + + +public class MinimalDaoObject +{ + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + private String value; + + public MinimalDaoObject(final String value) + { + this.value = value; + } + + public int getId() + { + return this.id; + } + + public void setId(final int id) + { + this.id = id; + } + + public String getValue() + { + return this.value; + } + + public void setValue(final String value) + { + this.value = value; + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/MinimalRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/MinimalRepository.java new file mode 100644 index 00000000..c1db0a3f --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/MinimalRepository.java @@ -0,0 +1,26 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.keywords; + +import org.springframework.data.repository.Repository; + + +public interface MinimalRepository extends Repository +{ + MinimalDaoObject save(MinimalDaoObject entity); + + boolean existsByValue(String lastName); +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigDecimalDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigDecimalDaoObject.java new file mode 100644 index 00000000..52c42c58 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigDecimalDaoObject.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import java.math.BigDecimal; + + +public class BigDecimalDaoObject extends ComplexObject +{ + public BigDecimalDaoObject(final Integer id, final BigDecimal value) + { + super(id, value); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigDecimalRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigDecimalRepository.java new file mode 100644 index 00000000..f56eb4a8 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigDecimalRepository.java @@ -0,0 +1,23 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; + + +public interface BigDecimalRepository extends EclipseStoreRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigIntegerDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigIntegerDaoObject.java new file mode 100644 index 00000000..90dc44f1 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigIntegerDaoObject.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import java.math.BigInteger; + + +public class BigIntegerDaoObject extends ComplexObject +{ + public BigIntegerDaoObject(final Integer id, final BigInteger value) + { + super(id, value); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigIntegerRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigIntegerRepository.java new file mode 100644 index 00000000..74a8d364 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/BigIntegerRepository.java @@ -0,0 +1,23 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; + + +public interface BigIntegerRepository extends EclipseStoreRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/CalendarDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/CalendarDaoObject.java new file mode 100644 index 00000000..3b835475 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/CalendarDaoObject.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import java.util.Calendar; + + +public class CalendarDaoObject extends ComplexObject +{ + public CalendarDaoObject(final Integer id, final Calendar value) + { + super(id, value); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/CalendarRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/CalendarRepository.java new file mode 100644 index 00000000..187d33fb --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/CalendarRepository.java @@ -0,0 +1,23 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; + + +public interface CalendarRepository extends EclipseStoreRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ComplexObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ComplexObject.java new file mode 100644 index 00000000..5561bb6c --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ComplexObject.java @@ -0,0 +1,71 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import java.util.Objects; + +import jakarta.persistence.Id; + + +public class ComplexObject +{ + @Id + private final Integer id; + + private T value; + + public ComplexObject(final Integer id, final T value) + { + this.id = id; + this.value = value; + } + + public T getValue() + { + return this.value; + } + + public void setValue(final T value) + { + this.value = value; + } + + public Integer getId() + { + return this.id; + } + + @Override + public boolean equals(final Object o) + { + if(this == o) + { + return true; + } + if(o == null || this.getClass() != o.getClass()) + { + return false; + } + final ComplexObject that = (ComplexObject)o; + return Objects.equals(this.id, that.id) && Objects.equals(this.value, that.value); + } + + @Override + public int hashCode() + { + return Objects.hash(this.id, this.value); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/DateDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/DateDaoObject.java new file mode 100644 index 00000000..f93dfa12 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/DateDaoObject.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import java.util.Date; + + +public class DateDaoObject extends ComplexObject +{ + public DateDaoObject(final Integer id, final Date value) + { + super(id, value); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/DateRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/DateRepository.java new file mode 100644 index 00000000..f967c16f --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/DateRepository.java @@ -0,0 +1,23 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; + + +public interface DateRepository extends EclipseStoreRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumMapDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumMapDaoObject.java new file mode 100644 index 00000000..cd81c07c --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumMapDaoObject.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import java.util.EnumMap; + + +public class EnumMapDaoObject extends ComplexObject> +{ + public enum Album + { + RUMOURS, + TUSK + } + public EnumMapDaoObject(final Integer id, final EnumMap value) + { + super(id, value); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumMapRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumMapRepository.java new file mode 100644 index 00000000..4f49be48 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumMapRepository.java @@ -0,0 +1,23 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; + + +public interface EnumMapRepository extends EclipseStoreRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumSetDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumSetDaoObject.java new file mode 100644 index 00000000..31acf389 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumSetDaoObject.java @@ -0,0 +1,33 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import java.util.EnumSet; + + +public class EnumSetDaoObject extends ComplexObject> +{ + public enum Album + { + RUMOURS, + TUSK + } + + public EnumSetDaoObject(final Integer id, final EnumSet value) + { + super(id, value); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumSetRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumSetRepository.java new file mode 100644 index 00000000..f2f186b8 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/EnumSetRepository.java @@ -0,0 +1,23 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; + + +public interface EnumSetRepository extends EclipseStoreRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LazyDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LazyDaoObject.java new file mode 100644 index 00000000..41221a67 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LazyDaoObject.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import org.eclipse.serializer.reference.Lazy; + + +public class LazyDaoObject extends ComplexObject> +{ + public LazyDaoObject(final Integer id, final Lazy value) + { + super(id, value); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LazyRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LazyRepository.java new file mode 100644 index 00000000..a3cd5e37 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LazyRepository.java @@ -0,0 +1,23 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; + + +public interface LazyRepository extends EclipseStoreRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ListDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ListDaoObject.java new file mode 100644 index 00000000..f4cb80e7 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ListDaoObject.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import java.util.List; + + +public class ListDaoObject extends ComplexObject> +{ + public ListDaoObject(final Integer id, final List value) + { + super(id, value); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ListRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ListRepository.java new file mode 100644 index 00000000..b0351524 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/ListRepository.java @@ -0,0 +1,23 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; + + +public interface ListRepository extends EclipseStoreRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateDaoObject.java new file mode 100644 index 00000000..bf6cf781 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateDaoObject.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import java.time.LocalDate; + + +public class LocalDateDaoObject extends ComplexObject +{ + public LocalDateDaoObject(final Integer id, final LocalDate value) + { + super(id, value); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateRepository.java new file mode 100644 index 00000000..0aa50229 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateRepository.java @@ -0,0 +1,23 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; + + +public interface LocalDateRepository extends EclipseStoreRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateTimeDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateTimeDaoObject.java new file mode 100644 index 00000000..169ea937 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateTimeDaoObject.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import java.time.LocalDateTime; + + +public class LocalDateTimeDaoObject extends ComplexObject +{ + public LocalDateTimeDaoObject(final Integer id, final LocalDateTime value) + { + super(id, value); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateTimeRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateTimeRepository.java new file mode 100644 index 00000000..737c6ebf --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalDateTimeRepository.java @@ -0,0 +1,23 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; + + +public interface LocalDateTimeRepository extends EclipseStoreRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalTimeDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalTimeDaoObject.java new file mode 100644 index 00000000..953aeab5 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalTimeDaoObject.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import java.time.LocalTime; + + +public class LocalTimeDaoObject extends ComplexObject +{ + public LocalTimeDaoObject(final Integer id, final LocalTime value) + { + super(id, value); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalTimeRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalTimeRepository.java new file mode 100644 index 00000000..db1cac67 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/LocalTimeRepository.java @@ -0,0 +1,23 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; + + +public interface LocalTimeRepository extends EclipseStoreRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/MapDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/MapDaoObject.java new file mode 100644 index 00000000..372ec6b3 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/MapDaoObject.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import java.util.Map; + + +public class MapDaoObject extends ComplexObject> +{ + public MapDaoObject(final Integer id, final Map value) + { + super(id, value); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/MapRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/MapRepository.java new file mode 100644 index 00000000..ebbb1d18 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/MapRepository.java @@ -0,0 +1,23 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; + + +public interface MapRepository extends EclipseStoreRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/OptionalDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/OptionalDaoObject.java new file mode 100644 index 00000000..228abedc --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/OptionalDaoObject.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import java.util.Optional; + + +public class OptionalDaoObject extends ComplexObject> +{ + public OptionalDaoObject(final Integer id, final Optional value) + { + super(id, value); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/OptionalRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/OptionalRepository.java new file mode 100644 index 00000000..7868afc6 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/OptionalRepository.java @@ -0,0 +1,23 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; + + +public interface OptionalRepository extends EclipseStoreRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/SetDaoObject.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/SetDaoObject.java new file mode 100644 index 00000000..be214b09 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/SetDaoObject.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import java.util.Set; + + +public class SetDaoObject extends ComplexObject> +{ + public SetDaoObject(final Integer id, final Set value) + { + super(id, value); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/SetRepository.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/SetRepository.java new file mode 100644 index 00000000..e3ed468b --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/SetRepository.java @@ -0,0 +1,23 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; + + +public interface SetRepository extends EclipseStoreRepository +{ +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/TypesData.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/TypesData.java new file mode 100644 index 00000000..4429ddb6 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/TypesData.java @@ -0,0 +1,443 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collections; +import java.util.Date; +import java.util.EnumMap; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.IdentityHashMap; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.Stack; +import java.util.TreeMap; +import java.util.TreeSet; +import java.util.Vector; +import java.util.WeakHashMap; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.stream.Stream; + +import org.eclipse.serializer.reference.Lazy; +import org.junit.jupiter.params.provider.Arguments; + +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; + + +final class TypesData +{ + public record ListOfTestArguments(List> testArguments) + { + public Stream toArguments() + { + return this.testArguments.stream().map(TestArguments::toArguments); + } + } + + + public record TestArguments>( + Class> repositoryClass, + Function objectCreator, + Consumer objectChanger) + { + public Arguments toArguments() + { + return Arguments.of(this.repositoryClass, this.objectCreator, this.objectChanger); + } + } + + @SuppressWarnings("checkstyle:MethodLength") + public static Stream generateData() + { + // noinspection RedundantTypeArguments (explicit type arguments speedup compilation and analysis time) + return new ListOfTestArguments( + List.>of( + new TestArguments<>( + SetRepository.class, + id -> new SetDaoObject(id, Set.of()), + set -> set.setValue(Set.of("1")) + ), + new TestArguments<>( + SetRepository.class, + id -> new SetDaoObject(id, Set.of("1")), + set -> set.setValue(Set.of("1", "2")) + ), + new TestArguments<>( + SetRepository.class, + id -> new SetDaoObject(id, Set.of("1", "2")), + set -> set.setValue(Set.of("1", "2", "3")) + ), + new TestArguments<>( + SetRepository.class, + id -> new SetDaoObject(id, new HashSet<>()), + set -> set.getValue().add("1") + ), + new TestArguments<>( + SetRepository.class, + id -> new SetDaoObject(id, new HashSet<>(List.of("1"))), + set -> set.getValue().add("2") + ), + new TestArguments<>( + SetRepository.class, + id -> new SetDaoObject(id, new HashSet<>(List.of("1", "2"))), + set -> set.getValue().add("3") + ), + new TestArguments<>( + SetRepository.class, + id -> new SetDaoObject(id, new TreeSet<>()), + set -> set.getValue().add("1") + ), + new TestArguments<>( + SetRepository.class, + id -> new SetDaoObject(id, new TreeSet<>(List.of("1"))), + set -> set.getValue().add("2") + ), + new TestArguments<>( + SetRepository.class, + id -> new SetDaoObject(id, new TreeSet<>(List.of("1", "2"))), + set -> set.getValue().add("3") + ), + new TestArguments<>( + SetRepository.class, + id -> new SetDaoObject(id, new LinkedHashSet<>()), + set -> set.getValue().add("1") + ), + new TestArguments<>( + SetRepository.class, + id -> new SetDaoObject(id, new LinkedHashSet<>(List.of("1"))), + set -> set.getValue().add("2") + ), + new TestArguments<>( + SetRepository.class, + id -> new SetDaoObject(id, new LinkedHashSet<>(List.of("1", "2"))), + set -> set.getValue().add("3") + ), + new TestArguments<>( + BigDecimalRepository.class, + id -> new BigDecimalDaoObject(id, BigDecimal.ONE), + object -> object.setValue(object.getValue().add(BigDecimal.ONE)) + ), + new TestArguments<>( + BigDecimalRepository.class, + id -> new BigDecimalDaoObject(id, BigDecimal.ZERO), + object -> object.setValue(object.getValue().add(BigDecimal.ONE)) + ), + new TestArguments<>( + BigDecimalRepository.class, + id -> new BigDecimalDaoObject(id, null), + object -> object.setValue(BigDecimal.ONE) + ), + new TestArguments<>( + BigIntegerRepository.class, + id -> new BigIntegerDaoObject(id, BigInteger.ONE), + object -> object.setValue(object.getValue().add(BigInteger.ONE)) + ), + new TestArguments<>( + BigIntegerRepository.class, + id -> new BigIntegerDaoObject(id, BigInteger.ZERO), + object -> object.setValue(object.getValue().add(BigInteger.ONE)) + ), + new TestArguments<>( + BigIntegerRepository.class, + id -> new BigIntegerDaoObject(id, null), + object -> object.setValue(BigInteger.ONE) + ), + new TestArguments<>( + BigIntegerRepository.class, + id -> new BigIntegerDaoObject(id, BigInteger.ONE), + object -> object.setValue(null) + ), + new TestArguments<>( + DateRepository.class, + id -> new DateDaoObject(id, null), + object -> object.setValue(new Date(System.currentTimeMillis())) + ), + new TestArguments<>( + DateRepository.class, + id -> new DateDaoObject(id, new Date(System.currentTimeMillis())), + object -> object.getValue().setTime(System.currentTimeMillis() + 1) + ), + new TestArguments<>( + ListRepository.class, + id -> new ListDaoObject(id, List.of()), + object -> object.setValue(List.of("1")) + ), + new TestArguments<>( + ListRepository.class, + id -> new ListDaoObject(id, List.of("1")), + object -> object.setValue(List.of("1", "2")) + ), + new TestArguments<>( + ListRepository.class, + id -> new ListDaoObject(id, List.of("1", "2")), + object -> object.setValue(List.of("1", "2", "3")) + ), + new TestArguments<>( + ListRepository.class, + id -> new ListDaoObject(id, null), + object -> object.setValue(List.of("1")) + ), + new TestArguments<>( + ListRepository.class, + id -> new ListDaoObject(id, new ArrayList<>()), + object -> object.getValue().add("1") + ), + new TestArguments<>( + ListRepository.class, + id -> new ListDaoObject(id, new ArrayList<>(Set.of("1"))), + object -> object.getValue().add("2") + ), + new TestArguments<>( + ListRepository.class, + id -> new ListDaoObject(id, new ArrayList<>(Set.of("1", "2"))), + object -> object.getValue().add("3") + ), + new TestArguments<>( + ListRepository.class, + id -> new ListDaoObject(id, new Stack<>()), + object -> object.getValue().add("1") + ), + new TestArguments<>( + ListRepository.class, + id -> + { + final Stack stack = new Stack<>(); + stack.add("1"); + return new ListDaoObject(id, stack); + }, + object -> object.getValue().add("2") + ), + new TestArguments<>( + ListRepository.class, + id -> + { + final Stack stack = new Stack<>(); + stack.push("1"); + stack.push("2"); + return new ListDaoObject(id, stack); + }, + object -> object.getValue().add("3") + ), + new TestArguments<>( + ListRepository.class, + id -> new ListDaoObject(id, new ArrayList<>(Set.of("1"))), + object -> object.getValue().remove("1") + ), + new TestArguments<>( + ListRepository.class, + id -> new ListDaoObject(id, new Vector<>(Set.of("1"))), + object -> object.getValue().remove("1") + ), + new TestArguments<>( + ListRepository.class, + id -> new ListDaoObject(id, Collections.emptyList()), + object -> object.setValue(List.of("1")) + ), + new TestArguments<>( + LocalDateRepository.class, + id -> new LocalDateDaoObject(id, LocalDate.of(2000, 1, 1)), + object -> object.setValue(object.getValue().plusDays(1)) + ), + new TestArguments<>( + LocalDateTimeRepository.class, + id -> new LocalDateTimeDaoObject(id, LocalDateTime.of(2000, 1, 1, 1, 1, 1)), + object -> object.setValue(object.getValue().plusDays(1)) + ), + new TestArguments<>( + LocalTimeRepository.class, + id -> new LocalTimeDaoObject(id, LocalTime.of(1, 1, 1)), + object -> object.setValue(object.getValue().plusHours(1)) + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, Map.of()), + set -> set.setValue(Map.of("1", "1")) + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, Map.of("1", "1")), + set -> set.setValue(Map.of("1", "1", "2", "2")) + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, Map.of("1", "1", "2", "2")), + set -> set.setValue(Map.of("1", "1", "2", "2", "3", "3")) + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, new HashMap<>()), + set -> set.getValue().put("1", "1") + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, new HashMap<>(Map.of("1", "1"))), + set -> set.getValue().put("2", "2") + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, new HashMap<>(Map.of("1", "1", "2", "2"))), + set -> set.getValue().put("3", "3") + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, new LinkedHashMap<>()), + set -> set.getValue().put("1", "1") + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, new LinkedHashMap<>(Map.of("1", "1"))), + set -> set.getValue().put("2", "2") + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, new LinkedHashMap<>(Map.of("1", "1", "2", "2"))), + set -> set.getValue().put("3", "3") + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, new Hashtable<>()), + set -> set.getValue().put("1", "1") + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, new Hashtable<>(Map.of("1", "1"))), + set -> set.getValue().put("2", "2") + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, new Hashtable<>(Map.of("1", "1", "2", "2"))), + set -> set.getValue().put("3", "3") + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, new TreeMap<>()), + set -> set.getValue().put("1", "1") + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, new TreeMap<>(Map.of("1", "1"))), + set -> set.getValue().put("2", "2") + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, new TreeMap<>(Map.of("1", "1", "2", "2"))), + set -> set.getValue().put("3", "3") + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, new IdentityHashMap<>()), + set -> set.getValue().put("1", "1") + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, new IdentityHashMap<>(Map.of("1", "1"))), + set -> set.getValue().put("2", "2") + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, new IdentityHashMap<>(Map.of("1", "1", "2", "2"))), + set -> set.getValue().put("3", "3") + ), + new TestArguments<>( + OptionalRepository.class, + id -> new OptionalDaoObject(id, Optional.of("1")), + set -> set.setValue(Optional.of("2")) + ), + new TestArguments<>( + OptionalRepository.class, + id -> new OptionalDaoObject(id, Optional.empty()), + set -> set.setValue(Optional.of("1")) + ), + new TestArguments<>( + OptionalRepository.class, + id -> new OptionalDaoObject(id, null), + set -> set.setValue(Optional.of("1")) + ) + ) + ).toArguments(); + } + + /** + * Should be identical to + * {@link + * software.xdev.spring.data.eclipse.store.repository.SupportedChecker.Implementation#UNSUPPORTED_DATA_TYPES} + */ + public static Stream generateNotWorkingData() + { + return new ListOfTestArguments( + List.of( + new TestArguments<>( + LazyRepository.class, + id -> new LazyDaoObject(id, Lazy.Reference("1")), + object -> object.setValue(Lazy.Reference("2")) + ), + new TestArguments<>( + LazyRepository.class, + id -> new LazyDaoObject(id, Lazy.Reference("1")), + object -> object.getValue().clear() + ), + new TestArguments<>( + EnumMapRepository.class, + id -> new EnumMapDaoObject(id, new EnumMap<>(EnumMapDaoObject.Album.class)), + object -> object.getValue().put(EnumMapDaoObject.Album.RUMOURS, "1") + ), + new TestArguments<>( + EnumMapRepository.class, + id -> new EnumMapDaoObject(id, new EnumMap<>(Map.of(EnumMapDaoObject.Album.RUMOURS, "1"))), + object -> object.getValue().put(EnumMapDaoObject.Album.TUSK, "2") + ), + new TestArguments<>( + EnumMapRepository.class, + id -> new EnumMapDaoObject(id, new EnumMap<>(Map.of(EnumMapDaoObject.Album.RUMOURS, "1"))), + object -> object.getValue().remove(EnumMapDaoObject.Album.RUMOURS) + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, new WeakHashMap<>()), + set -> set.getValue().put("1", "1") + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, new WeakHashMap<>(Map.of("1", "1"))), + set -> set.getValue().put("2", "2") + ), + new TestArguments<>( + MapRepository.class, + id -> new MapDaoObject(id, new WeakHashMap<>(Map.of("1", "1", "2", "2"))), + set -> set.getValue().put("3", "3") + ), + new TestArguments<>( + CalendarRepository.class, + id -> new CalendarDaoObject(id, Calendar.getInstance()), + object -> object.getValue().add(Calendar.DAY_OF_MONTH, 1) + ) + ) + ).toArguments(); + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/TypesTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/TypesTest.java new file mode 100644 index 00000000..8c28d405 --- /dev/null +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/TypesTest.java @@ -0,0 +1,181 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types; + +import java.util.Collection; +import java.util.Map; +import java.util.Optional; +import java.util.function.Consumer; +import java.util.function.Function; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.test.context.TestPropertySource; + +import software.xdev.spring.data.eclipse.store.exceptions.DataTypeNotSupportedException; +import software.xdev.spring.data.eclipse.store.helper.TestUtil; +import software.xdev.spring.data.eclipse.store.integration.isolated.tests.IsolatedTestAnnotations; +import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage; +import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository; + + +@IsolatedTestAnnotations +@TestPropertySource( + properties = + "org.eclipse.store.storage-directory=./target/isolated-tests-storage" +) +class TypesTest +{ + public static final String TYPES_DATA_SOURCE = + "software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types" + + ".TypesData#generateData"; + public static final String TYPES_NOT_WORKING_DATA_SOURCE = + "software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types" + + ".TypesData#generateNotWorkingData"; + + @Autowired + private EclipseStoreStorage storage; + + @ParameterizedTest + @MethodSource(TYPES_DATA_SOURCE) + > void simpleStoreAndRead( + final Class> repositoryClass, + final Function objectCreator, + final Consumer ignoredObjectChanger, + @Autowired final ApplicationContext context) + { + final EclipseStoreRepository repository = context.getBean(repositoryClass); + final T objectToStore = objectCreator.apply(1); + repository.save(objectToStore); + + TestUtil.doBeforeAndAfterRestartOfDatastore( + this.storage, + () -> this.dynamicAssertEquals(1, repository, objectToStore) + ); + } + + @ParameterizedTest + @MethodSource(TYPES_NOT_WORKING_DATA_SOURCE) + > void simpleStoreAndReadForNotWorkingTypes( + final Class> repositoryClass, + final Function objectCreator, + final Consumer ignoredObjectChanger, + @Autowired final ApplicationContext context) + { + Assertions.assertThrows( + DataTypeNotSupportedException.class, + () -> this.simpleChangeAfterStore(repositoryClass, objectCreator, ignoredObjectChanger, context)); + } + + @ParameterizedTest + @MethodSource(TYPES_DATA_SOURCE) + > void simpleChangeToNullAfterStore( + final Class> repositoryClass, + final Function objectCreator, + final Consumer ignoredObjectChanger, + @Autowired final ApplicationContext context) + { + this.simpleChangeAfterStore(repositoryClass, objectCreator, object -> object.setValue(null), context); + } + + @ParameterizedTest + @MethodSource(TYPES_DATA_SOURCE) + > void simpleChangeAfterStore( + final Class> repositoryClass, + final Function objectCreator, + final Consumer objectChanger, + @Autowired final ApplicationContext context) + { + final EclipseStoreRepository repository = context.getBean(repositoryClass); + final T objectToStore = objectCreator.apply(1); + repository.save(objectToStore); + + final Optional storedObject = repository.findById(1); + Assertions.assertTrue(storedObject.isPresent()); + + objectChanger.accept(storedObject.get()); + repository.save(storedObject.get()); + + TestUtil.doBeforeAndAfterRestartOfDatastore( + this.storage, + () -> this.dynamicAssertEquals(1, repository, storedObject.get()) + ); + } + + @ParameterizedTest + @MethodSource(TYPES_DATA_SOURCE) + > void doubleStoreSameEntityWithChange( + final Class> repositoryClass, + final Function objectCreator, + final Consumer objectChanger, + @Autowired final ApplicationContext context) + { + final EclipseStoreRepository repository = context.getBean(repositoryClass); + final T objectToStore = objectCreator.apply(1); + repository.save(objectToStore); + + objectChanger.accept(objectToStore); + repository.save(objectToStore); + + TestUtil.doBeforeAndAfterRestartOfDatastore( + this.storage, + () -> this.dynamicAssertEquals(1, repository, objectToStore) + ); + } + + @ParameterizedTest + @MethodSource(TYPES_DATA_SOURCE) + > void simpleChangeBeforeStore( + final Class> repositoryClass, + final Function objectCreator, + final Consumer objectChanger, + @Autowired final ApplicationContext context) + { + final EclipseStoreRepository repository = context.getBean(repositoryClass); + final T objectToStore = objectCreator.apply(1); + objectChanger.accept(objectToStore); + repository.save(objectToStore); + + TestUtil.doBeforeAndAfterRestartOfDatastore( + this.storage, + () -> this.dynamicAssertEquals(1, repository, objectToStore) + ); + } + + private > void dynamicAssertEquals( + final int id, + final EclipseStoreRepository repository, + final T objectToStore) + { + final Optional storedObject2 = repository.findById(id); + Assertions.assertTrue(storedObject2.isPresent()); + if(storedObject2.get().getValue() instanceof final Map storedMap) + { + Assertions.assertEquals(((Map)objectToStore.getValue()).size(), storedMap.size()); + } + else if(storedObject2.get().getValue() instanceof final Collection storedList) + { + Assertions.assertEquals(((Collection)objectToStore.getValue()).size(), storedList.size()); + } + else + { + Assertions.assertEquals(objectToStore, storedObject2.get()); + } + } +} diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/tests/HashSetTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/tests/HashSetTest.java index faec4a23..3c4acc2a 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/tests/HashSetTest.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/tests/HashSetTest.java @@ -18,11 +18,9 @@ import java.util.List; import java.util.Set; -import org.springframework.beans.factory.annotation.Autowired; - import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; import software.xdev.spring.data.eclipse.store.helper.TestData; import software.xdev.spring.data.eclipse.store.helper.TestUtil; @@ -165,26 +163,6 @@ void testSaveAndSetNullAndFindAllNonFinal() ); } - // TODO: Fix this. - @Test - @Disabled("Is not fixed yet, but will be.") - void testDoubleSaveAndFindAll() - { - final CustomerWithHashSet customer = new CustomerWithHashSet(TestData.FIRST_NAME, TestData.LAST_NAME); - this.repository.save(customer); - customer.getValues().add("Test"); - this.repository.save(customer); - - TestUtil.doBeforeAndAfterRestartOfDatastore( - this.storage, - () -> { - final List customers = TestUtil.iterableToList(this.repository.findAll()); - Assertions.assertEquals(1, customers.size()); - Assertions.assertEquals(1, customers.get(0).getValues().size()); - } - ); - } - @Test void testDoubleSaveWithNewInstanceAndFindAll() { diff --git a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/repository/support/copier/object/EclipseStoreRegisteringCopierTest.java b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/repository/support/copier/object/EclipseStoreRegisteringCopierTest.java index 9cbd8cad..51ad01bf 100644 --- a/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/repository/support/copier/object/EclipseStoreRegisteringCopierTest.java +++ b/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/repository/support/copier/object/EclipseStoreRegisteringCopierTest.java @@ -21,6 +21,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import software.xdev.spring.data.eclipse.store.repository.SupportedChecker; import software.xdev.spring.data.eclipse.store.repository.WorkingCopyRegistry; @@ -34,7 +35,7 @@ private record DummyData(String data, int number) void testCopyManyCopiesSingle() { try(final EclipseSerializerRegisteringCopier copier = - new EclipseSerializerRegisteringCopier(new WorkingCopyRegistry())) + new EclipseSerializerRegisteringCopier(new WorkingCopyRegistry(), new SupportedChecker.Implementation())) { final List originalObjects = IntStream.range(0, 1_000).mapToObj( i -> new DummyData("Data" + i, i) @@ -50,7 +51,7 @@ void testCopyManyCopiesSingle() void testCopyAgainSameObject() { try(final EclipseSerializerRegisteringCopier copier = - new EclipseSerializerRegisteringCopier(new WorkingCopyRegistry())) + new EclipseSerializerRegisteringCopier(new WorkingCopyRegistry(), new SupportedChecker.Implementation())) { final DummyData originalObject = new DummyData("Test", 1); @@ -65,7 +66,7 @@ void testCopyAgainSameObject() void testCopyAgainTheCopy() { try(final EclipseSerializerRegisteringCopier copier = - new EclipseSerializerRegisteringCopier(new WorkingCopyRegistry())) + new EclipseSerializerRegisteringCopier(new WorkingCopyRegistry(), new SupportedChecker.Implementation())) { final DummyData originalObject = new DummyData("Test", 1); @@ -82,7 +83,7 @@ void testCopyAgainTheCopy() void testCopyManyCopiesBulk() { try(final EclipseSerializerRegisteringCopier copier = - new EclipseSerializerRegisteringCopier(new WorkingCopyRegistry())) + new EclipseSerializerRegisteringCopier(new WorkingCopyRegistry(), new SupportedChecker.Implementation())) { final List originalObjects = IntStream.range(0, 100_000).mapToObj( i -> new DummyData("Data" + i, i) @@ -98,7 +99,7 @@ void testCopyManyCopiesBulk() void testCopyEmpty() { try(final EclipseSerializerRegisteringCopier copier = - new EclipseSerializerRegisteringCopier(new WorkingCopyRegistry())) + new EclipseSerializerRegisteringCopier(new WorkingCopyRegistry(), new SupportedChecker.Implementation())) { Assertions.assertThrows(NullPointerException.class, () -> copier.copy(null)); }