Search in sources :

Example 6 with TestScenarioGroup

use of jp.ossc.nimbus.service.test.TestScenarioGroup in project nimbus by nimbus-org.

the class ScenarioTestView method updatehState.

// Contorollerから最新の情報を取得し画面に表示する
private void updatehState() throws Exception {
    // 実行中のシナリオグループがある場合取得しておく
    TestScenarioGroup currentScenarioGroup = this.testController.getCurrentScenarioGroup();
    // テストシナリオグループのコンボボックスを設定
    this.setupScenarioGroupCombobox(null);
    // コンボボックスを編集可能に設定
    this.scenarioGroupCombobox.setEditable(true);
    this.scenarioCombobox.setEditable(true);
    // 実行中のシナリオグループがある場合のみ
    if (currentScenarioGroup != null) {
        this.scenarioGroupCombobox.setSelectedItem(currentScenarioGroup.getScenarioGroupId());
        this.scenarioCombobox.setEnabled(true);
        this.scenarioStartButton.setEnabled(true);
        this.scenarioEndButton.setEnabled(false);
        this.scenarioCancelButton.setEnabled(false);
        this.scenarioDownloadButton.setEnabled(false);
        // シナリオコンボボックスの設定
        this.setupScenarioCombobox(null);
    }
    // シナリオ系コンポーネントの設定(初期化)
    this.setupScenarioComponents();
}
Also used : TestScenarioGroup(jp.ossc.nimbus.service.test.TestScenarioGroup)

Example 7 with TestScenarioGroup

use of jp.ossc.nimbus.service.test.TestScenarioGroup in project nimbus by nimbus-org.

the class MSProjectTestReporterService method report.

