diff --git a/core/src/test/java/place/sita/labelle/core/repository/inrepository/ImageRepositoryTest.java b/core/src/test/java/place/sita/labelle/core/repository/inrepository/ImageRepositoryTest.java index 486e8db..0f502f8 100644 --- a/core/src/test/java/place/sita/labelle/core/repository/inrepository/ImageRepositoryTest.java +++ b/core/src/test/java/place/sita/labelle/core/repository/inrepository/ImageRepositoryTest.java @@ -7,8 +7,10 @@ import place.sita.labelle.core.TestContainersTest; import place.sita.labelle.core.cache.CacheRegistry; import place.sita.labelle.core.images.imagelocator.ImageLocatorService; +import place.sita.labelle.core.repository.inrepository.delta.DeltaService; import place.sita.labelle.core.repository.inrepository.image.ImageRepository; import place.sita.labelle.core.repository.inrepository.image.ImageResponse; +import place.sita.labelle.core.repository.inrepository.tags.Tag; import place.sita.labelle.core.repository.repositories.Repository; import place.sita.labelle.core.repository.repositories.RepositoryService; import place.sita.labelle.datasource.NonUniqueAnswerException; @@ -41,11 +43,15 @@ public class ImageRepositoryTest extends TestContainersTest { @Autowired private ImageLocatorService imageLocatorService; + @Autowired + private DeltaService deltaService; + @Autowired private CacheRegistry cacheRegistry; @AfterEach public void cleanup() { + context.delete(Tables.TAG_DELTA).execute(); context.delete(Tables.TAG_IMAGE).execute(); context.delete(Tables.TAG).execute(); context.delete(Tables.TAG_CATEGORY).execute(); @@ -478,4 +484,24 @@ public void shouldReturnCorrectIndexOf() { assertThat(imageRepository.images().indexOf(sixthImage)).isEqualTo(5); } + @Test + public void shouldCreateDuplicateOfImage() { + // given + Repository repo = repositoryService.addRepository("Test repo"); + var imageId = inRepositoryService.addEmptySyntheticImage(repo.id()); + inRepositoryService.addTag(imageId, repo.id(), new Tag("First category", "First tag")); + inRepositoryService.addTag(imageId, repo.id(), new Tag("Second category", "Second tag")); + // todo test deltas + + // when + var duplicateId = inRepositoryService.duplicateImage(imageId); + + // then + assertThat(inRepositoryService.getTags(duplicateId)).contains(new Tag("First category", "First tag")); + assertThat(inRepositoryService.getTags(duplicateId)).contains(new Tag("Second category", "Second tag")); + assertThat(inRepositoryService.getTags(duplicateId)).hasSize(2); + // todo test persistent IDs + } + + }