From ad1bbf9ea847c7c4981f071f28744572e5443d53 Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Mon, 27 Jan 2020 21:21:20 +0000 Subject: [PATCH 01/14] refactor: rename tests on Groovy and add Legacy prefix to their names. The renaming is required as tests on Java and Groovy can't have the same class names. The original names (without Legacy prefix) will be used by new tests on Java. Part of 1246 --- .../{LocaleUtilsTest.groovy => LegacyLocaleUtilsTest.groovy} | 2 +- .../web/common/{PagerTest.groovy => LegacyPagerTest.groovy} | 2 +- .../common/{SlugUtilsTest.groovy => LegacySlugUtilsTest.groovy} | 2 +- ...rServiceImplTest.groovy => LegacyUserServiceImplTest.groovy} | 2 +- ...lTest.groovy => LegacyUsersActivationServiceImplTest.groovy} | 2 +- ...viceImplTest.groovy => LegacyCategoryServiceImplTest.groovy} | 2 +- ...ceImplTest.groovy => LegacyCollectionServiceImplTest.groovy} | 2 +- ...rviceImplTest.groovy => LegacyCountryServiceImplTest.groovy} | 2 +- ...groovy => LegacyDatabaseImagePersistenceStrategyTest.groovy} | 2 +- ...oovy => LegacyFilesystemImagePersistenceStrategyTest.groovy} | 2 +- ...ServiceImplTest.groovy => LegacyImageServiceImplTest.groovy} | 2 +- ...gyTest.groovy => LegacyTimedImagePreviewStrategyTest.groovy} | 2 +- ...eImplTest.groovy => LegacyParticipantServiceImplTest.groovy} | 2 +- .../{CatalogUtilsTest.groovy => LegacyCatalogUtilsTest.groovy} | 2 +- ...erviceImplTest.groovy => LegacySeriesServiceImplTest.groovy} | 2 +- ...mplTest.groovy => LegacyStampsCatalogServiceImplTest.groovy} | 2 +- ...ImplTest.groovy => LegacySeriesImportServiceImplTest.groovy} | 2 +- ...t.groovy => LegacySeriesInfoExtractorServiceImplTest.groovy} | 2 +- ....groovy => LegacyTimedSeriesInfoExtractorServiceTest.groovy} | 2 +- ...est.groovy => LegacySeriesSalesImportServiceImplTest.groovy} | 2 +- ...eImplTest.groovy => LegacySeriesSalesServiceImplTest.groovy} | 2 +- ...nServiceImplTest.groovy => LegacyCronServiceImplTest.groovy} | 2 +- ...eServiceImplTest.groovy => LegacySiteServiceImplTest.groovy} | 2 +- ...st.groovy => LegacySuspiciousActivityServiceImplTest.groovy} | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) rename src/test/groovy/ru/mystamps/web/common/{LocaleUtilsTest.groovy => LegacyLocaleUtilsTest.groovy} (97%) rename src/test/groovy/ru/mystamps/web/common/{PagerTest.groovy => LegacyPagerTest.groovy} (99%) rename src/test/groovy/ru/mystamps/web/common/{SlugUtilsTest.groovy => LegacySlugUtilsTest.groovy} (97%) rename src/test/groovy/ru/mystamps/web/feature/account/{UserServiceImplTest.groovy => LegacyUserServiceImplTest.groovy} (99%) rename src/test/groovy/ru/mystamps/web/feature/account/{UsersActivationServiceImplTest.groovy => LegacyUsersActivationServiceImplTest.groovy} (99%) rename src/test/groovy/ru/mystamps/web/feature/category/{CategoryServiceImplTest.groovy => LegacyCategoryServiceImplTest.groovy} (99%) rename src/test/groovy/ru/mystamps/web/feature/collection/{CollectionServiceImplTest.groovy => LegacyCollectionServiceImplTest.groovy} (99%) rename src/test/groovy/ru/mystamps/web/feature/country/{CountryServiceImplTest.groovy => LegacyCountryServiceImplTest.groovy} (99%) rename src/test/groovy/ru/mystamps/web/feature/image/{DatabaseImagePersistenceStrategyTest.groovy => LegacyDatabaseImagePersistenceStrategyTest.groovy} (98%) rename src/test/groovy/ru/mystamps/web/feature/image/{FilesystemImagePersistenceStrategyTest.groovy => LegacyFilesystemImagePersistenceStrategyTest.groovy} (98%) rename src/test/groovy/ru/mystamps/web/feature/image/{ImageServiceImplTest.groovy => LegacyImageServiceImplTest.groovy} (99%) rename src/test/groovy/ru/mystamps/web/feature/image/{TimedImagePreviewStrategyTest.groovy => LegacyTimedImagePreviewStrategyTest.groovy} (96%) rename src/test/groovy/ru/mystamps/web/feature/participant/{ParticipantServiceImplTest.groovy => LegacyParticipantServiceImplTest.groovy} (99%) rename src/test/groovy/ru/mystamps/web/feature/series/{CatalogUtilsTest.groovy => LegacyCatalogUtilsTest.groovy} (99%) rename src/test/groovy/ru/mystamps/web/feature/series/{SeriesServiceImplTest.groovy => LegacySeriesServiceImplTest.groovy} (99%) rename src/test/groovy/ru/mystamps/web/feature/series/{StampsCatalogServiceImplTest.groovy => LegacyStampsCatalogServiceImplTest.groovy} (98%) rename src/test/groovy/ru/mystamps/web/feature/series/importing/{SeriesImportServiceImplTest.groovy => LegacySeriesImportServiceImplTest.groovy} (99%) rename src/test/groovy/ru/mystamps/web/feature/series/importing/{SeriesInfoExtractorServiceImplTest.groovy => LegacySeriesInfoExtractorServiceImplTest.groovy} (99%) rename src/test/groovy/ru/mystamps/web/feature/series/importing/{TimedSeriesInfoExtractorServiceTest.groovy => LegacyTimedSeriesInfoExtractorServiceTest.groovy} (96%) rename src/test/groovy/ru/mystamps/web/feature/series/importing/sale/{SeriesSalesImportServiceImplTest.groovy => LegacySeriesSalesImportServiceImplTest.groovy} (97%) rename src/test/groovy/ru/mystamps/web/feature/series/sale/{SeriesSalesServiceImplTest.groovy => LegacySeriesSalesServiceImplTest.groovy} (98%) rename src/test/groovy/ru/mystamps/web/feature/site/{CronServiceImplTest.groovy => LegacyCronServiceImplTest.groovy} (99%) rename src/test/groovy/ru/mystamps/web/feature/site/{SiteServiceImplTest.groovy => LegacySiteServiceImplTest.groovy} (99%) rename src/test/groovy/ru/mystamps/web/feature/site/{SuspiciousActivityServiceImplTest.groovy => LegacySuspiciousActivityServiceImplTest.groovy} (98%) diff --git a/src/test/groovy/ru/mystamps/web/common/LocaleUtilsTest.groovy b/src/test/groovy/ru/mystamps/web/common/LegacyLocaleUtilsTest.groovy similarity index 97% rename from src/test/groovy/ru/mystamps/web/common/LocaleUtilsTest.groovy rename to src/test/groovy/ru/mystamps/web/common/LegacyLocaleUtilsTest.groovy index 08a20ede1e..a2a81ac20f 100644 --- a/src/test/groovy/ru/mystamps/web/common/LocaleUtilsTest.groovy +++ b/src/test/groovy/ru/mystamps/web/common/LegacyLocaleUtilsTest.groovy @@ -21,7 +21,7 @@ import spock.lang.Specification import spock.lang.Unroll @SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace']) -class LocaleUtilsTest extends Specification { +class LegacyLocaleUtilsTest extends Specification { // // Tests for getLanguageOrNull() diff --git a/src/test/groovy/ru/mystamps/web/common/PagerTest.groovy b/src/test/groovy/ru/mystamps/web/common/LegacyPagerTest.groovy similarity index 99% rename from src/test/groovy/ru/mystamps/web/common/PagerTest.groovy rename to src/test/groovy/ru/mystamps/web/common/LegacyPagerTest.groovy index 46390bac3c..81474fa494 100644 --- a/src/test/groovy/ru/mystamps/web/common/PagerTest.groovy +++ b/src/test/groovy/ru/mystamps/web/common/LegacyPagerTest.groovy @@ -21,7 +21,7 @@ import spock.lang.Specification import spock.lang.Unroll @SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace']) -class PagerTest extends Specification { +class LegacyPagerTest extends Specification { // // Tests for Pager() diff --git a/src/test/groovy/ru/mystamps/web/common/SlugUtilsTest.groovy b/src/test/groovy/ru/mystamps/web/common/LegacySlugUtilsTest.groovy similarity index 97% rename from src/test/groovy/ru/mystamps/web/common/SlugUtilsTest.groovy rename to src/test/groovy/ru/mystamps/web/common/LegacySlugUtilsTest.groovy index 8a9ef10c87..b34a9e4842 100644 --- a/src/test/groovy/ru/mystamps/web/common/SlugUtilsTest.groovy +++ b/src/test/groovy/ru/mystamps/web/common/LegacySlugUtilsTest.groovy @@ -21,7 +21,7 @@ import spock.lang.Specification import spock.lang.Unroll @SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace']) -class SlugUtilsTest extends Specification { +class LegacySlugUtilsTest extends Specification { // // Tests for slugify() diff --git a/src/test/groovy/ru/mystamps/web/feature/account/UserServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/account/LegacyUserServiceImplTest.groovy similarity index 99% rename from src/test/groovy/ru/mystamps/web/feature/account/UserServiceImplTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/account/LegacyUserServiceImplTest.groovy index 327682b243..7c1b17f876 100644 --- a/src/test/groovy/ru/mystamps/web/feature/account/UserServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/account/LegacyUserServiceImplTest.groovy @@ -26,7 +26,7 @@ import ru.mystamps.web.tests.Random import spock.lang.Specification @SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace']) -class UserServiceImplTest extends Specification { +class LegacyUserServiceImplTest extends Specification { private final UserDao userDao = Mock() private final UsersActivationService usersActivationService = Mock() diff --git a/src/test/groovy/ru/mystamps/web/feature/account/UsersActivationServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/account/LegacyUsersActivationServiceImplTest.groovy similarity index 99% rename from src/test/groovy/ru/mystamps/web/feature/account/UsersActivationServiceImplTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/account/LegacyUsersActivationServiceImplTest.groovy index 70598bd6fe..c491a2f0ea 100644 --- a/src/test/groovy/ru/mystamps/web/feature/account/UsersActivationServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/account/LegacyUsersActivationServiceImplTest.groovy @@ -25,7 +25,7 @@ import spock.lang.Specification import spock.lang.Unroll @SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace']) -class UsersActivationServiceImplTest extends Specification { +class LegacyUsersActivationServiceImplTest extends Specification { private final UsersActivationDao usersActivationDao = Mock() private final MailService mailService = Mock() diff --git a/src/test/groovy/ru/mystamps/web/feature/category/CategoryServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/category/LegacyCategoryServiceImplTest.groovy similarity index 99% rename from src/test/groovy/ru/mystamps/web/feature/category/CategoryServiceImplTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/category/LegacyCategoryServiceImplTest.groovy index b9dd92dd0a..2c7042cbf7 100644 --- a/src/test/groovy/ru/mystamps/web/feature/category/CategoryServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/category/LegacyCategoryServiceImplTest.groovy @@ -41,7 +41,7 @@ import static io.qala.datagen.StringModifier.Impls.oneOf 'NoTabCharacter', 'TrailingWhitespace', ]) -class CategoryServiceImplTest extends Specification { +class LegacyCategoryServiceImplTest extends Specification { private final CategoryDao categoryDao = Mock() private final CategoryService service = new CategoryServiceImpl(NOPLogger.NOP_LOGGER, categoryDao) diff --git a/src/test/groovy/ru/mystamps/web/feature/collection/CollectionServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/collection/LegacyCollectionServiceImplTest.groovy similarity index 99% rename from src/test/groovy/ru/mystamps/web/feature/collection/CollectionServiceImplTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/collection/LegacyCollectionServiceImplTest.groovy index 49be144f62..06c6cdd5cf 100644 --- a/src/test/groovy/ru/mystamps/web/feature/collection/CollectionServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/collection/LegacyCollectionServiceImplTest.groovy @@ -37,7 +37,7 @@ import static io.qala.datagen.RandomShortApi.positiveLong 'NoTabCharacter', 'TrailingWhitespace', ]) -class CollectionServiceImplTest extends Specification { +class LegacyCollectionServiceImplTest extends Specification { private final CollectionDao collectionDao = Mock() diff --git a/src/test/groovy/ru/mystamps/web/feature/country/CountryServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/country/LegacyCountryServiceImplTest.groovy similarity index 99% rename from src/test/groovy/ru/mystamps/web/feature/country/CountryServiceImplTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/country/LegacyCountryServiceImplTest.groovy index 8b4a079a07..42233691a7 100644 --- a/src/test/groovy/ru/mystamps/web/feature/country/CountryServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/country/LegacyCountryServiceImplTest.groovy @@ -40,7 +40,7 @@ import static io.qala.datagen.StringModifier.Impls.oneOf 'NoTabCharacter', 'TrailingWhitespace', ]) -class CountryServiceImplTest extends Specification { +class LegacyCountryServiceImplTest extends Specification { private final CountryDao countryDao = Mock() private final CountryService service = new CountryServiceImpl(NOPLogger.NOP_LOGGER, countryDao) diff --git a/src/test/groovy/ru/mystamps/web/feature/image/DatabaseImagePersistenceStrategyTest.groovy b/src/test/groovy/ru/mystamps/web/feature/image/LegacyDatabaseImagePersistenceStrategyTest.groovy similarity index 98% rename from src/test/groovy/ru/mystamps/web/feature/image/DatabaseImagePersistenceStrategyTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/image/LegacyDatabaseImagePersistenceStrategyTest.groovy index a1d7addf90..db69425965 100644 --- a/src/test/groovy/ru/mystamps/web/feature/image/DatabaseImagePersistenceStrategyTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/image/LegacyDatabaseImagePersistenceStrategyTest.groovy @@ -23,7 +23,7 @@ import ru.mystamps.web.service.TestObjects import spock.lang.Specification @SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace']) -class DatabaseImagePersistenceStrategyTest extends Specification { +class LegacyDatabaseImagePersistenceStrategyTest extends Specification { private final ImageDataDao imageDataDao = Mock() private final MultipartFile multipartFile = Mock() diff --git a/src/test/groovy/ru/mystamps/web/feature/image/FilesystemImagePersistenceStrategyTest.groovy b/src/test/groovy/ru/mystamps/web/feature/image/LegacyFilesystemImagePersistenceStrategyTest.groovy similarity index 98% rename from src/test/groovy/ru/mystamps/web/feature/image/FilesystemImagePersistenceStrategyTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/image/LegacyFilesystemImagePersistenceStrategyTest.groovy index de4d71428b..213c3c4665 100644 --- a/src/test/groovy/ru/mystamps/web/feature/image/FilesystemImagePersistenceStrategyTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/image/LegacyFilesystemImagePersistenceStrategyTest.groovy @@ -25,7 +25,7 @@ import spock.lang.Specification import java.nio.file.Path @SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace']) -class FilesystemImagePersistenceStrategyTest extends Specification { +class LegacyFilesystemImagePersistenceStrategyTest extends Specification { private static final STORAGE_DIR = File.separator + 'tmp' private static final PREVIEW_DIR = File.separator + 'tmp' diff --git a/src/test/groovy/ru/mystamps/web/feature/image/ImageServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/image/LegacyImageServiceImplTest.groovy similarity index 99% rename from src/test/groovy/ru/mystamps/web/feature/image/ImageServiceImplTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/image/LegacyImageServiceImplTest.groovy index efd0f2c70d..9487020ada 100644 --- a/src/test/groovy/ru/mystamps/web/feature/image/ImageServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/image/LegacyImageServiceImplTest.groovy @@ -26,7 +26,7 @@ import spock.lang.Specification import spock.lang.Unroll @SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace']) -class ImageServiceImplTest extends Specification { +class LegacyImageServiceImplTest extends Specification { private final ImageDao imageDao = Mock() private final MultipartFile multipartFile = Mock() diff --git a/src/test/groovy/ru/mystamps/web/feature/image/TimedImagePreviewStrategyTest.groovy b/src/test/groovy/ru/mystamps/web/feature/image/LegacyTimedImagePreviewStrategyTest.groovy similarity index 96% rename from src/test/groovy/ru/mystamps/web/feature/image/TimedImagePreviewStrategyTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/image/LegacyTimedImagePreviewStrategyTest.groovy index de3d1c3a2e..d4e2593e3a 100644 --- a/src/test/groovy/ru/mystamps/web/feature/image/TimedImagePreviewStrategyTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/image/LegacyTimedImagePreviewStrategyTest.groovy @@ -22,7 +22,7 @@ import spock.lang.Specification import spock.lang.Unroll @SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace']) -class TimedImagePreviewStrategyTest extends Specification { +class LegacyTimedImagePreviewStrategyTest extends Specification { private final ImagePreviewStrategy origStrategy = Mock() diff --git a/src/test/groovy/ru/mystamps/web/feature/participant/ParticipantServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/participant/LegacyParticipantServiceImplTest.groovy similarity index 99% rename from src/test/groovy/ru/mystamps/web/feature/participant/ParticipantServiceImplTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/participant/LegacyParticipantServiceImplTest.groovy index dddbadf735..8c6336ef54 100644 --- a/src/test/groovy/ru/mystamps/web/feature/participant/ParticipantServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/participant/LegacyParticipantServiceImplTest.groovy @@ -34,7 +34,7 @@ import static io.qala.datagen.RandomShortApi.nullOrBlank 'NoTabCharacter', 'TrailingWhitespace', ]) -class ParticipantServiceImplTest extends Specification { +class LegacyParticipantServiceImplTest extends Specification { private final ParticipantDao participantDao = Mock() private final ParticipantService service = new ParticipantServiceImpl( diff --git a/src/test/groovy/ru/mystamps/web/feature/series/CatalogUtilsTest.groovy b/src/test/groovy/ru/mystamps/web/feature/series/LegacyCatalogUtilsTest.groovy similarity index 99% rename from src/test/groovy/ru/mystamps/web/feature/series/CatalogUtilsTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/series/LegacyCatalogUtilsTest.groovy index 8d4478a2a7..077ac9dac5 100644 --- a/src/test/groovy/ru/mystamps/web/feature/series/CatalogUtilsTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/series/LegacyCatalogUtilsTest.groovy @@ -21,7 +21,7 @@ import spock.lang.Specification import spock.lang.Unroll @SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace']) -class CatalogUtilsTest extends Specification { +class LegacyCatalogUtilsTest extends Specification { // // Tests for toShortForm() diff --git a/src/test/groovy/ru/mystamps/web/feature/series/SeriesServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/series/LegacySeriesServiceImplTest.groovy similarity index 99% rename from src/test/groovy/ru/mystamps/web/feature/series/SeriesServiceImplTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/series/LegacySeriesServiceImplTest.groovy index 138d2793c3..5afd12ec54 100644 --- a/src/test/groovy/ru/mystamps/web/feature/series/SeriesServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/series/LegacySeriesServiceImplTest.groovy @@ -41,7 +41,7 @@ import static io.qala.datagen.RandomShortApi.positiveLong 'NoTabCharacter', 'TrailingWhitespace', ]) -class SeriesServiceImplTest extends Specification { +class LegacySeriesServiceImplTest extends Specification { private final ImageService imageService = Mock() private final SeriesDao seriesDao = Mock() private final StampsCatalogService michelCatalogService = Mock() diff --git a/src/test/groovy/ru/mystamps/web/feature/series/StampsCatalogServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/series/LegacyStampsCatalogServiceImplTest.groovy similarity index 98% rename from src/test/groovy/ru/mystamps/web/feature/series/StampsCatalogServiceImplTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/series/LegacyStampsCatalogServiceImplTest.groovy index 2c87a04301..02948505eb 100644 --- a/src/test/groovy/ru/mystamps/web/feature/series/StampsCatalogServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/series/LegacyStampsCatalogServiceImplTest.groovy @@ -23,7 +23,7 @@ import spock.lang.Specification import spock.lang.Unroll @SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace']) -class StampsCatalogServiceImplTest extends Specification { +class LegacyStampsCatalogServiceImplTest extends Specification { private final StampsCatalogDao stampsCatalogDao = Mock() diff --git a/src/test/groovy/ru/mystamps/web/feature/series/importing/SeriesImportServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/series/importing/LegacySeriesImportServiceImplTest.groovy similarity index 99% rename from src/test/groovy/ru/mystamps/web/feature/series/importing/SeriesImportServiceImplTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/series/importing/LegacySeriesImportServiceImplTest.groovy index 85db022f2d..dbdadb2a65 100644 --- a/src/test/groovy/ru/mystamps/web/feature/series/importing/SeriesImportServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/series/importing/LegacySeriesImportServiceImplTest.groovy @@ -48,7 +48,7 @@ import static io.qala.datagen.RandomValue.between 'NoTabCharacter', 'TrailingWhitespace', ]) -class SeriesImportServiceImplTest extends Specification { +class LegacySeriesImportServiceImplTest extends Specification { private final SeriesImportDao seriesImportDao = Mock() private final SeriesService seriesService = Mock() diff --git a/src/test/groovy/ru/mystamps/web/feature/series/importing/SeriesInfoExtractorServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/series/importing/LegacySeriesInfoExtractorServiceImplTest.groovy similarity index 99% rename from src/test/groovy/ru/mystamps/web/feature/series/importing/SeriesInfoExtractorServiceImplTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/series/importing/LegacySeriesInfoExtractorServiceImplTest.groovy index 0b06d7759f..2324de152a 100644 --- a/src/test/groovy/ru/mystamps/web/feature/series/importing/SeriesInfoExtractorServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/series/importing/LegacySeriesInfoExtractorServiceImplTest.groovy @@ -43,7 +43,7 @@ import static ru.mystamps.web.feature.series.importing.SeriesInfoExtractorServic 'NoTabCharacter', 'TrailingWhitespace', ]) -class SeriesInfoExtractorServiceImplTest extends Specification { +class LegacySeriesInfoExtractorServiceImplTest extends Specification { private final CategoryService categoryService = Mock() private final CountryService countryService = Mock() diff --git a/src/test/groovy/ru/mystamps/web/feature/series/importing/TimedSeriesInfoExtractorServiceTest.groovy b/src/test/groovy/ru/mystamps/web/feature/series/importing/LegacyTimedSeriesInfoExtractorServiceTest.groovy similarity index 96% rename from src/test/groovy/ru/mystamps/web/feature/series/importing/TimedSeriesInfoExtractorServiceTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/series/importing/LegacyTimedSeriesInfoExtractorServiceTest.groovy index 28d4368eb0..5016cf8657 100644 --- a/src/test/groovy/ru/mystamps/web/feature/series/importing/TimedSeriesInfoExtractorServiceTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/series/importing/LegacyTimedSeriesInfoExtractorServiceTest.groovy @@ -32,7 +32,7 @@ import static io.qala.datagen.RandomShortApi.nullOr 'NoTabCharacter', 'TrailingWhitespace', ]) -class TimedSeriesInfoExtractorServiceTest extends Specification { +class LegacyTimedSeriesInfoExtractorServiceTest extends Specification { private final SeriesInfoExtractorService origService = Mock() diff --git a/src/test/groovy/ru/mystamps/web/feature/series/importing/sale/SeriesSalesImportServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/series/importing/sale/LegacySeriesSalesImportServiceImplTest.groovy similarity index 97% rename from src/test/groovy/ru/mystamps/web/feature/series/importing/sale/SeriesSalesImportServiceImplTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/series/importing/sale/LegacySeriesSalesImportServiceImplTest.groovy index 18134ad0e1..41bd3ba71a 100644 --- a/src/test/groovy/ru/mystamps/web/feature/series/importing/sale/SeriesSalesImportServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/series/importing/sale/LegacySeriesSalesImportServiceImplTest.groovy @@ -25,7 +25,7 @@ import ru.mystamps.web.tests.Random import spock.lang.Specification @SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace']) -class SeriesSalesImportServiceImplTest extends Specification { +class LegacySeriesSalesImportServiceImplTest extends Specification { private final SeriesSalesImportDao seriesSalesImportDao = Mock() private final DownloaderService downloaderService = Mock() diff --git a/src/test/groovy/ru/mystamps/web/feature/series/sale/SeriesSalesServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/series/sale/LegacySeriesSalesServiceImplTest.groovy similarity index 98% rename from src/test/groovy/ru/mystamps/web/feature/series/sale/SeriesSalesServiceImplTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/series/sale/LegacySeriesSalesServiceImplTest.groovy index 8dd05f3a5b..b70baf4164 100644 --- a/src/test/groovy/ru/mystamps/web/feature/series/sale/SeriesSalesServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/series/sale/LegacySeriesSalesServiceImplTest.groovy @@ -24,7 +24,7 @@ import spock.lang.Specification import spock.lang.Unroll @SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace']) -class SeriesSalesServiceImplTest extends Specification { +class LegacySeriesSalesServiceImplTest extends Specification { private final SeriesSalesDao seriesSalesDao = Mock() private final SeriesSalesService service = new SeriesSalesServiceImpl( diff --git a/src/test/groovy/ru/mystamps/web/feature/site/CronServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy similarity index 99% rename from src/test/groovy/ru/mystamps/web/feature/site/CronServiceImplTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy index 00165911db..5df7f3732d 100644 --- a/src/test/groovy/ru/mystamps/web/feature/site/CronServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy @@ -30,7 +30,7 @@ import ru.mystamps.web.service.TestObjects import spock.lang.Specification @SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace']) -class CronServiceImplTest extends Specification { +class LegacyCronServiceImplTest extends Specification { private final CategoryService categoryService = Mock() private final CountryService countryService = Mock() diff --git a/src/test/groovy/ru/mystamps/web/feature/site/SiteServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/site/LegacySiteServiceImplTest.groovy similarity index 99% rename from src/test/groovy/ru/mystamps/web/feature/site/SiteServiceImplTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/site/LegacySiteServiceImplTest.groovy index 21f4adda37..0b55099830 100644 --- a/src/test/groovy/ru/mystamps/web/feature/site/SiteServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/site/LegacySiteServiceImplTest.groovy @@ -26,7 +26,7 @@ import spock.lang.Specification import spock.lang.Unroll @SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace']) -class SiteServiceImplTest extends Specification { +class LegacySiteServiceImplTest extends Specification { private static final String TEST_TYPE = TestObjects.TEST_ACTIVITY_TYPE private static final String TEST_PAGE = TestObjects.TEST_ACTIVITY_PAGE private static final String TEST_IP = TestObjects.TEST_ACTIVITY_IP diff --git a/src/test/groovy/ru/mystamps/web/feature/site/SuspiciousActivityServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/site/LegacySuspiciousActivityServiceImplTest.groovy similarity index 98% rename from src/test/groovy/ru/mystamps/web/feature/site/SuspiciousActivityServiceImplTest.groovy rename to src/test/groovy/ru/mystamps/web/feature/site/LegacySuspiciousActivityServiceImplTest.groovy index 1583f632cc..fc86f6e9ef 100644 --- a/src/test/groovy/ru/mystamps/web/feature/site/SuspiciousActivityServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/site/LegacySuspiciousActivityServiceImplTest.groovy @@ -22,7 +22,7 @@ import spock.lang.Specification import spock.lang.Unroll @SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace']) -class SuspiciousActivityServiceImplTest extends Specification { +class LegacySuspiciousActivityServiceImplTest extends Specification { private final SuspiciousActivityDao suspiciousActivityDao = Mock() From 66326768064c3e56ddcfc3dd48746e5b0f0953a8 Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Mon, 27 Jan 2020 21:27:24 +0000 Subject: [PATCH 02/14] refactor: rename methods to avoid escaping of a single quote. This change is needed in order to simplify automated porting of tests. Part of 1246 --- .../collection/LegacyCollectionServiceImplTest.groovy | 2 +- .../LegacyFilesystemImagePersistenceStrategyTest.groovy | 2 +- .../web/feature/series/LegacySeriesServiceImplTest.groovy | 4 ++-- .../LegacySeriesInfoExtractorServiceImplTest.groovy | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/test/groovy/ru/mystamps/web/feature/collection/LegacyCollectionServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/collection/LegacyCollectionServiceImplTest.groovy index 06c6cdd5cf..271832d74c 100644 --- a/src/test/groovy/ru/mystamps/web/feature/collection/LegacyCollectionServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/collection/LegacyCollectionServiceImplTest.groovy @@ -70,7 +70,7 @@ class LegacyCollectionServiceImplTest extends Specification { } @SuppressWarnings('FactoryMethodName') - def 'createCollection() should throw exception when owner login can\'t be converted to slug'() { + def "createCollection() should throw exception when owner login can't be converted to slug"() { when: service.createCollection(Random.userId(), '') then: diff --git a/src/test/groovy/ru/mystamps/web/feature/image/LegacyFilesystemImagePersistenceStrategyTest.groovy b/src/test/groovy/ru/mystamps/web/feature/image/LegacyFilesystemImagePersistenceStrategyTest.groovy index 213c3c4665..3ccaf29db8 100644 --- a/src/test/groovy/ru/mystamps/web/feature/image/LegacyFilesystemImagePersistenceStrategyTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/image/LegacyFilesystemImagePersistenceStrategyTest.groovy @@ -94,7 +94,7 @@ class LegacyFilesystemImagePersistenceStrategyTest extends Specification { // Tests for get() // - def 'get() should return null when file doesn\'t exist'() { + def "get() should return null when file doesn't exist"() { given: strategy.exists(_ as Path) >> false and: diff --git a/src/test/groovy/ru/mystamps/web/feature/series/LegacySeriesServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/series/LegacySeriesServiceImplTest.groovy index 5afd12ec54..5b457004e0 100644 --- a/src/test/groovy/ru/mystamps/web/feature/series/LegacySeriesServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/series/LegacySeriesServiceImplTest.groovy @@ -955,7 +955,7 @@ class LegacySeriesServiceImplTest extends Specification { 1 * solovyovCatalogService.findSeriesIdsByNumber(expectedNumber) >> [] } - def 'findBySolovyovNumber() shouldn\'t try to find series info if there are no series'() { + def "findBySolovyovNumber() shouldn't try to find series info if there are no series"() { given: solovyovCatalogService.findSeriesIdsByNumber(_ as String) >> [] when: @@ -994,7 +994,7 @@ class LegacySeriesServiceImplTest extends Specification { 1 * zagorskiCatalogService.findSeriesIdsByNumber(expectedNumber) >> [] } - def 'findByZagorskiNumber() shouldn\'t try to find series info if there are no series'() { + def "findByZagorskiNumber() shouldn't try to find series info if there are no series"() { given: zagorskiCatalogService.findSeriesIdsByNumber(_ as String) >> [] when: diff --git a/src/test/groovy/ru/mystamps/web/feature/series/importing/LegacySeriesInfoExtractorServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/series/importing/LegacySeriesInfoExtractorServiceImplTest.groovy index 2324de152a..c83fdd4bd6 100644 --- a/src/test/groovy/ru/mystamps/web/feature/series/importing/LegacySeriesInfoExtractorServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/series/importing/LegacySeriesInfoExtractorServiceImplTest.groovy @@ -327,7 +327,7 @@ class LegacySeriesInfoExtractorServiceImplTest extends Specification { year == expectedYear } - def 'extractReleaseYear() shouldn\'t extract dates before 1840'() { + def "extractReleaseYear() shouldn't extract dates before 1840"() { given: Integer unsupportedYear = between(0, SeriesValidation.MIN_RELEASE_YEAR - 1).integer() String fragment = String.valueOf(unsupportedYear) @@ -337,7 +337,7 @@ class LegacySeriesInfoExtractorServiceImplTest extends Specification { year == null } - def 'extractReleaseYear() shouldn\'t extract dates after 2099'() { + def "extractReleaseYear() shouldn't extract dates after 2099"() { given: Integer unsupportedYear = between(MAX_SUPPORTED_RELEASE_YEAR + 1, Integer.MAX_VALUE).integer() String fragment = String.valueOf(unsupportedYear) @@ -348,7 +348,7 @@ class LegacySeriesInfoExtractorServiceImplTest extends Specification { } @Unroll - def 'extractReleaseYear() shouldn\'t extract date from "#fragment"'(String fragment) { + def "extractReleaseYear() shouldn't extract date from '#fragment'"(String fragment) { when: Integer year = service.extractReleaseYear(fragment) then: From b2791d847e8206950a29f059cfac63d152ca0655 Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Mon, 27 Jan 2020 21:29:31 +0000 Subject: [PATCH 03/14] refactor: explicitly specify members type. This change is needed in order to simplify automated porting of tests. Part of 1246 --- .../image/LegacyFilesystemImagePersistenceStrategyTest.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/groovy/ru/mystamps/web/feature/image/LegacyFilesystemImagePersistenceStrategyTest.groovy b/src/test/groovy/ru/mystamps/web/feature/image/LegacyFilesystemImagePersistenceStrategyTest.groovy index 3ccaf29db8..2c14425f42 100644 --- a/src/test/groovy/ru/mystamps/web/feature/image/LegacyFilesystemImagePersistenceStrategyTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/image/LegacyFilesystemImagePersistenceStrategyTest.groovy @@ -26,8 +26,8 @@ import java.nio.file.Path @SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace']) class LegacyFilesystemImagePersistenceStrategyTest extends Specification { - private static final STORAGE_DIR = File.separator + 'tmp' - private static final PREVIEW_DIR = File.separator + 'tmp' + private static final String STORAGE_DIR = File.separator + 'tmp' + private static final String PREVIEW_DIR = File.separator + 'tmp' private final MultipartFile multipartFile = Mock() private final ImageInfoDto imageInfoDto = TestObjects.createImageInfoDto() From 2cae593f71ee85073f789627aa0cfc274073d6cc Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Mon, 27 Jan 2020 21:30:23 +0000 Subject: [PATCH 04/14] refactor: split "where" block and its arguments This change is needed in order to simplify automated porting of tests. Part of 1246 --- .../site/LegacySiteServiceImplTest.groovy | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/test/groovy/ru/mystamps/web/feature/site/LegacySiteServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/site/LegacySiteServiceImplTest.groovy index 0b55099830..1c850644dc 100644 --- a/src/test/groovy/ru/mystamps/web/feature/site/LegacySiteServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/site/LegacySiteServiceImplTest.groovy @@ -210,9 +210,10 @@ class LegacySiteServiceImplTest extends Specification { assert activity?.method == expectedMethod return true }) - where: expectedMethod | _ - 'OPTIONS' | _ - null | _ + where: + expectedMethod | _ + 'OPTIONS' | _ + null | _ } @SuppressWarnings(['ClosureAsLastMethodParameter', 'UnnecessaryReturnKeyword']) @@ -311,10 +312,11 @@ class LegacySiteServiceImplTest extends Specification { assert activity?.refererPage == null return true }) - where: refererPage | _ - ' ' | _ - '' | _ - null | _ + where: + refererPage | _ + ' ' | _ + '' | _ + null | _ } @SuppressWarnings(['ClosureAsLastMethodParameter', 'UnnecessaryReturnKeyword']) @@ -352,10 +354,11 @@ class LegacySiteServiceImplTest extends Specification { assert activity?.userAgent == null return true }) - where: userAgent | _ - ' ' | _ - '' | _ - null | _ + where: + userAgent | _ + ' ' | _ + '' | _ + null | _ } } From 7408a66866f179947150e12f44d3544045492f81 Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Mon, 27 Jan 2020 21:31:37 +0000 Subject: [PATCH 05/14] style: add white spaces where needed and remove trailing tabs. This change is needed in order to simplify automated porting of tests. Part of 1246 --- .../web/feature/series/LegacySeriesServiceImplTest.groovy | 2 +- .../series/importing/LegacySeriesImportServiceImplTest.groovy | 1 - .../mystamps/web/feature/site/LegacyCronServiceImplTest.groovy | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/test/groovy/ru/mystamps/web/feature/series/LegacySeriesServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/series/LegacySeriesServiceImplTest.groovy index 5b457004e0..68af691029 100644 --- a/src/test/groovy/ru/mystamps/web/feature/series/LegacySeriesServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/series/LegacySeriesServiceImplTest.groovy @@ -758,7 +758,7 @@ class LegacySeriesServiceImplTest extends Specification { result.createdBy == expectedInfo.createdBy result.imageIds == expectedImageIds - + result.michel?.numbers == expectedMichelNumbers result.michel?.price == expectedInfo.michelPrice diff --git a/src/test/groovy/ru/mystamps/web/feature/series/importing/LegacySeriesImportServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/series/importing/LegacySeriesImportServiceImplTest.groovy index dbdadb2a65..90b78a392f 100644 --- a/src/test/groovy/ru/mystamps/web/feature/series/importing/LegacySeriesImportServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/series/importing/LegacySeriesImportServiceImplTest.groovy @@ -329,7 +329,6 @@ class LegacySeriesImportServiceImplTest extends Specification { assert status?.newStatus == expectedNewStatus return true }) - } // diff --git a/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy index 5df7f3732d..56eecadee6 100644 --- a/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy @@ -231,7 +231,7 @@ class LegacyCronServiceImplTest extends Specification { def "purgeUsersActivations() should do nothing if no activations"() { given: usersActivationService.findOlderThan(_ as Integer) >> [] - when: + when: service.purgeUsersActivations() then: 0 * usersActivationService.remove(_ as String) From d93b668ebee71883fafd6d6511026621783cb851 Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Mon, 27 Jan 2020 21:37:30 +0000 Subject: [PATCH 06/14] [DO NOT MERGE] run only a single profile. --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 55c3ed06cf..522e723cca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,7 @@ language: java env: matrix: - - SPRING_PROFILES_ACTIVE=test - SPRING_PROFILES_ACTIVE=travis - - SPRING_PROFILES_ACTIVE=postgres global: - MAVEN_OPTS='-Xss256k' - secure: "fBav56BzY+A+Vs1g9YSfo1oLDCO1rFrXl49lJkOA5/XpnsKEEs4lI2RcOzz0wiJKXFNgcliiAJWoYMI8Esqz+lkyFWan4ij5Co0UzJcytDuY+2o+jaqwx45DuDYPogABzT+hWjLCxQLLG46gUkChzT8kcvOOn6JxC7Ff8q5MnoM=" From cab975bc72b9fb75ed5b6c4967ba8af7de48d589 Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Mon, 27 Jan 2020 22:49:05 +0000 Subject: [PATCH 07/14] refactor: propagate assertThat().isNotNull() This change is needed in order to simplify automated porting of tests. Part of 1246 --- .../web/feature/site/LegacyCronServiceImplTest.groovy | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy index 56eecadee6..d8b7e7dc47 100644 --- a/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy @@ -17,6 +17,7 @@ */ package ru.mystamps.web.feature.site +import org.assertj.core.api.WithAssertions import org.slf4j.helpers.NOPLogger import ru.mystamps.web.feature.account.UserService import ru.mystamps.web.feature.account.UsersActivationFullDto @@ -30,7 +31,7 @@ import ru.mystamps.web.service.TestObjects import spock.lang.Specification @SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace']) -class LegacyCronServiceImplTest extends Specification { +class LegacyCronServiceImplTest extends Specification implements WithAssertions { private final CategoryService categoryService = Mock() private final CountryService countryService = Mock() @@ -66,14 +67,14 @@ class LegacyCronServiceImplTest extends Specification { assert first[Calendar.DAY_OF_MONTH] == second[Calendar.DAY_OF_MONTH] } - private static void assertMidnightOfYesterday(Date date) { - assert date != null + private void assertMidnightOfYesterday(Date date) { + assertThat(date).isNotNull() assertDatesEqual(date, new Date().previous()) assertMidnight(date) } - private static void assertMidnightOfToday(Date date) { - assert date != null + private void assertMidnightOfToday(Date date) { + assertThat(date).isNotNull() assertDatesEqual(date, new Date()) assertMidnight(date) } From 4079d28b59e4c5ef028fd8d43fc58791eb139823 Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Mon, 27 Jan 2020 22:52:15 +0000 Subject: [PATCH 08/14] refactor: use assertThat() for hours/minutes/seconds/milliseconds. This change is needed in order to simplify automated porting of tests. Part of 1246 --- .../web/feature/site/LegacyCronServiceImplTest.groovy | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy index d8b7e7dc47..2f540b8dc4 100644 --- a/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy @@ -54,11 +54,12 @@ class LegacyCronServiceImplTest extends Specification implements WithAssertions mailService ) - private static void assertMidnight(Date date) { - assert date[Calendar.HOUR_OF_DAY] == 0 - assert date[Calendar.MINUTE] == 0 - assert date[Calendar.SECOND] == 0 - assert date[Calendar.MILLISECOND] == 0 + private void assertMidnight(Date date) { + assertThat(date) + .hasHourOfDay(0) + .hasMinute(0) + .hasSecond(0) + .hasMillisecond(0) } private static void assertDatesEqual(Date first, Date second) { From 3b3bd4986d7d4b609f59fcf93cfea253df8dfe5c Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Mon, 27 Jan 2020 23:02:48 +0000 Subject: [PATCH 09/14] refactor: use assertThat().isToday() and .isInSameDayAs() to simplify code. This change is needed in order to simplify automated porting of tests. Part of 1246 --- .../feature/site/LegacyCronServiceImplTest.groovy | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy index 2f540b8dc4..7d81230932 100644 --- a/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy @@ -17,6 +17,8 @@ */ package ru.mystamps.web.feature.site +import static org.assertj.core.util.DateUtil.yesterday + import org.assertj.core.api.WithAssertions import org.slf4j.helpers.NOPLogger import ru.mystamps.web.feature.account.UserService @@ -62,21 +64,15 @@ class LegacyCronServiceImplTest extends Specification implements WithAssertions .hasMillisecond(0) } - private static void assertDatesEqual(Date first, Date second) { - assert first[Calendar.YEAR] == second[Calendar.YEAR] - assert first[Calendar.MONTH] == second[Calendar.MONTH] - assert first[Calendar.DAY_OF_MONTH] == second[Calendar.DAY_OF_MONTH] - } - private void assertMidnightOfYesterday(Date date) { assertThat(date).isNotNull() - assertDatesEqual(date, new Date().previous()) + assertThat(date).isInSameDayAs(yesterday()) assertMidnight(date) } private void assertMidnightOfToday(Date date) { assertThat(date).isNotNull() - assertDatesEqual(date, new Date()) + assertThat(date).isToday() assertMidnight(date) } From fad9082728de4c0d71d64d8d25d9e57349b76b1f Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Mon, 27 Jan 2020 23:46:59 +0000 Subject: [PATCH 10/14] refactor: use getters explicitly. This change is needed in order to simplify automated porting of tests. Part of 1246 --- .../web/feature/account/LegacyUserServiceImplTest.groovy | 7 ++++--- .../web/feature/image/LegacyImageServiceImplTest.groovy | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/test/groovy/ru/mystamps/web/feature/account/LegacyUserServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/account/LegacyUserServiceImplTest.groovy index 7c1b17f876..9f491156f0 100644 --- a/src/test/groovy/ru/mystamps/web/feature/account/LegacyUserServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/account/LegacyUserServiceImplTest.groovy @@ -36,18 +36,19 @@ class LegacyUserServiceImplTest extends Specification { private UserService service private ActivateAccountForm activationForm + @SuppressWarnings('UnnecessaryGetter') def setup() { AddUserDbDto user = TestObjects.createAddUserDbDto() - encoder.encode(_ as String) >> user.hash + encoder.encode(_ as String) >> user.getHash() UsersActivationDto activation = TestObjects.createUsersActivationDto() usersActivationService.findByActivationKey(_ as String) >> activation activationForm = new ActivateAccountForm() - activationForm.setLogin(user.login) + activationForm.setLogin(user.getLogin()) activationForm.setPassword(TestObjects.TEST_PASSWORD) - activationForm.setName(user.name) + activationForm.setName(user.getName()) activationForm.setActivationKey(TestObjects.TEST_ACTIVATION_KEY) service = new UserServiceImpl( diff --git a/src/test/groovy/ru/mystamps/web/feature/image/LegacyImageServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/image/LegacyImageServiceImplTest.groovy index 9487020ada..a8651dec0b 100644 --- a/src/test/groovy/ru/mystamps/web/feature/image/LegacyImageServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/image/LegacyImageServiceImplTest.groovy @@ -40,10 +40,11 @@ class LegacyImageServiceImplTest extends Specification { imageDao ) + @SuppressWarnings('UnnecessaryGetter') def setup() { - multipartFile.size >> 1024L - multipartFile.contentType >> 'image/png' - multipartFile.originalFilename >> 'super-image.png' + multipartFile.getSize() >> 1024L + multipartFile.getContentType() >> 'image/png' + multipartFile.getOriginalFilename() >> 'super-image.png' imageDao.add(_ as String, _ as String) >> 17 } From 1b23a09a083d7cfbfd389366f626e162bd367bf4 Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Mon, 27 Jan 2020 23:49:08 +0000 Subject: [PATCH 11/14] refactor: make a constant be accessible in other packages. We use it in ru.mystamps.web.feature.account.LegacyUserServiceImplTest and it's not clear how it worked before. This change is needed in order to simplify automated porting of tests. Part of 1246 --- src/test/java/ru/mystamps/web/service/TestObjects.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/java/ru/mystamps/web/service/TestObjects.java b/src/test/java/ru/mystamps/web/service/TestObjects.java index 780168ff54..ae8562c7bd 100644 --- a/src/test/java/ru/mystamps/web/service/TestObjects.java +++ b/src/test/java/ru/mystamps/web/service/TestObjects.java @@ -71,8 +71,7 @@ public final class TestObjects { public static final String TEST_EMAIL = "test@example.org"; public static final String TEST_ACTIVATION_KEY = "1234567890"; - - protected static final String TEST_PASSWORD = "secret"; + public static final String TEST_PASSWORD = "secret"; private static final String TEST_NAME = "Test Name"; private static final String TEST_URL = "test.example.org"; From f9c4357de33c08a765e6ac5b188710024a3b9679 Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Mon, 27 Jan 2020 23:50:59 +0000 Subject: [PATCH 12/14] refactor(TestObjects.createUsersActivationFullDto): remove an intermediate local variable. --- src/test/java/ru/mystamps/web/service/TestObjects.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/java/ru/mystamps/web/service/TestObjects.java b/src/test/java/ru/mystamps/web/service/TestObjects.java index ae8562c7bd..5006d3c803 100644 --- a/src/test/java/ru/mystamps/web/service/TestObjects.java +++ b/src/test/java/ru/mystamps/web/service/TestObjects.java @@ -86,12 +86,11 @@ private TestObjects() { } public static UsersActivationFullDto createUsersActivationFullDto() { - UsersActivationFullDto activation = new UsersActivationFullDto( + return new UsersActivationFullDto( TEST_ACTIVATION_KEY, TEST_EMAIL, Random.date() ); - return activation; } public static UsersActivationDto createUsersActivationDto() { From 65d62d85fc1957dc94b3497e42f5444a9614b9de Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Tue, 28 Jan 2020 00:02:38 +0000 Subject: [PATCH 13/14] refactor: add explicit import for Date class. This change is needed in order to simplify automated porting of tests. Part of 1246 --- .../mystamps/web/feature/site/LegacyCronServiceImplTest.groovy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy b/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy index 7d81230932..611615155b 100644 --- a/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy @@ -19,6 +19,9 @@ package ru.mystamps.web.feature.site import static org.assertj.core.util.DateUtil.yesterday +@SuppressWarnings('UnnecessaryGroovyImport') +import java.util.Date + import org.assertj.core.api.WithAssertions import org.slf4j.helpers.NOPLogger import ru.mystamps.web.feature.account.UserService From 0b5a2f7cb0512c956151871b2c7eaf3be1cb52bf Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Tue, 28 Jan 2020 23:42:33 +0000 Subject: [PATCH 14/14] refactor: don't call init() method on the interface that doesn't have it. This change is needed in order to simplify automated porting of tests. Part of 1246 --- .../image/LegacyDatabaseImagePersistenceStrategyTest.groovy | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/groovy/ru/mystamps/web/feature/image/LegacyDatabaseImagePersistenceStrategyTest.groovy b/src/test/groovy/ru/mystamps/web/feature/image/LegacyDatabaseImagePersistenceStrategyTest.groovy index db69425965..1c29c3c597 100644 --- a/src/test/groovy/ru/mystamps/web/feature/image/LegacyDatabaseImagePersistenceStrategyTest.groovy +++ b/src/test/groovy/ru/mystamps/web/feature/image/LegacyDatabaseImagePersistenceStrategyTest.groovy @@ -32,13 +32,15 @@ class LegacyDatabaseImagePersistenceStrategyTest extends Specification { private ImagePersistenceStrategy strategy def setup() { - strategy = new DatabaseImagePersistenceStrategy( + DatabaseImagePersistenceStrategy dbStrategy = new DatabaseImagePersistenceStrategy( NOPLogger.NOP_LOGGER, imageDataDao ) // init() does nothing except logging but by invoking it we're improving code coverage - strategy.init() + dbStrategy.init() + + strategy = dbStrategy } //