Skip to content

Commit

Permalink
Run formatter on EndToEndTest
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Kurait <[email protected]>
  • Loading branch information
AndreKurait committed Dec 10, 2024
1 parent 1b5c6a5 commit 406ad78
Showing 1 changed file with 29 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;

Expand All @@ -31,19 +34,19 @@ class EndToEndTest extends BaseMigrationTest {

private static Stream<Arguments> scenarios() {
return SupportedClusters.sources().stream()
.flatMap(sourceCluster -> {
// Determine applicable template types based on source version
List<TemplateType> templateTypes = Stream.concat(
Stream.of(TemplateType.Legacy),
(sourceCluster.getVersion().getMajor() >= 7
? Stream.of(TemplateType.Index, TemplateType.IndexAndComponent)
: Stream.empty()))
.collect(Collectors.toList());

return SupportedClusters.targets().stream()
.flatMap(targetCluster -> templateTypes.stream().flatMap(templateType -> Arrays.stream(TransferMedium.values())
.map(transferMedium -> Arguments.of(sourceCluster, targetCluster, transferMedium, templateType))));
});
.flatMap(sourceCluster -> {
// Determine applicable template types based on source version
List<TemplateType> templateTypes = Stream.concat(
Stream.of(TemplateType.Legacy),
(sourceCluster.getVersion().getMajor() >= 7
? Stream.of(TemplateType.Index, TemplateType.IndexAndComponent)
: Stream.empty()))
.collect(Collectors.toList());

return SupportedClusters.targets().stream()
.flatMap(targetCluster -> templateTypes.stream().flatMap(templateType -> Arrays.stream(TransferMedium.values())
.map(transferMedium -> Arguments.of(sourceCluster, targetCluster, transferMedium, templateType))));
});
}

@ParameterizedTest(name = "From version {0} to version {1}, Medium {2}, Command {3}, Template Type {4}")
Expand All @@ -53,8 +56,8 @@ void metadataCommand(SearchClusterContainer.ContainerVersion sourceVersion,
TransferMedium medium,
TemplateType templateType) {
try (
final var sourceCluster = new SearchClusterContainer(sourceVersion);
final var targetCluster = new SearchClusterContainer(targetVersion)
final var sourceCluster = new SearchClusterContainer(sourceVersion);
final var targetCluster = new SearchClusterContainer(targetVersion)
) {
this.sourceCluster = sourceCluster;
this.targetCluster = targetCluster;
Expand Down Expand Up @@ -146,29 +149,29 @@ private void verifyCommandResults(MigrationItemResult result,

var migratedItems = result.getItems();
assertThat(getNames(getSuccessfulResults(migratedItems.getIndexTemplates())),
containsInAnyOrder(testData.indexTemplateName));
containsInAnyOrder(testData.indexTemplateName));
assertThat(
getNames(getSuccessfulResults(migratedItems.getComponentTemplates())),
equalTo(templateType.equals(TemplateType.IndexAndComponent) ? List.of(testData.compoTemplateName) : List.of())
getNames(getSuccessfulResults(migratedItems.getComponentTemplates())),
equalTo(templateType.equals(TemplateType.IndexAndComponent) ? List.of(testData.compoTemplateName) : List.of())
);
assertThat(getNames(getSuccessfulResults(migratedItems.getIndexes())),
containsInAnyOrder(testData.blogIndexName, testData.movieIndexName));
containsInAnyOrder(testData.blogIndexName, testData.movieIndexName));
assertThat(getNames(getFailedResultsByType(migratedItems.getIndexes(), CreationResult.CreationFailureType.ALREADY_EXISTS)),
containsInAnyOrder(testData.indexThatAlreadyExists));
containsInAnyOrder(testData.indexThatAlreadyExists));
assertThat(getNames(getSuccessfulResults(migratedItems.getAliases())),
containsInAnyOrder(testData.aliasInTemplate, testData.aliasName));
containsInAnyOrder(testData.aliasInTemplate, testData.aliasName));
}

private List<CreationResult> getSuccessfulResults(List<CreationResult> results) {
return results.stream()
.filter(CreationResult::wasSuccessful)
.collect(Collectors.toList());
.filter(CreationResult::wasSuccessful)
.collect(Collectors.toList());
}

private List<CreationResult> getFailedResultsByType(List<CreationResult> results, CreationResult.CreationFailureType failureType) {
return results.stream()
.filter(r -> failureType.equals(r.getFailureType()))
.collect(Collectors.toList());
.filter(r -> failureType.equals(r.getFailureType()))
.collect(Collectors.toList());
}

private List<String> getNames(List<CreationResult> items) {
Expand Down

0 comments on commit 406ad78

Please sign in to comment.