From 046055dae19debf739bfde7f7c61c9cc4e3340d0 Mon Sep 17 00:00:00 2001 From: Darko Date: Tue, 29 Oct 2024 17:06:22 -0400 Subject: [PATCH] I18N-1324 - Update TextUnitSearcherParameters to support Builder pattern Updated TextUnitSearcherParameters to support Builder pattern in ThirdPartyTMSSmartling class --- .../thirdparty/ThirdPartyTMSSmartling.java | 173 +++++------ .../tm/search/TextUnitSearcherParameters.java | 270 ++++++++++++++++- .../ThirdPartyTMSSmartlingTest.java | 273 ++++++++++++++++++ .../TextUnitSearcherParametersTest.java | 225 +++++++++++++++ 4 files changed, 834 insertions(+), 107 deletions(-) create mode 100644 webapp/src/test/java/com/box/l10n/mojito/service/tm/search/TextUnitSearcherParametersTest.java diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyTMSSmartling.java b/webapp/src/main/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyTMSSmartling.java index 3270556c2..7f436a878 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyTMSSmartling.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyTMSSmartling.java @@ -35,7 +35,6 @@ import com.box.l10n.mojito.smartling.request.Bindings; import com.box.l10n.mojito.smartling.response.File; import com.box.l10n.mojito.smartling.response.StringInfo; -import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; @@ -89,7 +88,7 @@ public class ThirdPartyTMSSmartling implements ThirdPartyTMS { private final SmartlingClient smartlingClient; private final AssetPathAndTextUnitNameKeys assetPathAndTextUnitNameKeys; - private final TextUnitSearcher textUnitSearcher; + TextUnitSearcher textUnitSearcher; private final TextUnitBatchImporterService textUnitBatchImporterService; private final SmartlingResultProcessor resultProcessor; private final Integer batchSize; @@ -827,15 +826,15 @@ private Stream> partitionSingulars( String skipTextUnitsWithPattern, String skipAssetsWithPathPattern) { TextUnitSearcherParameters parameters = - baseParams( - repositoryId, - localeTag, - skipTextUnitsWithPattern, - skipAssetsWithPathPattern, - true, - true, - null); - parameters.setOrderByTextUnitID(true); + this.baseParams() + .repositoryId(repositoryId) + .localeTags(ImmutableList.of(localeTag)) + .skipTextUnitWithPattern(skipTextUnitsWithPattern) + .skipAssetPathWithPattern(skipAssetsWithPathPattern) + .pluralFormsFiltered(true) + .pluralFormsExcluded(true) + .isOrderedByTextUnitID(true) + .build(); return partitionedStream(parameters, textUnitSearcher::search); } @@ -846,16 +845,16 @@ private Stream> partitionSingulars( String skipAssetsWithPathPattern, String includeTextUnitWithPattern) { TextUnitSearcherParameters parameters = - baseParams( - repositoryId, - localeTag, - skipTextUnitsWithPattern, - skipAssetsWithPathPattern, - true, - true, - null, - includeTextUnitWithPattern); - parameters.setOrderByTextUnitID(true); + this.baseParams() + .repositoryId(repositoryId) + .localeTags(ImmutableList.of(localeTag)) + .skipTextUnitWithPattern(skipTextUnitsWithPattern) + .skipAssetPathWithPattern(skipAssetsWithPathPattern) + .pluralFormsFiltered(true) + .pluralFormsExcluded(true) + .includeTextUnitsWithPattern(includeTextUnitWithPattern) + .isOrderedByTextUnitID(true) + .build(); return partitionedStream(parameters, textUnitSearcher::search); } @@ -865,15 +864,16 @@ private Stream> partitionPlurals( String skipTextUnitsWithPattern, String skipAssetsWithPathPattern) { TextUnitSearcherParameters parameters = - baseParams( - repositoryId, - localeTag, - skipTextUnitsWithPattern, - skipAssetsWithPathPattern, - false, - false, - "%"); - parameters.setOrderByTextUnitID(true); + this.baseParams() + .repositoryId(repositoryId) + .localeTags(ImmutableList.of(localeTag)) + .skipTextUnitWithPattern(skipTextUnitsWithPattern) + .skipAssetPathWithPattern(skipAssetsWithPathPattern) + .pluralFormsFiltered(false) + .pluralFormsExcluded(false) + .pluralFormOther("%") + .isOrderedByTextUnitID(true) + .build(); return partitionedStream(parameters, textUnitSearcher::search); } @@ -898,17 +898,17 @@ private Stream> partitionPlurals( } TextUnitSearcherParameters parameters = - baseParams( - repositoryId, - localeTag, - skipTextUnitsWithPattern, - skipAssetsWithPathPattern, - false, - false, - "%", - includeTextUnitsWithPattern); - - parameters.setOrderByTextUnitID(true); + this.baseParams() + .repositoryId(repositoryId) + .localeTags(ImmutableList.of(localeTag)) + .skipTextUnitWithPattern(skipTextUnitsWithPattern) + .skipAssetPathWithPattern(skipAssetsWithPathPattern) + .pluralFormsFiltered(false) + .pluralFormsExcluded(false) + .pluralFormOther("%") + .includeTextUnitsWithPattern(includeTextUnitsWithPattern) + .isOrderedByTextUnitID(true) + .build(); return partitionedStream(parameters, searchFunction); } @@ -927,14 +927,14 @@ private Long singularCount( String skipAssetsWithPathPattern) { return textUnitSearcher .countTextUnitAndWordCount( - baseParams( - repositoryId, - localeTag, - skipTextUnitsWithPattern, - skipAssetsWithPathPattern, - true, - true, - null)) + this.baseParams() + .repositoryId(repositoryId) + .localeTags(ImmutableList.of(localeTag)) + .skipTextUnitWithPattern(skipTextUnitsWithPattern) + .skipAssetPathWithPattern(skipAssetsWithPathPattern) + .pluralFormsFiltered(true) + .pluralFormsExcluded(true) + .build()) .getTextUnitCount(); } @@ -945,66 +945,27 @@ private Long pluralCount( String skipAssetsWithPathPattern) { return textUnitSearcher .countTextUnitAndWordCount( - baseParams( - repositoryId, - localeTag, - skipTextUnitsWithPattern, - skipAssetsWithPathPattern, - false, - false, - "%")) + this.baseParams() + .repositoryId(repositoryId) + .localeTags(ImmutableList.of(localeTag)) + .skipTextUnitWithPattern(skipTextUnitsWithPattern) + .skipAssetPathWithPattern(skipAssetsWithPathPattern) + .pluralFormsFiltered(false) + .pluralFormsExcluded(false) + .pluralFormOther("%") + .build()) .getTextUnitCount(); } - private TextUnitSearcherParameters baseParams( - Long repositoryId, - String localeTag, - String skipTextUnitsWithPattern, - String skipAssetsWithPathPattern, - boolean pluralFormsFiltered, - boolean pluralFormsExcluded, - String pluralFormOther) { - TextUnitSearcherParameters result = new TextUnitSearcherParameters(); - result.setRepositoryIds(repositoryId); - result.setLocaleTags(ImmutableList.of(localeTag)); - result.setRootLocaleExcluded(false); - result.setDoNotTranslateFilter(false); - result.setSearchType(SearchType.ILIKE); - result.setStatusFilter(StatusFilter.TRANSLATED); - result.setUsedFilter(UsedFilter.USED); - result.setPluralFormsFiltered(pluralFormsFiltered); - result.setPluralFormsExcluded(pluralFormsExcluded); - result.setSkipTextUnitWithPattern(skipTextUnitsWithPattern); - result.setSkipAssetPathWithPattern(skipAssetsWithPathPattern); - result.setExcludeUnexpiredPendingMT(aiTranslationConfiguration.isEnabled()); - result.setAiTranslationExpiryDuration(aiTranslationConfiguration.getExpiryDuration()); - if (!Strings.isNullOrEmpty(pluralFormOther)) { - result.setPluralFormOther(pluralFormOther); - } - - return result; - } - - private TextUnitSearcherParameters baseParams( - Long repositoryId, - String localeTag, - String skipTextUnitsWithPattern, - String skipAssetsWithPathPattern, - boolean pluralFormsFiltered, - boolean pluralFormsExcluded, - String pluralFormOther, - String includeTextUnitsWithPattern) { - TextUnitSearcherParameters result = - baseParams( - repositoryId, - localeTag, - skipTextUnitsWithPattern, - skipAssetsWithPathPattern, - pluralFormsFiltered, - pluralFormsExcluded, - pluralFormOther); - result.setIncludeTextUnitsWithPattern(includeTextUnitsWithPattern); - return result; + private TextUnitSearcherParameters.Builder baseParams() { + return new TextUnitSearcherParameters.Builder() + .rootLocaleExcluded(false) + .doNotTranslateFilter(false) + .searchType(SearchType.ILIKE) + .statusFilter(StatusFilter.TRANSLATED) + .usedFilter(UsedFilter.USED) + .isExcludeUnexpiredPendingMT(aiTranslationConfiguration.isEnabled()) + .aiTranslationExpiryDuration(aiTranslationConfiguration.getExpiryDuration()); } /** diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/tm/search/TextUnitSearcherParameters.java b/webapp/src/main/java/com/box/l10n/mojito/service/tm/search/TextUnitSearcherParameters.java index ae3354a91..8825b48ba 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/tm/search/TextUnitSearcherParameters.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/tm/search/TextUnitSearcherParameters.java @@ -4,6 +4,7 @@ import java.time.Duration; import java.time.ZonedDateTime; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -38,7 +39,6 @@ public class TextUnitSearcherParameters { boolean forRootLocale = false; boolean rootLocaleExcluded = true; Boolean toBeFullyTranslatedFilter; - boolean untranslatedOrTranslationNeeded = false; boolean pluralFormsFiltered = true; boolean pluralFormsExcluded = false; @@ -346,4 +346,272 @@ public Duration getAiTranslationExpiryDuration() { public void setAiTranslationExpiryDuration(Duration aiTranslationExpiryDuration) { this.aiTranslationExpiryDuration = aiTranslationExpiryDuration; } + + public static class Builder { + private String name; + private String source; + private String target; + private String assetPath; + private String pluralFormOther; + private String locationUsage; + private SearchType searchType; + private List repositoryIds; + private List repositoryNames; + private List tmTextUnitIds; + private List localeTags; + private Long localeId; + private UsedFilter usedFilter; + private StatusFilter statusFilter; + private Integer offset; + private Integer limit; + private Long assetId; + private Long tmId; + private String md5; + private boolean forRootLocale; + private boolean rootLocaleExcluded = true; + private Boolean toBeFullyTranslatedFilter; + private boolean pluralFormsFiltered = true; + private boolean pluralFormsExcluded; + private boolean isOrderedByTextUnitID; + private Long pluralFormId; + private Boolean doNotTranslateFilter; + private ZonedDateTime tmTextUnitCreatedBefore; + private ZonedDateTime tmTextUnitCreatedAfter; + private Long branchId; + private String skipTextUnitWithPattern; + private String includeTextUnitsWithPattern; + private String skipAssetPathWithPattern; + private boolean isExcludeUnexpiredPendingMT; + private Duration aiTranslationExpiryDuration; + + public TextUnitSearcherParameters build() { + TextUnitSearcherParameters textUnitSearcherParameters = new TextUnitSearcherParameters(); + textUnitSearcherParameters.name = this.name; + textUnitSearcherParameters.source = this.source; + textUnitSearcherParameters.target = this.target; + textUnitSearcherParameters.assetPath = this.assetPath; + textUnitSearcherParameters.pluralFormOther = this.pluralFormOther; + textUnitSearcherParameters.locationUsage = this.locationUsage; + textUnitSearcherParameters.searchType = this.searchType; + textUnitSearcherParameters.repositoryIds = this.repositoryIds; + textUnitSearcherParameters.repositoryNames = this.repositoryNames; + textUnitSearcherParameters.tmTextUnitIds = this.tmTextUnitIds; + textUnitSearcherParameters.localeTags = this.localeTags; + textUnitSearcherParameters.localeId = this.localeId; + textUnitSearcherParameters.usedFilter = this.usedFilter; + textUnitSearcherParameters.statusFilter = this.statusFilter; + textUnitSearcherParameters.offset = this.offset; + textUnitSearcherParameters.limit = this.limit; + textUnitSearcherParameters.assetId = this.assetId; + textUnitSearcherParameters.tmId = this.tmId; + textUnitSearcherParameters.md5 = this.md5; + textUnitSearcherParameters.forRootLocale = this.forRootLocale; + textUnitSearcherParameters.rootLocaleExcluded = this.rootLocaleExcluded; + textUnitSearcherParameters.toBeFullyTranslatedFilter = this.toBeFullyTranslatedFilter; + textUnitSearcherParameters.pluralFormsFiltered = this.pluralFormsFiltered; + textUnitSearcherParameters.pluralFormsExcluded = this.pluralFormsExcluded; + textUnitSearcherParameters.isOrderedByTextUnitID = this.isOrderedByTextUnitID; + textUnitSearcherParameters.pluralFormId = this.pluralFormId; + textUnitSearcherParameters.doNotTranslateFilter = this.doNotTranslateFilter; + textUnitSearcherParameters.tmTextUnitCreatedBefore = this.tmTextUnitCreatedBefore; + textUnitSearcherParameters.tmTextUnitCreatedAfter = this.tmTextUnitCreatedAfter; + textUnitSearcherParameters.branchId = this.branchId; + textUnitSearcherParameters.skipTextUnitWithPattern = this.skipTextUnitWithPattern; + textUnitSearcherParameters.includeTextUnitsWithPattern = this.includeTextUnitsWithPattern; + textUnitSearcherParameters.skipAssetPathWithPattern = this.skipAssetPathWithPattern; + textUnitSearcherParameters.isExcludeUnexpiredPendingMT = this.isExcludeUnexpiredPendingMT; + textUnitSearcherParameters.aiTranslationExpiryDuration = this.aiTranslationExpiryDuration; + return textUnitSearcherParameters; + } + + public Builder name(String name) { + this.name = name; + return this; + } + + public Builder source(String source) { + this.source = NormalizationUtils.normalize(source); + return this; + } + + public Builder target(String target) { + this.target = NormalizationUtils.normalize(target); + return this; + } + + public Builder assetPath(String assetPath) { + this.assetPath = assetPath; + return this; + } + + public Builder pluralFormOther(String pluralFormOther) { + this.pluralFormOther = pluralFormOther; + return this; + } + + public Builder locationUsage(String locationUsage) { + this.locationUsage = locationUsage; + return this; + } + + public Builder searchType(SearchType searchType) { + this.searchType = searchType; + return this; + } + + public Builder repositoryId(Long repositoryId) { + this.repositoryIds = Collections.singletonList(repositoryId); + return this; + } + + public Builder repositoryIds(List repositoryIds) { + this.repositoryIds = repositoryIds; + return this; + } + + public Builder repositoryNames(List repositoryNames) { + this.repositoryNames = repositoryNames; + return this; + } + + public Builder tmTextUnitIds(List tmTextUnitIds) { + this.tmTextUnitIds = tmTextUnitIds; + return this; + } + + public Builder tmTextUnitIds(Long... tmTextUnitIds) { + List filtered = + Arrays.stream(tmTextUnitIds).filter(Objects::nonNull).collect(Collectors.toList()); + + if (!filtered.isEmpty()) { + this.tmTextUnitIds = filtered; + } + return this; + } + + public Builder localeTags(List localeTags) { + this.localeTags = localeTags; + return this; + } + + public Builder localeId(Long localeId) { + this.localeId = localeId; + return this; + } + + public Builder usedFilter(UsedFilter usedFilter) { + this.usedFilter = usedFilter; + return this; + } + + public Builder statusFilter(StatusFilter statusFilter) { + this.statusFilter = statusFilter; + return this; + } + + public Builder offset(Integer offset) { + this.offset = offset; + return this; + } + + public Builder limit(Integer limit) { + this.limit = limit; + return this; + } + + public Builder assetId(Long assetId) { + this.assetId = assetId; + return this; + } + + public Builder tmId(Long tmId) { + this.tmId = tmId; + return this; + } + + public Builder md5(String md5) { + this.md5 = md5; + return this; + } + + public Builder forRootLocale(boolean forRootLocale) { + this.forRootLocale = forRootLocale; + return this; + } + + public Builder rootLocaleExcluded(boolean rootLocaleExcluded) { + this.rootLocaleExcluded = rootLocaleExcluded; + return this; + } + + public Builder toBeFullyTranslatedFilter(Boolean toBeFullyTranslatedFilter) { + this.toBeFullyTranslatedFilter = toBeFullyTranslatedFilter; + return this; + } + + public Builder pluralFormsFiltered(boolean pluralFormsFiltered) { + this.pluralFormsFiltered = pluralFormsFiltered; + return this; + } + + public Builder pluralFormsExcluded(boolean pluralFormsExcluded) { + this.pluralFormsExcluded = pluralFormsExcluded; + return this; + } + + public Builder isOrderedByTextUnitID(boolean isOrderedByTextUnitID) { + this.isOrderedByTextUnitID = isOrderedByTextUnitID; + return this; + } + + public Builder pluralFormId(Long pluralFormId) { + this.pluralFormId = pluralFormId; + return this; + } + + public Builder doNotTranslateFilter(Boolean doNotTranslateFilter) { + this.doNotTranslateFilter = doNotTranslateFilter; + return this; + } + + public Builder tmTextUnitCreatedBefore(ZonedDateTime tmTextUnitCreatedBefore) { + this.tmTextUnitCreatedBefore = tmTextUnitCreatedBefore; + return this; + } + + public Builder tmTextUnitCreatedAfter(ZonedDateTime tmTextUnitCreatedAfter) { + this.tmTextUnitCreatedAfter = tmTextUnitCreatedAfter; + return this; + } + + public Builder branchId(Long branchId) { + this.branchId = branchId; + return this; + } + + public Builder skipTextUnitWithPattern(String skipTextUnitWithPattern) { + this.skipTextUnitWithPattern = skipTextUnitWithPattern; + return this; + } + + public Builder includeTextUnitsWithPattern(String includeTextUnitsWithPattern) { + this.includeTextUnitsWithPattern = includeTextUnitsWithPattern; + return this; + } + + public Builder skipAssetPathWithPattern(String skipAssetPathWithPattern) { + this.skipAssetPathWithPattern = skipAssetPathWithPattern; + return this; + } + + public Builder isExcludeUnexpiredPendingMT(boolean isExcludeUnexpiredPendingMT) { + this.isExcludeUnexpiredPendingMT = isExcludeUnexpiredPendingMT; + return this; + } + + public Builder aiTranslationExpiryDuration(Duration aiTranslationExpiryDuration) { + this.aiTranslationExpiryDuration = aiTranslationExpiryDuration; + return this; + } + } } diff --git a/webapp/src/test/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyTMSSmartlingTest.java b/webapp/src/test/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyTMSSmartlingTest.java index f819dd220..0d29583fa 100644 --- a/webapp/src/test/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyTMSSmartlingTest.java +++ b/webapp/src/test/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyTMSSmartlingTest.java @@ -53,10 +53,13 @@ import com.box.l10n.mojito.service.thirdparty.smartling.quartz.SmartlingPullTranslationsJobInput; import com.box.l10n.mojito.service.tm.TMService; import com.box.l10n.mojito.service.tm.importer.TextUnitBatchImporterService; +import com.box.l10n.mojito.service.tm.search.SearchType; import com.box.l10n.mojito.service.tm.search.StatusFilter; +import com.box.l10n.mojito.service.tm.search.TextUnitAndWordCount; import com.box.l10n.mojito.service.tm.search.TextUnitDTO; import com.box.l10n.mojito.service.tm.search.TextUnitSearcher; import com.box.l10n.mojito.service.tm.search.TextUnitSearcherParameters; +import com.box.l10n.mojito.service.tm.search.UsedFilter; import com.box.l10n.mojito.smartling.AssetPathAndTextUnitNameKeys; import com.box.l10n.mojito.smartling.SmartlingClient; import com.box.l10n.mojito.smartling.SmartlingClientException; @@ -169,6 +172,8 @@ public class ThirdPartyTMSSmartlingTest extends ServiceTestBase { @Captor ArgumentCaptor> quartzJobInfoCaptor; + @Captor ArgumentCaptor textUnitSearcherParametersCaptor; + ThirdPartyTMSSmartling tmsSmartling; AndroidStringDocumentMapper mapper; @@ -1692,6 +1697,274 @@ private List searchTextUnits(List ids) { return searcher.search(params); } + private void assertOtherParameters(TextUnitSearcherParameters textUnitSearcherParameters) { + assertThat(textUnitSearcherParameters.getName()).isNull(); + assertThat(textUnitSearcherParameters.getSource()).isNull(); + assertThat(textUnitSearcherParameters.getTarget()).isNull(); + assertThat(textUnitSearcherParameters.getAssetPath()).isNull(); + assertThat(textUnitSearcherParameters.getLocationUsage()).isNull(); + assertThat(textUnitSearcherParameters.getRepositoryNames()).isNull(); + assertThat(textUnitSearcherParameters.getTmTextUnitIds()).isNull(); + assertThat(textUnitSearcherParameters.getLocaleId()).isNull(); + assertThat(textUnitSearcherParameters.getOffset()).isNull(); + assertThat(textUnitSearcherParameters.getLimit()).isNull(); + assertThat(textUnitSearcherParameters.getAssetId()).isNull(); + assertThat(textUnitSearcherParameters.getTmId()).isNull(); + assertThat(textUnitSearcherParameters.getMd5()).isNull(); + assertThat(textUnitSearcherParameters.isForRootLocale()).isFalse(); + assertThat(textUnitSearcherParameters.getToBeFullyTranslatedFilter()).isNull(); + assertThat(textUnitSearcherParameters.getPluralFormId()).isNull(); + assertThat(textUnitSearcherParameters.getTmTextUnitCreatedBefore()).isNull(); + assertThat(textUnitSearcherParameters.getTmTextUnitCreatedAfter()).isNull(); + assertThat(textUnitSearcherParameters.getBranchId()).isNull(); + } + + @Test + public void testPushByVerifyingTextUnitSearcherParameters() + throws RepositoryNameAlreadyUsedException { + + List result; + Repository repository = + this.repositoryService.createRepository(this.testIdWatcher.getEntityName("batchRepo")); + + this.tmsSmartling.textUnitSearcher = Mockito.mock(TextUnitSearcher.class); + this.tmsSmartling.push( + repository, + "projectId", + "_", + "skipTextUnitsWithPattern", + "skipAssetsWithPathPattern", + Collections.emptyList()); + verify(this.tmsSmartling.textUnitSearcher, times(2)) + .search(this.textUnitSearcherParametersCaptor.capture()); + + List allTextUnitSearcherParameters = + this.textUnitSearcherParametersCaptor.getAllValues(); + TextUnitSearcherParameters textUnitSearcherParameters = + allTextUnitSearcherParameters.getFirst(); + + assertThat(allTextUnitSearcherParameters.size()).isEqualTo(2); + assertThat(textUnitSearcherParameters.getRepositoryIds()).hasSize(1); + assertThat(textUnitSearcherParameters.getRepositoryIds().getFirst()) + .isEqualTo(repository.getId()); + assertThat(textUnitSearcherParameters.getLocaleTags()).hasSize(1); + assertThat(textUnitSearcherParameters.getLocaleTags().getFirst()).isEqualTo("en"); + assertThat(textUnitSearcherParameters.getSkipTextUnitWithPattern()) + .isEqualTo("skipTextUnitsWithPattern"); + assertThat(textUnitSearcherParameters.getSkipAssetPathWithPattern()) + .isEqualTo("skipAssetsWithPathPattern"); + assertThat(textUnitSearcherParameters.isPluralFormsFiltered()).isTrue(); + assertThat(textUnitSearcherParameters.isPluralFormsExcluded()).isTrue(); + assertThat(textUnitSearcherParameters.getPluralFormOther()).isNull(); + assertThat(textUnitSearcherParameters.isOrderedByTextUnitID()).isTrue(); + + assertThat(textUnitSearcherParameters.isRootLocaleExcluded()).isFalse(); + assertThat(textUnitSearcherParameters.getDoNotTranslateFilter()).isFalse(); + assertThat(textUnitSearcherParameters.getSearchType()).isEqualTo(SearchType.ILIKE); + assertThat(textUnitSearcherParameters.getStatusFilter()).isEqualTo(StatusFilter.TRANSLATED); + assertThat(textUnitSearcherParameters.getUsedFilter()).isEqualTo(UsedFilter.USED); + assertThat(textUnitSearcherParameters.isExcludeUnexpiredPendingMT()).isFalse(); + assertThat(textUnitSearcherParameters.getAiTranslationExpiryDuration()) + .isEqualTo(Duration.ZERO); + assertThat(textUnitSearcherParameters.getIncludeTextUnitsWithPattern()).isNull(); + this.assertOtherParameters(textUnitSearcherParameters); + + textUnitSearcherParameters = allTextUnitSearcherParameters.get(1); + + assertThat(textUnitSearcherParameters.getRepositoryIds()).hasSize(1); + assertThat(textUnitSearcherParameters.getRepositoryIds().getFirst()) + .isEqualTo(repository.getId()); + assertThat(textUnitSearcherParameters.getLocaleTags()).hasSize(1); + assertThat(textUnitSearcherParameters.getLocaleTags().getFirst()).isEqualTo("en"); + assertThat(textUnitSearcherParameters.getSkipTextUnitWithPattern()) + .isEqualTo("skipTextUnitsWithPattern"); + assertThat(textUnitSearcherParameters.getSkipAssetPathWithPattern()) + .isEqualTo("skipAssetsWithPathPattern"); + assertThat(textUnitSearcherParameters.isPluralFormsFiltered()).isFalse(); + assertThat(textUnitSearcherParameters.isPluralFormsExcluded()).isFalse(); + assertThat(textUnitSearcherParameters.getPluralFormOther()).isEqualTo("%"); + assertThat(textUnitSearcherParameters.isOrderedByTextUnitID()).isTrue(); + + assertThat(textUnitSearcherParameters.isRootLocaleExcluded()).isFalse(); + assertThat(textUnitSearcherParameters.getDoNotTranslateFilter()).isFalse(); + assertThat(textUnitSearcherParameters.getSearchType()).isEqualTo(SearchType.ILIKE); + assertThat(textUnitSearcherParameters.getStatusFilter()).isEqualTo(StatusFilter.TRANSLATED); + assertThat(textUnitSearcherParameters.getUsedFilter()).isEqualTo(UsedFilter.USED); + assertThat(textUnitSearcherParameters.isExcludeUnexpiredPendingMT()).isFalse(); + assertThat(textUnitSearcherParameters.getAiTranslationExpiryDuration()) + .isEqualTo(Duration.ZERO); + assertThat(textUnitSearcherParameters.getIncludeTextUnitsWithPattern()).isNull(); + this.assertOtherParameters(textUnitSearcherParameters); + } + + @Test + public void testPushTranslationsByVerifyingTextUnitSearcherParameters() + throws RepositoryLocaleCreationException, RepositoryNameAlreadyUsedException { + Repository repository = + this.repositoryService.createRepository(this.testIdWatcher.getEntityName("batchRepo")); + Locale frCA = this.localeService.findByBcp47Tag("fr-CA"); + this.repositoryService.addRepositoryLocale(repository, frCA.getBcp47Tag()); + + this.tmsSmartling.textUnitSearcher = Mockito.mock(TextUnitSearcher.class); + this.tmsSmartling.pushTranslations( + repository, + "projectId", + this.pluralSep, + ImmutableMap.of(), + "skipTextUnitsWithPattern", + "skipAssetsWithPathPattern", + "includeTextUnitsWithPattern", + ImmutableList.of()); + + verify(this.tmsSmartling.textUnitSearcher, times(2)) + .search(this.textUnitSearcherParametersCaptor.capture()); + + List allTextUnitSearcherParameters = + this.textUnitSearcherParametersCaptor.getAllValues(); + TextUnitSearcherParameters textUnitSearcherParameters = + allTextUnitSearcherParameters.getFirst(); + + assertThat(allTextUnitSearcherParameters.size()).isEqualTo(2); + assertThat(textUnitSearcherParameters.getRepositoryIds()).hasSize(1); + assertThat(textUnitSearcherParameters.getRepositoryIds().getFirst()) + .isEqualTo(repository.getId()); + assertThat(textUnitSearcherParameters.getLocaleTags()).hasSize(1); + assertThat(textUnitSearcherParameters.getLocaleTags().getFirst()).isEqualTo("fr-CA"); + assertThat(textUnitSearcherParameters.getSkipTextUnitWithPattern()) + .isEqualTo("skipTextUnitsWithPattern"); + assertThat(textUnitSearcherParameters.getSkipAssetPathWithPattern()) + .isEqualTo("skipAssetsWithPathPattern"); + assertThat(textUnitSearcherParameters.isPluralFormsFiltered()).isTrue(); + assertThat(textUnitSearcherParameters.isPluralFormsExcluded()).isTrue(); + assertThat(textUnitSearcherParameters.getPluralFormOther()).isNull(); + assertThat(textUnitSearcherParameters.getIncludeTextUnitsWithPattern()) + .isEqualTo("includeTextUnitsWithPattern"); + assertThat(textUnitSearcherParameters.isOrderedByTextUnitID()).isTrue(); + + assertThat(textUnitSearcherParameters.isRootLocaleExcluded()).isFalse(); + assertThat(textUnitSearcherParameters.getDoNotTranslateFilter()).isFalse(); + assertThat(textUnitSearcherParameters.getSearchType()).isEqualTo(SearchType.ILIKE); + assertThat(textUnitSearcherParameters.getStatusFilter()).isEqualTo(StatusFilter.TRANSLATED); + assertThat(textUnitSearcherParameters.getUsedFilter()).isEqualTo(UsedFilter.USED); + assertThat(textUnitSearcherParameters.isExcludeUnexpiredPendingMT()).isFalse(); + assertThat(textUnitSearcherParameters.getAiTranslationExpiryDuration()) + .isEqualTo(Duration.ZERO); + this.assertOtherParameters(textUnitSearcherParameters); + + textUnitSearcherParameters = allTextUnitSearcherParameters.get(1); + + assertThat(textUnitSearcherParameters.getRepositoryIds()).hasSize(1); + assertThat(textUnitSearcherParameters.getRepositoryIds().getFirst()) + .isEqualTo(repository.getId()); + assertThat(textUnitSearcherParameters.getLocaleTags()).hasSize(1); + assertThat(textUnitSearcherParameters.getLocaleTags().getFirst()).isEqualTo("fr-CA"); + assertThat(textUnitSearcherParameters.getSkipTextUnitWithPattern()) + .isEqualTo("skipTextUnitsWithPattern"); + assertThat(textUnitSearcherParameters.getSkipAssetPathWithPattern()) + .isEqualTo("skipAssetsWithPathPattern"); + assertThat(textUnitSearcherParameters.isPluralFormsFiltered()).isFalse(); + assertThat(textUnitSearcherParameters.isPluralFormsExcluded()).isFalse(); + assertThat(textUnitSearcherParameters.getPluralFormOther()).isEqualTo("%"); + assertThat(textUnitSearcherParameters.getIncludeTextUnitsWithPattern()) + .isEqualTo("includeTextUnitsWithPattern"); + assertThat(textUnitSearcherParameters.isOrderedByTextUnitID()).isTrue(); + + assertThat(textUnitSearcherParameters.isRootLocaleExcluded()).isFalse(); + assertThat(textUnitSearcherParameters.getDoNotTranslateFilter()).isFalse(); + assertThat(textUnitSearcherParameters.getSearchType()).isEqualTo(SearchType.ILIKE); + assertThat(textUnitSearcherParameters.getStatusFilter()).isEqualTo(StatusFilter.TRANSLATED); + assertThat(textUnitSearcherParameters.getUsedFilter()).isEqualTo(UsedFilter.USED); + assertThat(textUnitSearcherParameters.isExcludeUnexpiredPendingMT()).isFalse(); + assertThat(textUnitSearcherParameters.getAiTranslationExpiryDuration()) + .isEqualTo(Duration.ZERO); + this.assertOtherParameters(textUnitSearcherParameters); + } + + @Test + public void testPullByVerifyingTextUnitSearcherParameters() + throws RepositoryLocaleCreationException { + ThirdPartyServiceTestData testData = new ThirdPartyServiceTestData(this.testIdWatcher); + Repository repository = testData.repository; + Map localeMapping = Collections.emptyMap(); + + TextUnitSearcher textUnitSearcherMock = Mockito.mock(TextUnitSearcher.class); + when(textUnitSearcherMock.countTextUnitAndWordCount(any())) + .thenReturn(new TextUnitAndWordCount(2, 4)); + this.tmsSmartling.textUnitSearcher = textUnitSearcherMock; + + this.tmsSmartling.pull( + repository, + "projectId", + pluralSep, + localeMapping, + "skipTextUnitsWithPattern", + "skipAssetsWithPathPattern", + Collections.emptyList(), + DEFAULT_SCHEDULER_NAME, + parent); + + verify(textUnitSearcherMock, times(2)) + .countTextUnitAndWordCount(this.textUnitSearcherParametersCaptor.capture()); + + List allTextUnitSearcherParameters = + this.textUnitSearcherParametersCaptor.getAllValues(); + TextUnitSearcherParameters textUnitSearcherParameters = + allTextUnitSearcherParameters.getFirst(); + + assertThat(allTextUnitSearcherParameters.size()).isEqualTo(2); + assertThat(textUnitSearcherParameters.getRepositoryIds()).hasSize(1); + assertThat(textUnitSearcherParameters.getRepositoryIds().getFirst()) + .isEqualTo(repository.getId()); + assertThat(textUnitSearcherParameters.getLocaleTags()).hasSize(1); + assertThat(textUnitSearcherParameters.getLocaleTags().getFirst()).isEqualTo("en"); + assertThat(textUnitSearcherParameters.getSkipTextUnitWithPattern()) + .isEqualTo("skipTextUnitsWithPattern"); + assertThat(textUnitSearcherParameters.getSkipAssetPathWithPattern()) + .isEqualTo("skipAssetsWithPathPattern"); + assertThat(textUnitSearcherParameters.isPluralFormsFiltered()).isTrue(); + assertThat(textUnitSearcherParameters.isPluralFormsExcluded()).isTrue(); + + assertThat(textUnitSearcherParameters.getPluralFormOther()).isNull(); + assertThat(textUnitSearcherParameters.getIncludeTextUnitsWithPattern()).isNull(); + assertThat(textUnitSearcherParameters.isOrderedByTextUnitID()).isFalse(); + assertThat(textUnitSearcherParameters.isRootLocaleExcluded()).isFalse(); + assertThat(textUnitSearcherParameters.getDoNotTranslateFilter()).isFalse(); + assertThat(textUnitSearcherParameters.getSearchType()).isEqualTo(SearchType.ILIKE); + assertThat(textUnitSearcherParameters.getStatusFilter()).isEqualTo(StatusFilter.TRANSLATED); + assertThat(textUnitSearcherParameters.getUsedFilter()).isEqualTo(UsedFilter.USED); + assertThat(textUnitSearcherParameters.isExcludeUnexpiredPendingMT()).isFalse(); + assertThat(textUnitSearcherParameters.getAiTranslationExpiryDuration()) + .isEqualTo(Duration.ZERO); + this.assertOtherParameters(textUnitSearcherParameters); + + textUnitSearcherParameters = allTextUnitSearcherParameters.get(1); + + assertThat(textUnitSearcherParameters.getRepositoryIds()).hasSize(1); + assertThat(textUnitSearcherParameters.getRepositoryIds().getFirst()) + .isEqualTo(repository.getId()); + assertThat(textUnitSearcherParameters.getLocaleTags()).hasSize(1); + assertThat(textUnitSearcherParameters.getLocaleTags().getFirst()).isEqualTo("en"); + assertThat(textUnitSearcherParameters.getSkipTextUnitWithPattern()) + .isEqualTo("skipTextUnitsWithPattern"); + assertThat(textUnitSearcherParameters.getSkipAssetPathWithPattern()) + .isEqualTo("skipAssetsWithPathPattern"); + assertThat(textUnitSearcherParameters.isPluralFormsFiltered()).isFalse(); + assertThat(textUnitSearcherParameters.isPluralFormsExcluded()).isFalse(); + assertThat(textUnitSearcherParameters.getPluralFormOther()).isEqualTo("%"); + + assertThat(textUnitSearcherParameters.getIncludeTextUnitsWithPattern()).isNull(); + assertThat(textUnitSearcherParameters.isOrderedByTextUnitID()).isFalse(); + assertThat(textUnitSearcherParameters.isRootLocaleExcluded()).isFalse(); + assertThat(textUnitSearcherParameters.getDoNotTranslateFilter()).isFalse(); + assertThat(textUnitSearcherParameters.getSearchType()).isEqualTo(SearchType.ILIKE); + assertThat(textUnitSearcherParameters.getStatusFilter()).isEqualTo(StatusFilter.TRANSLATED); + assertThat(textUnitSearcherParameters.getUsedFilter()).isEqualTo(UsedFilter.USED); + assertThat(textUnitSearcherParameters.isExcludeUnexpiredPendingMT()).isFalse(); + assertThat(textUnitSearcherParameters.getAiTranslationExpiryDuration()) + .isEqualTo(Duration.ZERO); + this.assertOtherParameters(textUnitSearcherParameters); + } + public String singularFileName(Repository repository, long num) { return SmartlingFileUtils.getOutputSourceFile(num, repository.getName(), "singular"); } diff --git a/webapp/src/test/java/com/box/l10n/mojito/service/tm/search/TextUnitSearcherParametersTest.java b/webapp/src/test/java/com/box/l10n/mojito/service/tm/search/TextUnitSearcherParametersTest.java new file mode 100644 index 000000000..3d6efbf1e --- /dev/null +++ b/webapp/src/test/java/com/box/l10n/mojito/service/tm/search/TextUnitSearcherParametersTest.java @@ -0,0 +1,225 @@ +package com.box.l10n.mojito.service.tm.search; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.time.Duration; +import java.time.ZonedDateTime; +import java.util.Arrays; +import org.junit.Test; + +public class TextUnitSearcherParametersTest { + @Test + public void testBuilder() { + TextUnitSearcherParameters textUnitSearcherParameters = + new TextUnitSearcherParameters.Builder().build(); + assertThat(textUnitSearcherParameters.getName()).isNull(); + assertThat(textUnitSearcherParameters.getSource()).isNull(); + assertThat(textUnitSearcherParameters.getTarget()).isNull(); + assertThat(textUnitSearcherParameters.getAssetPath()).isNull(); + assertThat(textUnitSearcherParameters.getPluralFormOther()).isNull(); + assertThat(textUnitSearcherParameters.getLocationUsage()).isNull(); + assertThat(textUnitSearcherParameters.getSearchType()).isNull(); + assertThat(textUnitSearcherParameters.getRepositoryIds()).isNull(); + assertThat(textUnitSearcherParameters.getRepositoryNames()).isNull(); + assertThat(textUnitSearcherParameters.getTmTextUnitIds()).isNull(); + assertThat(textUnitSearcherParameters.getLocaleTags()).isNull(); + assertThat(textUnitSearcherParameters.getLocaleId()).isNull(); + assertThat(textUnitSearcherParameters.getUsedFilter()).isNull(); + assertThat(textUnitSearcherParameters.getStatusFilter()).isNull(); + assertThat(textUnitSearcherParameters.getOffset()).isNull(); + assertThat(textUnitSearcherParameters.getLimit()).isNull(); + assertThat(textUnitSearcherParameters.getAssetId()).isNull(); + assertThat(textUnitSearcherParameters.getTmId()).isNull(); + assertThat(textUnitSearcherParameters.getMd5()).isNull(); + assertThat(textUnitSearcherParameters.isForRootLocale()).isFalse(); + assertThat(textUnitSearcherParameters.isRootLocaleExcluded()).isTrue(); + assertThat(textUnitSearcherParameters.getToBeFullyTranslatedFilter()).isNull(); + assertThat(textUnitSearcherParameters.isPluralFormsFiltered()).isTrue(); + assertThat(textUnitSearcherParameters.isPluralFormsExcluded()).isFalse(); + assertThat(textUnitSearcherParameters.isOrderedByTextUnitID()).isFalse(); + assertThat(textUnitSearcherParameters.getPluralFormId()).isNull(); + assertThat(textUnitSearcherParameters.getDoNotTranslateFilter()).isNull(); + assertThat(textUnitSearcherParameters.getTmTextUnitCreatedBefore()).isNull(); + assertThat(textUnitSearcherParameters.getTmTextUnitCreatedAfter()).isNull(); + assertThat(textUnitSearcherParameters.getBranchId()).isNull(); + assertThat(textUnitSearcherParameters.getSkipTextUnitWithPattern()).isNull(); + assertThat(textUnitSearcherParameters.getIncludeTextUnitsWithPattern()).isNull(); + assertThat(textUnitSearcherParameters.getSkipAssetPathWithPattern()).isNull(); + assertThat(textUnitSearcherParameters.isExcludeUnexpiredPendingMT()).isFalse(); + assertThat(textUnitSearcherParameters.getAiTranslationExpiryDuration()).isNull(); + + ZonedDateTime now = ZonedDateTime.now(); + textUnitSearcherParameters = + new TextUnitSearcherParameters.Builder() + .name("testName") + .source("testSource") + .target("testTarget") + .assetPath("testAssetPath") + .pluralFormOther("testPluralFormOther") + .locationUsage("testLocationUsage") + .searchType(SearchType.CONTAINS) + .repositoryId(1L) + .repositoryNames(Arrays.asList("testRepository1", "testRepository2")) + .tmTextUnitIds(null, null, 2L, 3L) + .localeTags(Arrays.asList("ar-SA", "es-ES")) + .localeId(4L) + .usedFilter(UsedFilter.USED) + .statusFilter(StatusFilter.FOR_TRANSLATION) + .offset(10) + .limit(20) + .assetId(5L) + .tmId(6L) + .md5("md5") + .pluralFormId(7L) + .tmTextUnitCreatedBefore(now) + .tmTextUnitCreatedAfter(now.minusDays(2)) + .branchId(8L) + .skipTextUnitWithPattern("testSkipTextUnitWithPattern") + .includeTextUnitsWithPattern("testSkipTextUnitWithPattern") + .skipAssetPathWithPattern("testSkipAssetPathWithPattern") + .aiTranslationExpiryDuration(Duration.ofMillis(1000)) + .build(); + + assertThat(textUnitSearcherParameters.getName()).isEqualTo("testName"); + assertThat(textUnitSearcherParameters.getSource()).isEqualTo("testSource"); + assertThat(textUnitSearcherParameters.getTarget()).isEqualTo("testTarget"); + assertThat(textUnitSearcherParameters.getAssetPath()).isEqualTo("testAssetPath"); + assertThat(textUnitSearcherParameters.getPluralFormOther()).isEqualTo("testPluralFormOther"); + assertThat(textUnitSearcherParameters.getLocationUsage()).isEqualTo("testLocationUsage"); + assertThat(textUnitSearcherParameters.getSearchType()).isEqualTo(SearchType.CONTAINS); + assertThat(textUnitSearcherParameters.getRepositoryIds().getFirst()).isEqualTo(1L); + assertThat(textUnitSearcherParameters.getRepositoryNames().getFirst()) + .isEqualTo("testRepository1"); + assertThat(textUnitSearcherParameters.getRepositoryNames().get(1)).isEqualTo("testRepository2"); + assertThat(textUnitSearcherParameters.getTmTextUnitIds().getFirst()).isEqualTo(2L); + assertThat(textUnitSearcherParameters.getTmTextUnitIds().get(1)).isEqualTo(3L); + assertThat(textUnitSearcherParameters.getLocaleTags().getFirst()).isEqualTo("ar-SA"); + assertThat(textUnitSearcherParameters.getLocaleTags().get(1)).isEqualTo("es-ES"); + assertThat(textUnitSearcherParameters.getLocaleId()).isEqualTo(4L); + assertThat(textUnitSearcherParameters.getUsedFilter()).isEqualTo(UsedFilter.USED); + assertThat(textUnitSearcherParameters.getStatusFilter()) + .isEqualTo(StatusFilter.FOR_TRANSLATION); + assertThat(textUnitSearcherParameters.getOffset()).isEqualTo(10); + assertThat(textUnitSearcherParameters.getLimit()).isEqualTo(20); + assertThat(textUnitSearcherParameters.getAssetId()).isEqualTo(5L); + assertThat(textUnitSearcherParameters.getTmId()).isEqualTo(6L); + assertThat(textUnitSearcherParameters.getMd5()).isEqualTo("md5"); + assertThat(textUnitSearcherParameters.getPluralFormId()).isEqualTo(7L); + assertThat(textUnitSearcherParameters.getTmTextUnitCreatedBefore()).isEqualTo(now); + assertThat(textUnitSearcherParameters.getTmTextUnitCreatedAfter()).isEqualTo(now.minusDays(2)); + assertThat(textUnitSearcherParameters.getBranchId()).isEqualTo(8L); + assertThat(textUnitSearcherParameters.getSkipTextUnitWithPattern()) + .isEqualTo("testSkipTextUnitWithPattern"); + assertThat(textUnitSearcherParameters.getIncludeTextUnitsWithPattern()) + .isEqualTo("testSkipTextUnitWithPattern"); + assertThat(textUnitSearcherParameters.getSkipAssetPathWithPattern()) + .isEqualTo("testSkipAssetPathWithPattern"); + assertThat(textUnitSearcherParameters.getAiTranslationExpiryDuration()) + .isEqualTo(Duration.ofMillis(1000)); + + assertThat(textUnitSearcherParameters.isForRootLocale()).isFalse(); + assertThat(textUnitSearcherParameters.isRootLocaleExcluded()).isTrue(); + assertThat(textUnitSearcherParameters.getToBeFullyTranslatedFilter()).isNull(); + assertThat(textUnitSearcherParameters.isPluralFormsFiltered()).isTrue(); + assertThat(textUnitSearcherParameters.isPluralFormsExcluded()).isFalse(); + assertThat(textUnitSearcherParameters.isOrderedByTextUnitID()).isFalse(); + assertThat(textUnitSearcherParameters.getDoNotTranslateFilter()).isNull(); + assertThat(textUnitSearcherParameters.isExcludeUnexpiredPendingMT()).isFalse(); + + textUnitSearcherParameters = + new TextUnitSearcherParameters.Builder().forRootLocale(true).build(); + + assertThat(textUnitSearcherParameters.isForRootLocale()).isTrue(); + assertThat(textUnitSearcherParameters.isRootLocaleExcluded()).isTrue(); + assertThat(textUnitSearcherParameters.getToBeFullyTranslatedFilter()).isNull(); + assertThat(textUnitSearcherParameters.isPluralFormsFiltered()).isTrue(); + assertThat(textUnitSearcherParameters.isPluralFormsExcluded()).isFalse(); + assertThat(textUnitSearcherParameters.isOrderedByTextUnitID()).isFalse(); + assertThat(textUnitSearcherParameters.getDoNotTranslateFilter()).isNull(); + assertThat(textUnitSearcherParameters.isExcludeUnexpiredPendingMT()).isFalse(); + + textUnitSearcherParameters = + new TextUnitSearcherParameters.Builder().rootLocaleExcluded(false).build(); + + assertThat(textUnitSearcherParameters.isForRootLocale()).isFalse(); + assertThat(textUnitSearcherParameters.isRootLocaleExcluded()).isFalse(); + assertThat(textUnitSearcherParameters.getToBeFullyTranslatedFilter()).isNull(); + assertThat(textUnitSearcherParameters.isPluralFormsFiltered()).isTrue(); + assertThat(textUnitSearcherParameters.isPluralFormsExcluded()).isFalse(); + assertThat(textUnitSearcherParameters.isOrderedByTextUnitID()).isFalse(); + assertThat(textUnitSearcherParameters.getDoNotTranslateFilter()).isNull(); + assertThat(textUnitSearcherParameters.isExcludeUnexpiredPendingMT()).isFalse(); + + textUnitSearcherParameters = + new TextUnitSearcherParameters.Builder().toBeFullyTranslatedFilter(true).build(); + + assertThat(textUnitSearcherParameters.isForRootLocale()).isFalse(); + assertThat(textUnitSearcherParameters.isRootLocaleExcluded()).isTrue(); + assertThat(textUnitSearcherParameters.getToBeFullyTranslatedFilter()).isTrue(); + assertThat(textUnitSearcherParameters.isPluralFormsFiltered()).isTrue(); + assertThat(textUnitSearcherParameters.isPluralFormsExcluded()).isFalse(); + assertThat(textUnitSearcherParameters.isOrderedByTextUnitID()).isFalse(); + assertThat(textUnitSearcherParameters.getDoNotTranslateFilter()).isNull(); + assertThat(textUnitSearcherParameters.isExcludeUnexpiredPendingMT()).isFalse(); + + textUnitSearcherParameters = + new TextUnitSearcherParameters.Builder().pluralFormsFiltered(false).build(); + + assertThat(textUnitSearcherParameters.isForRootLocale()).isFalse(); + assertThat(textUnitSearcherParameters.isRootLocaleExcluded()).isTrue(); + assertThat(textUnitSearcherParameters.getToBeFullyTranslatedFilter()).isNull(); + assertThat(textUnitSearcherParameters.isPluralFormsFiltered()).isFalse(); + assertThat(textUnitSearcherParameters.isPluralFormsExcluded()).isFalse(); + assertThat(textUnitSearcherParameters.isOrderedByTextUnitID()).isFalse(); + assertThat(textUnitSearcherParameters.getDoNotTranslateFilter()).isNull(); + assertThat(textUnitSearcherParameters.isExcludeUnexpiredPendingMT()).isFalse(); + + textUnitSearcherParameters = + new TextUnitSearcherParameters.Builder().pluralFormsExcluded(true).build(); + + assertThat(textUnitSearcherParameters.isForRootLocale()).isFalse(); + assertThat(textUnitSearcherParameters.isRootLocaleExcluded()).isTrue(); + assertThat(textUnitSearcherParameters.getToBeFullyTranslatedFilter()).isNull(); + assertThat(textUnitSearcherParameters.isPluralFormsFiltered()).isTrue(); + assertThat(textUnitSearcherParameters.isPluralFormsExcluded()).isTrue(); + assertThat(textUnitSearcherParameters.isOrderedByTextUnitID()).isFalse(); + assertThat(textUnitSearcherParameters.getDoNotTranslateFilter()).isNull(); + assertThat(textUnitSearcherParameters.isExcludeUnexpiredPendingMT()).isFalse(); + + textUnitSearcherParameters = + new TextUnitSearcherParameters.Builder().isOrderedByTextUnitID(true).build(); + + assertThat(textUnitSearcherParameters.isForRootLocale()).isFalse(); + assertThat(textUnitSearcherParameters.isRootLocaleExcluded()).isTrue(); + assertThat(textUnitSearcherParameters.getToBeFullyTranslatedFilter()).isNull(); + assertThat(textUnitSearcherParameters.isPluralFormsFiltered()).isTrue(); + assertThat(textUnitSearcherParameters.isPluralFormsExcluded()).isFalse(); + assertThat(textUnitSearcherParameters.isOrderedByTextUnitID()).isTrue(); + assertThat(textUnitSearcherParameters.getDoNotTranslateFilter()).isNull(); + assertThat(textUnitSearcherParameters.isExcludeUnexpiredPendingMT()).isFalse(); + + textUnitSearcherParameters = + new TextUnitSearcherParameters.Builder().doNotTranslateFilter(true).build(); + + assertThat(textUnitSearcherParameters.isForRootLocale()).isFalse(); + assertThat(textUnitSearcherParameters.isRootLocaleExcluded()).isTrue(); + assertThat(textUnitSearcherParameters.getToBeFullyTranslatedFilter()).isNull(); + assertThat(textUnitSearcherParameters.isPluralFormsFiltered()).isTrue(); + assertThat(textUnitSearcherParameters.isPluralFormsExcluded()).isFalse(); + assertThat(textUnitSearcherParameters.isOrderedByTextUnitID()).isFalse(); + assertThat(textUnitSearcherParameters.getDoNotTranslateFilter()).isTrue(); + assertThat(textUnitSearcherParameters.isExcludeUnexpiredPendingMT()).isFalse(); + + textUnitSearcherParameters = + new TextUnitSearcherParameters.Builder().isExcludeUnexpiredPendingMT(true).build(); + + assertThat(textUnitSearcherParameters.isForRootLocale()).isFalse(); + assertThat(textUnitSearcherParameters.isRootLocaleExcluded()).isTrue(); + assertThat(textUnitSearcherParameters.getToBeFullyTranslatedFilter()).isNull(); + assertThat(textUnitSearcherParameters.isPluralFormsFiltered()).isTrue(); + assertThat(textUnitSearcherParameters.isPluralFormsExcluded()).isFalse(); + assertThat(textUnitSearcherParameters.isOrderedByTextUnitID()).isFalse(); + assertThat(textUnitSearcherParameters.getDoNotTranslateFilter()).isNull(); + assertThat(textUnitSearcherParameters.isExcludeUnexpiredPendingMT()).isTrue(); + } +}