public void report(TestController controller) {
    try {
        ProjectFile pf = new ProjectFile();
        ProjectCalendar cal = pf.getDefaultCalendar();
        TestScenarioGroup[] groups = controller.getScenarioGroups();
        Map resourceMap = new HashMap();
        for (int i = 0; i < groups.length; i++) {
            TestScenarioGroup.TestScenarioGroupResource sgr = groups[i].getTestScenarioGroupResource();
            if (sgr == null) {
                continue;
            }
            Task groupTask = pf.addTask();
            String title = sgr.getTitle();
            if (title == null || title.length() == 0) {
                groupTask.setName(groups[i].getScenarioGroupId());
            } else {
                groupTask.setName(groups[i].getScenarioGroupId() + ':' + title);
            }
            groupTask.setCalendar(cal);
            if (sgr.getCreator() != null) {
                Resource resource = null;
                if (!resourceMap.containsKey(sgr.getCreator())) {
                    resource = pf.addResource();
                    resource.setName(sgr.getCreator());
                    resourceMap.put(sgr.getCreator(), resource);
                } else {
                    resource = (Resource) resourceMap.get(sgr.getCreator());
                }
                ResourceAssignment ra = pf.newResourceAssignment(groupTask);
                ra.setResourceUniqueID(resource.getUniqueID());
                if (sgr.getScheduledCreateStartDate() != null) {
                    ra.setStart(sgr.getScheduledCreateStartDate());
                }
                if (sgr.getScheduledCreateEndDate() != null) {
                    ra.setFinish(sgr.getScheduledCreateEndDate());
                }
                if (sgr.getCreateStartDate() != null) {
                    ra.setActualStart(sgr.getCreateStartDate());
                }
                if (sgr.getCreateEndDate() != null) {
                    ra.setActualFinish(sgr.getCreateEndDate());
                }
                resource.addResourceAssignment(ra);
                groupTask.addResourceAssignment(ra);
                groupTask.setResourceNames(sgr.getCreator());
            }
            if (sgr.getScheduledCreateStartDate() != null) {
                groupTask.setStart(sgr.getScheduledCreateStartDate());
            }
            if (sgr.getScheduledCreateEndDate() != null) {
                groupTask.setFinish(sgr.getScheduledCreateEndDate());
            }
            if (sgr.getCreateStartDate() != null) {
                groupTask.setActualStart(sgr.getCreateStartDate());
            }
            if (sgr.getCreateEndDate() != null) {
                groupTask.setActualFinish(sgr.getCreateEndDate());
            }
            if (sgr.getScheduledCreateStartDate() != null) {
                if (sgr.getExpectedCost() > 0) {
                    groupTask.setManualDuration(Duration.getInstance(sgr.getExpectedCost(), TimeUnit.MINUTES));
                    groupTask.setDuration(Duration.getInstance(sgr.getExpectedCost(), TimeUnit.MINUTES));
                }
                if (sgr.getCreateStartDate() != null && sgr.getCreateEndDate() == null) {
                    if (sgr.getProgress() != 0.0d) {
                        groupTask.setPercentageComplete(new Double(sgr.getProgress()));
                    }
                } else if (sgr.getCreateStartDate() != null && sgr.getCreateEndDate() != null) {
                    if (sgr.getCost() > 0) {
                        groupTask.setActualDuration(Duration.getInstance(sgr.getCost(), TimeUnit.MINUTES));
                    }
                    groupTask.setPercentageComplete(new Double(100.0d));
                    groupTask.setTaskMode(TaskMode.AUTO_SCHEDULED);
                }
            }
            Task groupSummuryTask = pf.addTask();
            if (title == null) {
                groupSummuryTask.setName(groups[i].getScenarioGroupId());
            } else {
                groupSummuryTask.setName(groups[i].getScenarioGroupId() + ':' + title);
            }
            groupSummuryTask.setCalendar(cal);
            TestScenario[] scenarios = controller.getScenarios(groups[i].getScenarioGroupId());
            for (int j = 0; j < scenarios.length; j++) {
                TestScenario.TestScenarioResource sr = scenarios[j].getTestScenarioResource();
                if (sr == null) {
                    continue;
                }
                Task scenarioTask = pf.addTask();
                title = sr.getTitle();
                if (title == null || title.length() == 0) {
                    scenarioTask.setName(scenarios[j].getScenarioId());
                } else {
                    scenarioTask.setName(scenarios[j].getScenarioId() + ':' + title);
                }
                scenarioTask.setCalendar(cal);
                scenarioTask.setTaskMode(TaskMode.MANUALLY_SCHEDULED);
                if (sr.getCreator() != null) {
                    Resource resource = null;
                    if (!resourceMap.containsKey(sr.getCreator())) {
                        resource = pf.addResource();
                        resource.setName(sr.getCreator());
                        resourceMap.put(sr.getCreator(), resource);
                    } else {
                        resource = (Resource) resourceMap.get(sr.getCreator());
                    }
                    ResourceAssignment ra = pf.newResourceAssignment(scenarioTask);
                    ra.setResourceUniqueID(resource.getUniqueID());
                    if (sr.getScheduledCreateStartDate() != null) {
                        ra.setStart(sr.getScheduledCreateStartDate());
                    }
                    if (sr.getScheduledCreateEndDate() != null) {
                        ra.setFinish(sr.getScheduledCreateEndDate());
                    }
                    if (sr.getCreateStartDate() != null) {
                        ra.setActualStart(sr.getCreateStartDate());
                    }
                    if (sr.getCreateEndDate() != null) {
                        ra.setActualFinish(sr.getCreateEndDate());
                    }
                    resource.addResourceAssignment(ra);
                    scenarioTask.addResourceAssignment(ra);
                    scenarioTask.setResourceNames(sr.getCreator());
                }
                if (sr.getScheduledCreateStartDate() != null) {
                    scenarioTask.setStart(sr.getScheduledCreateStartDate());
                }
                if (sr.getScheduledCreateEndDate() != null) {
                    scenarioTask.setFinish(sr.getScheduledCreateEndDate());
                }
                if (sr.getCreateStartDate() != null) {
                    scenarioTask.setActualStart(sr.getCreateStartDate());
                }
                if (sr.getCreateEndDate() != null) {
                    scenarioTask.setActualFinish(sr.getCreateEndDate());
                }
                if (sr.getScheduledCreateStartDate() != null) {
                    if (sr.getExpectedCost() > 0) {
                        scenarioTask.setManualDuration(Duration.getInstance(sr.getExpectedCost(), TimeUnit.MINUTES));
                        scenarioTask.setDuration(Duration.getInstance(sr.getExpectedCost(), TimeUnit.MINUTES));
                    }
                    if (sr.getCreateStartDate() != null && sr.getCreateEndDate() == null) {
                        if (sr.getProgress() != 0.0d) {
                            scenarioTask.setPercentageComplete(new Double(sr.getProgress()));
                        }
                    } else if (sr.getCreateStartDate() != null && sr.getCreateEndDate() != null) {
                        if (sr.getCost() > 0) {
                            scenarioTask.setActualDuration(Duration.getInstance(sr.getCost(), TimeUnit.MINUTES));
                        }
                        scenarioTask.setPercentageComplete(new Double(100.0d));
                        scenarioTask.setTaskMode(TaskMode.AUTO_SCHEDULED);
                    }
                }
                groupSummuryTask.addChildTask(scenarioTask);
                TestCase[] testcases = controller.getTestCases(groups[i].getScenarioGroupId(), scenarios[j].getScenarioId());
                for (int k = 0; k < testcases.length; k++) {
                    TestCase.TestCaseResource tcr = testcases[k].getTestCaseResource();
                    if (tcr != null && (tcr.getCreator() != null || tcr.getScheduledCreateStartDate() != null || tcr.getCreateStartDate() != null)) {
                        Task testcaseTask = pf.addTask();
                        title = tcr.getTitle();
                        if (title == null || title.length() == 0) {
                            testcaseTask.setName(testcases[k].getTestCaseId());
                        } else {
                            testcaseTask.setName(testcases[k].getTestCaseId() + ':' + title);
                        }
                        testcaseTask.setName(testcases[k].getTestCaseId());
                        testcaseTask.setCalendar(cal);
                        if (tcr.getCreator() != null) {
                            Resource resource = null;
                            if (!resourceMap.containsKey(tcr.getCreator())) {
                                resource = pf.addResource();
                                resource.setName(tcr.getCreator());
                                resourceMap.put(tcr.getCreator(), resource);
                            } else {
                                resource = (Resource) resourceMap.get(tcr.getCreator());
                            }
                            ResourceAssignment ra = pf.newResourceAssignment(testcaseTask);
                            ra.setResourceUniqueID(resource.getUniqueID());
                            if (tcr.getScheduledCreateStartDate() != null) {
                                ra.setStart(tcr.getScheduledCreateStartDate());
                            }
                            if (tcr.getScheduledCreateEndDate() != null) {
                                ra.setFinish(tcr.getScheduledCreateEndDate());
                            }
                            if (tcr.getCreateStartDate() != null) {
                                ra.setActualStart(tcr.getCreateStartDate());
                            }
                            if (tcr.getCreateEndDate() != null) {
                                ra.setActualFinish(tcr.getCreateEndDate());
                            }
                            resource.addResourceAssignment(ra);
                            testcaseTask.addResourceAssignment(ra);
                            testcaseTask.setResourceNames(tcr.getCreator());
                        }
                        if (tcr.getScheduledCreateStartDate() != null) {
                            testcaseTask.setStart(tcr.getScheduledCreateStartDate());
                        }
                        if (tcr.getScheduledCreateEndDate() != null) {
                            testcaseTask.setFinish(tcr.getScheduledCreateEndDate());
                        }
                        if (tcr.getCreateStartDate() != null) {
                            testcaseTask.setActualStart(tcr.getCreateStartDate());
                        }
                        if (tcr.getCreateEndDate() != null) {
                            testcaseTask.setActualFinish(tcr.getCreateEndDate());
                        }
                        if (tcr.getScheduledCreateStartDate() != null) {
                            if (tcr.getExpectedCost() > 0) {
                                testcaseTask.setManualDuration(Duration.getInstance(tcr.getExpectedCost(), TimeUnit.MINUTES));
                                testcaseTask.setDuration(Duration.getInstance(tcr.getExpectedCost(), TimeUnit.MINUTES));
                            }
                            if (tcr.getCreateStartDate() != null && tcr.getCreateEndDate() == null) {
                                if (tcr.getProgress() != 0.0d) {
                                    testcaseTask.setPercentageComplete(new Double(tcr.getProgress()));
                                }
                            } else if (tcr.getCreateStartDate() != null && tcr.getCreateEndDate() != null) {
                                if (tcr.getCost() > 0) {
                                    testcaseTask.setActualDuration(Duration.getInstance(tcr.getCost(), TimeUnit.MINUTES));
                                }
                                testcaseTask.setPercentageComplete(new Double(100.0d));
                                testcaseTask.setTaskMode(TaskMode.AUTO_SCHEDULED);
                            }
                        }
                        scenarioTask.addChildTask(testcaseTask);
                    }
                }
            }
        }
        FileOutputStream fos = new FileOutputStream(outputFile);
        try {
            ProjectWriter pw = projectWriter == null ? new MSPDIWriter() : projectWriter;
            pw.write(pf, fos);
        } finally {
            fos.close();
        }
    } catch (Exception e) {
        ServiceManagerFactory.getLogger().write("CTR__00001", e);
        return;
    }
}
Also used : Task(net.sf.mpxj.Task) MSPDIWriter(net.sf.mpxj.mspdi.MSPDIWriter) HashMap(java.util.HashMap) TestScenario(jp.ossc.nimbus.service.test.TestScenario) ProjectCalendar(net.sf.mpxj.ProjectCalendar) TestScenarioGroup(jp.ossc.nimbus.service.test.TestScenarioGroup) Resource(net.sf.mpxj.Resource) ProjectFile(net.sf.mpxj.ProjectFile) IOException(java.io.IOException) ResourceAssignment(net.sf.mpxj.ResourceAssignment) TestCase(jp.ossc.nimbus.service.test.TestCase) FileOutputStream(java.io.FileOutputStream) ProjectWriter(net.sf.mpxj.writer.ProjectWriter) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 with TestScenarioGroup

