Source:
<code>private Map<String, Map<String, String>> createPartitionConfig(List<String> taskStates, List<String> expectedTaskEndingStates) throws Exception { Map<String, Map<String, String>> targetPartitionConfigs = new HashMap<>(); boolean isExternalViewCreated = TestHelper.verify(() -> { ExternalView externalView = _manager.getClusterManagmentTool().getResourceExternalView(CLUSTER_NAME, DB_NAME); return (externalView != null); }, TestHelper.WAIT_DURATION); <START> Assert.assertTrue(isExternalViewCreated); <END> ExternalView externalView = _manager.getClusterManagmentTool().getResourceExternalView(CLUSTER_NAME, DB_NAME); Set<String> partitionSet = externalView.getPartitionSet(); if (taskStates.size() != partitionSet.size()) { throw new IllegalArgumentException( "Input size does not match number of partitions for target resource: " + DB_NAME); } int i = 0; for (String partition : partitionSet) { Map<String, String> config = new HashMap<>(); if (taskStates.get(i).equals(TaskPartitionState.COMPLETED.name())) { config.put(MockTask.TASK_RESULT_STATUS, TaskResult.Status.COMPLETED.name()); } else if (taskStates.get(i).equals(TaskPartitionState.TASK_ERROR.name())) { config.put(MockTask.TASK_RESULT_STATUS, TaskResult.Status.FAILED.name()); } else if (taskStates.get(i).equals(TaskPartitionState.TASK_ABORTED.name())) { config.put(MockTask.TASK_RESULT_STATUS, TaskResult.Status.FATAL_FAILED.name()); } else if (taskStates.get(i).equals(TaskPartitionState.RUNNING.name())) { config.put(MockTask.JOB_DELAY, "99999999"); } else { throw new IllegalArgumentException("Invalid taskStates input: " + taskStates.get(i)); } config.put(EXPECTED_ENDING_STATE, expectedTaskEndingStates.get(i)); targetPartitionConfigs.put(partition, config); i++; } return targetPartitionConfigs; }</code><technical_language>Nit, I do assertTrue(TestHelper.verify()); get rid of temp boolean isExternalViewCreated var minimize variable scope. for usages</technical_language>

Target:
private Map<String, Map<String, String>> createPartitionConfig(List<String> taskStates, List<String> expectedTaskEndingStates) throws Exception { Map<String, Map<String, String>> targetPartitionConfigs = new HashMap<>(); Assert.assertTrue(TestHelper.verify(() -> { ExternalView externalView = _manager.getClusterManagmentTool().getResourceExternalView(CLUSTER_NAME, DB_NAME); return externalView != null; }, TestHelper.WAIT_DURATION)); ExternalView externalView = _manager.getClusterManagmentTool().getResourceExternalView(CLUSTER_NAME, DB_NAME); Set<String> partitionSet = externalView.getPartitionSet(); if (taskStates.size() != partitionSet.size()) { throw new IllegalArgumentException( "Input size does not match number of partitions for target resource: " + DB_NAME); } int i = 0; for (String partition : partitionSet) { Map<String, String> config = new HashMap<>(); if (taskStates.get(i).equals(TaskPartitionState.COMPLETED.name())) { config.put(MockTask.TASK_RESULT_STATUS, TaskResult.Status.COMPLETED.name()); } else if (taskStates.get(i).equals(TaskPartitionState.TASK_ERROR.name())) { config.put(MockTask.TASK_RESULT_STATUS, TaskResult.Status.FAILED.name()); } else if (taskStates.get(i).equals(TaskPartitionState.TASK_ABORTED.name())) { config.put(MockTask.TASK_RESULT_STATUS, TaskResult.Status.FATAL_FAILED.name()); } else if (taskStates.get(i).equals(TaskPartitionState.RUNNING.name())) { config.put(MockTask.JOB_DELAY, "99999999"); } else { throw new IllegalArgumentException("Invalid taskStates input: " + taskStates.get(i)); } config.put(EXPECTED_ENDING_STATE, expectedTaskEndingStates.get(i)); targetPartitionConfigs.put(partition, config); i++; } return targetPartitionConfigs; }