From 082e5655e791666a9b3cd2441dadf5458483d793 Mon Sep 17 00:00:00 2001 From: Yaroslav Lepenkin Date: Mon, 25 Jan 2016 20:16:57 +0300 Subject: [PATCH] extracted method --- .../testIntegration/SelectTestStep.java | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/java/execution/impl/src/com/intellij/testIntegration/SelectTestStep.java b/java/execution/impl/src/com/intellij/testIntegration/SelectTestStep.java index 0709edab77da..86634a11e095 100644 --- a/java/execution/impl/src/com/intellij/testIntegration/SelectTestStep.java +++ b/java/execution/impl/src/com/intellij/testIntegration/SelectTestStep.java @@ -67,18 +67,21 @@ public class SelectTestStep extends BaseListPopupStep { Set passedSuites = ContainerUtil.newHashSet(); Set otherSuites = ContainerUtil.newHashSet(); - for (Map.Entry item : records.entrySet()) { - String url = item.getKey(); - TestStateInfo.Magnitude magnitude = getMagnitude(item.getValue().magnitude); + List infos = getTestInfos(records.entrySet(), runner); + + for (TestInfo info : infos) { + String url = info.url; + TestStateInfo.Magnitude magnitude = info.magnitude; if (magnitude == null) continue; + switch (magnitude) { case COMPLETE_INDEX: - if (runner.isSuite(url)) { + if (info.isSuite) { passedSuites.add(url); } break; case PASSED_INDEX: - if (runner.isSuite(url)) { + if (info.isSuite) { passedSuites.add(url); } break; @@ -94,6 +97,19 @@ public class SelectTestStep extends BaseListPopupStep { return new TestGroup(failedTests, passedSuites, otherSuites); } + private static List getTestInfos(Set> entries, RecentTestRunner runner) { + List list = ContainerUtil.newSmartList(); + + for (Map.Entry item : entries) { + String url = item.getKey(); + TestStateStorage.Record record = item.getValue(); + TestStateInfo.Magnitude magnitude = getMagnitude(record.magnitude); + list.add(new TestInfo(url, magnitude, runner.isSuite(url))); + } + + return list; + } + private static TestStateInfo.Magnitude getMagnitude(int magnitude) { for (TestStateInfo.Magnitude m : TestStateInfo.Magnitude.values()) { if (m.getValue() == magnitude) { @@ -139,4 +155,17 @@ public class SelectTestStep extends BaseListPopupStep { this.otherTests = otherTests; } } + + private static class TestInfo { + private final boolean isSuite; + public String url; + public TestStateInfo.Magnitude magnitude; + + public TestInfo(String url, TestStateInfo.Magnitude magnitude, boolean isSuite) { + this.url = url; + this.magnitude = magnitude; + this.isSuite = isSuite; + } + } + }