use of jp.ossc.nimbus.service.test.TestScenarioGroup in project nimbus by nimbus-org.

the class ScenarioTestView method setupStatusLabel.

/**
 * 実行中のシナリオグループ、シナリオ、テストケースをラベルに設定する。
 * @throws Exception
 */
private void setupStatusLabel() throws Exception {
    TestScenarioGroup group = testController.getCurrentScenarioGroup();
    TestScenario scenario = testController.getCurrentScenario();
    TestCase testcase = testController.getCurrentTestCase();
    StringBuilder sb = new StringBuilder();
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd HH:mm");
    if (group != null) {
        sb.append("ScenarioGroup=" + group.getScenarioGroupId());
        if (group.getStatus() != null) {
            sb.append("(" + group.getStatus().getUserId());
            if (group.getStatus().getStartTime() != null) {
                sb.append(" " + sdf.format(group.getStatus().getStartTime()));
            }
            sb.append(")");
        }
        if (scenario != null) {
            sb.append(", Scenario=" + scenario.getScenarioId());
            if (scenario.getStatus() != null) {
                sb.append("(" + scenario.getStatus().getUserId());
                if (scenario.getStatus().getStartTime() != null) {
                    sb.append(" " + sdf.format(scenario.getStatus().getStartTime()));
                }
                sb.append(")");
            }
            if (testcase != null) {
                sb.append(", Testcase=" + testcase.getTestCaseId());
                if (testcase.getStatus() != null) {
                    sb.append("(" + testcase.getStatus().getUserId());
                    if (testcase.getStatus().getStartTime() != null) {
                        sb.append(" " + sdf.format(testcase.getStatus().getStartTime()));
                    }
                    sb.append(")");
                }
            }
        }
    } else {
        sb.append("無し");
    }
    this.statusLabel2.setText(sb.toString());
    this.statusLabel2.setToolTipText(sb.toString());
}
Also used : TestCase(jp.ossc.nimbus.service.test.TestCase) TestScenario(jp.ossc.nimbus.service.test.TestScenario) TestScenarioGroup(jp.ossc.nimbus.service.test.TestScenarioGroup) SimpleDateFormat(java.text.SimpleDateFormat)

