Source:
<code>public void restoreRedundancyWithIncludeRegionArgumentRestoresOnlyThoseRegions() { <START> List<String> regionNames = getAllRegionNames(); createAndPopulateRegions(regionNames); int numberOfServers = servers.size(); regionNames.forEach(region -> locator .waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + region, numberOfServers)); String regionToInclude = HIGH_REDUNDANCY_REGION_NAME; List<String> nonIncludedRegions = new ArrayList<>(regionNames); nonIncludedRegions.remove(regionToInclude); String command = new CommandStringBuilder(COMMAND_NAME) .addOption(INCLUDE_REGION, regionToInclude).getCommandString(); <END> CommandResultAssert commandResult = gfsh.executeAndAssertThat(command).statusIsSuccess() .hasNoSection(ZERO_REDUNDANCY_SECTION) .hasNoSection(UNDER_REDUNDANCY_SECTION) .doesNotContainOutput(nonIncludedRegions.toArray(new String[0])); InfoResultModelAssert summary = commandResult.hasInfoSection(SUMMARY_SECTION); summary.hasOutput().contains(ZERO_REDUNDANT_COPIES + 0); summary.hasOutput().contains(PARTIALLY_SATISFIED_REDUNDANCY + 0); summary.hasOutput().contains(FULLY_SATISFIED_REDUNDANCY + 1); InfoResultModelAssert satisfiedSection = commandResult.hasInfoSection(SATISFIED_REDUNDANCY_SECTION); satisfiedSection.hasHeader().isEqualTo(REDUNDANCY_SATISFIED_FOR_REGIONS); satisfiedSection.hasOutput().contains(regionToInclude); InfoResultModelAssert primariesSection = commandResult.hasInfoSection(PRIMARIES_INFO_SECTION); primariesSection.hasOutput().contains(PRIMARY_TRANSFERS_COMPLETED, PRIMARY_TRANSFER_TIME); int numberOfActiveServers = servers.size(); servers.get(0).invoke(() -> { for (String regionName : regionNames) { boolean shouldBeSatisfied = regionName.equals(regionToInclude); assertRedundancyStatusForRegion(regionName, shouldBeSatisfied); assertPrimariesBalanced(regionName, numberOfActiveServers, shouldBeSatisfied); } }); }</code><technical_language>This code block is duplicated test, extracted a separate method</technical_language>

Target:
public void restoreRedundancyWithIncludeRegionArgumentRestoresOnlyThoseRegions() { List<String> regionNames = getAllRegionNames(); createAndPopulateRegions(regionNames); int numberOfServers = servers.size(); regionNames.forEach(region -> locator .waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + region, numberOfServers)); String regionToInclude = HIGH_REDUNDANCY_REGION_NAME; List<String> nonIncludedRegions = new ArrayList<>(regionNames); nonIncludedRegions.remove(regionToInclude); String command = new CommandStringBuilder(RESTORE_REDUNDANCY) .addOption(REDUNDANCY_INCLUDE_REGION, regionToInclude).getCommandString(); CommandResultAssert commandResult = gfsh.executeAndAssertThat(command).statusIsSuccess() .doesNotContainOutput(nonIncludedRegions.toArray(new String[0])); verifyGfshOutput(commandResult, new ArrayList<>(), new ArrayList<>(), Collections.singletonList(regionToInclude)); int numberOfActiveServers = servers.size(); servers.get(0).invoke(() -> { for (String regionName : regionNames) { boolean shouldBeSatisfied = regionName.equals(regionToInclude); assertRedundancyStatusForRegion(regionName, shouldBeSatisfied); assertPrimariesBalanced(regionName, numberOfActiveServers, shouldBeSatisfied); } }); }