Example 9 with TestScenarioGroup

use of jp.ossc.nimbus.service.test.TestScenarioGroup in project nimbus by nimbus-org.

the class ScenarioTestView method setupScenarioComponents.

/**
 * シナリオ系コンポーネントの設定
 * @throws Exception
 */
private void setupScenarioComponents() throws Exception {
    TestScenarioGroup currentScenarioGroup = testController.getCurrentScenarioGroup();
    if (currentScenarioGroup == null) {
        this.scenarioGroupStartButton.setEnabled(true);
        this.scenarioGroupEndButton.setEnabled(false);
        this.scenarioCombobox.setEnabled(false);
        this.scenarioStartButton.setEnabled(false);
        this.scenarioEndButton.setEnabled(false);
        this.scenarioCancelButton.setEnabled(false);
        this.scenarioDownloadButton.setEnabled(false);
        return;
    } else {
        this.scenarioGroupStartButton.setEnabled(false);
        this.scenarioGroupEndButton.setEnabled(true);
    }
    String currentScenarioGroupId = currentScenarioGroup.getScenarioGroupId();
    if (this.scenarioCombobox.getSelectedItem() == null)
        return;
    String selectScenarioId = this.scenarioCombobox.getSelectedItem().toString();
    TestScenario selectSenario = null;
    if (currentScenarioGroupId != null && selectScenarioId != null) {
        selectSenario = testController.getScenario(currentScenarioGroupId, selectScenarioId);
    }
    if (selectSenario == null) {
        return;
    }
    final TestScenario.Status status = selectSenario.getStatus();
    this.scenarioStatusButton.change(status);
    if (status != null && status.getState() == TestScenario.Status.STARTED) {
        this.scenarioCombobox.setEnabled(true);
        this.scenarioStartButton.setEnabled(false);
        this.scenarioEndButton.setEnabled(true);
        this.scenarioCancelButton.setEnabled(true);
        this.scenarioDownloadButton.setEnabled(false);
    } else if (status != null && status.getState() == TestScenario.Status.END) {
        this.scenarioCombobox.setEnabled(true);
        this.scenarioStartButton.setEnabled(true);
        this.scenarioEndButton.setEnabled(false);
        this.scenarioCancelButton.setEnabled(false);
        this.scenarioDownloadButton.setEnabled(true);
    } else if (status == null || (status != null && (status.getState() == TestScenario.Status.INITIAL || status.getState() == TestScenario.Status.CANCELED || status.getState() == TestScenario.Status.ERROR))) {
        this.scenarioCombobox.setEnabled(true);
        this.scenarioStartButton.setEnabled(true);
        this.scenarioEndButton.setEnabled(false);
        this.scenarioCancelButton.setEnabled(false);
        this.scenarioDownloadButton.setEnabled(false);
    } else {
        if (this.scenarioCombobox.getItemCount() == 0) {
            this.scenarioCombobox.setEnabled(false);
        } else {
            this.scenarioCombobox.setEnabled(true);
        }
        this.scenarioStartButton.setEnabled(false);
        this.scenarioEndButton.setEnabled(false);
        this.scenarioCancelButton.setEnabled(false);
        this.scenarioDownloadButton.setEnabled(false);
    }
}
Also used : TestScenario(jp.ossc.nimbus.service.test.TestScenario) TestScenarioGroup(jp.ossc.nimbus.service.test.TestScenarioGroup)

Example 10 with TestScenarioGroup

use of jp.ossc.nimbus.service.test.TestScenarioGroup in project nimbus by nimbus-org.

the class CSVTestReporterService method report.

public void report(TestController controller) {
    CSVWriter writer = csvWriter == null ? new CSVWriter() : csvWriter.cloneWriter();
    if (writer.getNullValue() == null) {
        writer.setNullValue("");
    }
    List csv = new ArrayList();
    try {
        BufferedWriter bw = new BufferedWriter(encoding == null ? new FileWriter(outputFile) : new OutputStreamWriter(new FileOutputStream(outputFile), encoding));
        writer.setWriter(bw);
        Set scenarioGroupCategorySet = new TreeSet();
        Set scenarioCategorySet = new TreeSet();
        Set testcaseCategorySet = new TreeSet();
        TestScenarioGroup[] groups = controller.getScenarioGroups();
        for (int i = 0; i < groups.length; i++) {
            TestScenarioGroup.TestScenarioGroupResource sgr = groups[i].getTestScenarioGroupResource();
            if (sgr != null) {
                Map categoryMap = sgr.getCategoryMap();
                if (categoryMap.size() != 0) {
                    scenarioGroupCategorySet.addAll(categoryMap.keySet());
                }
            }
            TestScenario[] scenarios = controller.getScenarios(groups[i].getScenarioGroupId());
            for (int j = 0; j < scenarios.length; j++) {
                TestScenario.TestScenarioResource sr = scenarios[j].getTestScenarioResource();
                if (sr != null) {
                    Map categoryMap = sr.getCategoryMap();
                    if (categoryMap.size() != 0) {
                        scenarioCategorySet.addAll(categoryMap.keySet());
                    }
                }
                TestCase[] testcases = controller.getTestCases(groups[i].getScenarioGroupId(), scenarios[j].getScenarioId());
                for (int k = 0; k < testcases.length; k++) {
                    TestCase.TestCaseResource tr = testcases[k].getTestCaseResource();
                    if (tr != null) {
                        Map categoryMap = tr.getCategoryMap();
                        if (categoryMap.size() != 0) {
                            testcaseCategorySet.addAll(categoryMap.keySet());
                        }
                    }
                }
            }
        }
        csv.add("ScenarioGroupId");
        Iterator categories = scenarioGroupCategorySet.iterator();
        while (categories.hasNext()) {
            String categoryName = (String) categories.next();
            csv.add(categoryName);
        }
        csv.add("Title");
        csv.add("Description");
        csv.add("UserId");
        csv.add("StartTime");
        csv.add("EndTime");
        csv.add("State");
        csv.add("Result");
        csv.add("Exception");
        csv.add("ActionId");
        csv.add("Title");
        csv.add("Description");
        csv.add("ActionType");
        csv.add("Result");
        csv.add("Exception");
        csv.add("ScenarioId");
        categories = scenarioCategorySet.iterator();
        while (categories.hasNext()) {
            String categoryName = (String) categories.next();
            csv.add(categoryName);
        }
        csv.add("Title");
        csv.add("Description");
        csv.add("UserId");
        csv.add("StartTime");
        csv.add("EndTime");
        csv.add("State");
        csv.add("Result");
        csv.add("Exception");
        csv.add("ActionId");
        csv.add("Title");
        csv.add("Description");
        csv.add("ActionType");
        csv.add("Result");
        csv.add("Exception");
        csv.add("TestcaseId");
        categories = testcaseCategorySet.iterator();
        while (categories.hasNext()) {
            String categoryName = (String) categories.next();
            csv.add(categoryName);
        }
        csv.add("Title");
        csv.add("Description");
        csv.add("UserId");
        csv.add("StartTime");
        csv.add("EndTime");
        csv.add("State");
        csv.add("Result");
        csv.add("Exception");
        csv.add("ActionId");
        csv.add("Title");
        csv.add("Description");
        csv.add("ActionType");
        csv.add("Result");
        csv.add("Exception");
        writer.writeCSV(csv);
        for (int i = 0; i < groups.length; i++) {
            TestScenarioGroup.TestScenarioGroupResource sgr = groups[i].getTestScenarioGroupResource();
            csv.clear();
            addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, true);
            addScenarioElements(csv, null, null, scenarioCategorySet, null, null, false);
            addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
            writer.writeCSV(csv);
            if (sgr != null) {
                String[] actionIds = sgr.getBeforeActionIds();
                if (actionIds != null) {
                    for (int j = 0; j < actionIds.length; j++) {
                        csv.clear();
                        addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, actionIds[j], "before", false);
                        addScenarioElements(csv, null, null, scenarioCategorySet, null, null, false);
                        addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
                        writer.writeCSV(csv);
                    }
                }
                actionIds = sgr.getFinallyActionIds();
                if (actionIds != null) {
                    for (int j = 0; j < actionIds.length; j++) {
                        csv.clear();
                        addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, actionIds[j], "finally", false);
                        addScenarioElements(csv, null, null, scenarioCategorySet, null, null, false);
                        addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
                        writer.writeCSV(csv);
                    }
                }
            }
            TestScenario[] scenarios = controller.getScenarios(groups[i].getScenarioGroupId());
            for (int j = 0; j < scenarios.length; j++) {
                TestScenario.TestScenarioResource sr = scenarios[j].getTestScenarioResource();
                csv.clear();
                addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, null, null, true);
                addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
                writer.writeCSV(csv);
                if (sr != null) {
                    String[] actionIds = sr.getBeforeActionIds();
                    if (actionIds != null) {
                        for (int k = 0; k < actionIds.length; k++) {
                            csv.clear();
                            addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                            addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, actionIds[k], "before", false);
                            addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
                            writer.writeCSV(csv);
                        }
                    }
                    actionIds = sr.getAfterActionIds();
                    if (actionIds != null) {
                        for (int k = 0; k < actionIds.length; k++) {
                            csv.clear();
                            addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                            addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, actionIds[k], "after", false);
                            addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
                            writer.writeCSV(csv);
                        }
                    }
                    actionIds = sr.getFinallyActionIds();
                    if (actionIds != null) {
                        for (int k = 0; k < actionIds.length; k++) {
                            csv.clear();
                            addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                            addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, actionIds[k], "finally", false);
                            addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
                            writer.writeCSV(csv);
                        }
                    }
                }
                TestCase[] testcases = controller.getTestCases(groups[i].getScenarioGroupId(), scenarios[j].getScenarioId());
                for (int k = 0; k < testcases.length; k++) {
                    TestCase.TestCaseResource tr = testcases[k].getTestCaseResource();
                    csv.clear();
                    addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                    addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, null, null, false);
                    addTestCaseElements(csv, testcases[k], tr, testcaseCategorySet, null, null, true);
                    writer.writeCSV(csv);
                    if (tr != null) {
                        String[] actionIds = tr.getBeforeActionIds();
                        if (actionIds != null) {
                            for (int l = 0; l < actionIds.length; l++) {
                                csv.clear();
                                addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                                addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, null, null, false);
                                addTestCaseElements(csv, testcases[k], tr, testcaseCategorySet, actionIds[l], "before", false);
                                writer.writeCSV(csv);
                            }
                        }
                        actionIds = tr.getActionIds();
                        if (actionIds != null) {
                            for (int l = 0; l < actionIds.length; l++) {
                                csv.clear();
                                addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                                addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, null, null, false);
                                addTestCaseElements(csv, testcases[k], tr, testcaseCategorySet, actionIds[l], "action", false);
                                writer.writeCSV(csv);
                            }
                        }
                        actionIds = tr.getAfterActionIds();
                        if (actionIds != null) {
                            for (int l = 0; l < actionIds.length; l++) {
                                csv.clear();
                                addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                                addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, null, null, false);
                                addTestCaseElements(csv, testcases[k], tr, testcaseCategorySet, actionIds[l], "after", false);
                                writer.writeCSV(csv);
                            }
                        }
                        actionIds = tr.getFinallyActionIds();
                        if (actionIds != null) {
                            for (int l = 0; l < actionIds.length; l++) {
                                csv.clear();
                                addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                                addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, null, null, false);
                                addTestCaseElements(csv, testcases[k], tr, testcaseCategorySet, actionIds[l], "finally", false);
                                writer.writeCSV(csv);
                            }
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        ServiceManagerFactory.getLogger().write("CTR__00001", e);
        return;
    } finally {
        try {
            writer.flush();
        } catch (IOException e) {
        }
        try {
            writer.close();
        } catch (IOException e) {
        }
    }
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) TestScenario(jp.ossc.nimbus.service.test.TestScenario) FileWriter(java.io.FileWriter) TestScenarioGroup(jp.ossc.nimbus.service.test.TestScenarioGroup) ArrayList(java.util.ArrayList) CSVWriter(jp.ossc.nimbus.io.CSVWriter) BufferedWriter(java.io.BufferedWriter) TreeSet(java.util.TreeSet) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException) IOException(java.io.IOException) TestCase(jp.ossc.nimbus.service.test.TestCase) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) Map(java.util.Map)

Aggregations

TestScenarioGroup (jp.ossc.nimbus.service.test.TestScenarioGroup)13 TestScenario (jp.ossc.nimbus.service.test.TestScenario)8 TestCase (jp.ossc.nimbus.service.test.TestCase)5 BufferedWriter (java.io.BufferedWriter)4 FileWriter (java.io.FileWriter)4 IOException (java.io.IOException)4 PrintWriter (java.io.PrintWriter)3 Iterator (java.util.Iterator)3 Map (java.util.Map)3 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 BigDecimal (java.math.BigDecimal)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 OutputStreamWriter (java.io.OutputStreamWriter)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1