Search in sources :

Example 1 with TestCase

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

the class HtmlTestReporterService method reportScenarioGroup.

private void reportScenarioGroup(PrintWriter pw, TestController controller, TestScenarioGroup group) throws Exception {
    TestScenario[] scenarios = controller.getScenarios(group.getScenarioGroupId());
    Map scenarioTestcaseMap = new TreeMap();
    int testCaseCount = 0;
    for (int index = 0; index < scenarios.length; index++) {
        TestCase[] cases = controller.getTestCases(group.getScenarioGroupId(), scenarios[index].getScenarioId());
        if (cases.length == 0) {
            testCaseCount++;
        } else {
            testCaseCount += cases.length;
        }
        scenarioTestcaseMap.put(scenarios[index].getScenarioId(), cases);
    }
    pw.println("<tr>");
    pw.println("<td rowspan=\"" + testCaseCount + "\"" + " scope=\"rowgroup\">" + group.getScenarioGroupId() + "</td>");
    pw.println("<td rowspan=\"" + testCaseCount + "\"" + " scope=\"rowgroup\">" + group.getStatus().getUserId() + "</td>");
    pw.println("<td rowspan=\"" + testCaseCount + "\"" + " scope=\"rowgroup\">" + formatDate(group.getStatus().getStartTime()) + "</td>");
    reportResult(pw, group.getStatus().getResult(), group.getStatus().getThrowable(), testCaseCount, "rowgroup");
    Iterator ite = scenarioTestcaseMap.keySet().iterator();
    boolean isFirst = true;
    while (ite.hasNext()) {
        String scenarioId = (String) ite.next();
        TestScenario scenario = null;
        for (int i = 0; i < scenarios.length; i++) {
            if (scenarioId.equals(scenarios[i].getScenarioId())) {
                scenario = scenarios[i];
            }
        }
        if (scenario.getStatus() == null) {
            continue;
        }
        TestCase[] cases = (TestCase[]) scenarioTestcaseMap.get(scenarioId);
        int caseCount = 0;
        if (cases.length == 0) {
            caseCount = 1;
        } else {
            caseCount = cases.length;
        }
        if (!isFirst) {
            pw.println("<tr>");
        }
        isFirst = false;
        if (isDownloadErrorOnly && !scenario.getStatus().getResult()) {
            String downloadFilepath = downloadResult(controller, scenario.getScenarioGroupId(), scenario.getScenarioId(), null);
            pw.println("<td rowspan=\"" + caseCount + "\"" + "scope=\"rowgroup\"><a href=\"" + downloadFilepath + "\">" + scenarioId + "</a></td>");
        } else {
            pw.println("<td rowspan=\"" + caseCount + "\"" + "scope=\"rowgroup\">" + scenarioId + "</td>");
        }
        pw.println("<td rowspan=\"" + caseCount + "\"" + "scope=\"rowgroup\">" + scenario.getStatus().getUserId() + "</td>");
        pw.println("<td rowspan=\"" + caseCount + "\"" + "scope=\"rowgroup\">" + formatDate(scenario.getStatus().getStartTime()) + "</td>");
        pw.println("<td rowspan=\"" + caseCount + "\"" + "scope=\"rowgroup\">" + formatDate(scenario.getStatus().getEndTime()) + "</td>");
        pw.println("<td rowspan=\"" + caseCount + "\"" + "scope=\"rowgroup\">" + scenario.getStatus().getStateString() + "</td>");
        reportResult(pw, scenario.getStatus().getResult(), scenario.getStatus().getThrowable(), caseCount, "rowgroup");
        if (cases.length > 0 && cases[0].getStatus() != null) {
            reportTestCase(pw, controller, cases[0]);
            pw.println("</tr>");
            for (int index = 1; index < cases.length; index++) {
                pw.println("<tr>");
                reportTestCase(pw, controller, cases[index]);
                pw.println("</tr>");
            }
        } else {
            pw.println("</tr>");
        }
    }
}
Also used : TestCase(jp.ossc.nimbus.service.test.TestCase) TestScenario(jp.ossc.nimbus.service.test.TestScenario) Iterator(java.util.Iterator) TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 2 with TestCase

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

the class ScenarioTestView method setupScenarioCombobox.

private void setupScenarioCombobox(String keyword) throws Exception {
    this.scenarioCombobox.removeAllItems();
    TestScenarioGroup currentScenarioGroup = this.testController.getCurrentScenarioGroup();
    if (currentScenarioGroup == null) {
        this.scenarioCombobox.setEnabled(false);
        return;
    }
    this.scenarioCombobox.setEnabled(true);
    // テストシナリオのコンボボックスを設定
    TestScenario[] testScenarioArray = this.testController.getScenarios(currentScenarioGroup.getScenarioGroupId());
    if (testScenarioArray != null) {
        for (int i = 0; i < testScenarioArray.length; i++) {
            String scenarioId = testScenarioArray[i].getScenarioId();
            if (keyword == null || keyword.length() == 0 || scenarioId.indexOf(keyword) >= 0) {
                this.scenarioCombobox.addItem(scenarioId);
            }
            // 開始状態の場合
            if (testScenarioArray[i] != null && testScenarioArray[i].getStatus() != null && testScenarioArray[i].getStatus().getState() == Status.STARTED) {
                String selectScenarioGroupId = currentScenarioGroup.getScenarioGroupId();
                String selectScenarioId = testScenarioArray[i].getScenarioId();
                TestCase[] testCaseArray = this.testController.getTestCases(selectScenarioGroupId, selectScenarioId);
                List testCaseList = new ArrayList();
                for (int t = 0; t < testCaseArray.length; t++) {
                    testCaseList.add(testCaseArray[t]);
                }
                this.testCasePanel.initialize();
                this.testCasePanel.setScenarioGroupId(selectScenarioGroupId);
                this.testCasePanel.setScenarioId(selectScenarioId);
                this.testCasePanel.setTestCaseList(testCaseList);
                this.testCasePanel.addTestCaseControlListener(new TestCaseControlListenerImpl());
                this.testCasePanel.setUserId(userId);
            }
        }
    }
}
Also used : TestCase(jp.ossc.nimbus.service.test.TestCase) TestScenario(jp.ossc.nimbus.service.test.TestScenario) TestScenarioGroup(jp.ossc.nimbus.service.test.TestScenarioGroup) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with TestCase

use of jp.ossc.nimbus.service.test.TestCase 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 4 with TestCase

use of jp.ossc.nimbus.service.test.TestCase 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 5 with TestCase

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

the class ScenarioTestView method scenarioStartAction.

/**
 * シナリオ開始ボタンの押下アクション
 * @throws Exception
 */
private void scenarioStartAction() throws Exception {
    String selectScenarioGroupId = this.scenarioGroupCombobox.getSelectedItem().toString();
    String selectScenarioId = this.scenarioCombobox.getSelectedItem().toString();
    // シナリオの開始
    this.testController.startScenario(this.userId, selectScenarioId);
    // シナリオの検索、シナリオ一覧をコンボボックスに設定
    TestCase[] testCaseArray = this.testController.getTestCases(selectScenarioGroupId, selectScenarioId);
    List testCaseList = new ArrayList();
    for (int i = 0; i < testCaseArray.length; i++) {
        testCaseList.add(testCaseArray[i]);
    }
    // コンポーネント、アクションリスナーの設定
    this.testCasePanel.initialize();
    this.testCasePanel.setScenarioGroupId(selectScenarioGroupId);
    this.testCasePanel.setScenarioId(selectScenarioId);
    this.testCasePanel.setTestCaseList(testCaseList);
    this.testCasePanel.addTestCaseControlListener(new TestCaseControlListenerImpl());
    this.testCasePanel.setUserId(userId);
    // シナリオ系コンポーネントの設定(初期化)
    this.setupScenarioComponents();
}
Also used : TestCase(jp.ossc.nimbus.service.test.TestCase) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

TestCase (jp.ossc.nimbus.service.test.TestCase)10 TestScenario (jp.ossc.nimbus.service.test.TestScenario)7 Iterator (java.util.Iterator)5 Map (java.util.Map)5 TestScenarioGroup (jp.ossc.nimbus.service.test.TestScenarioGroup)5 ArrayList (java.util.ArrayList)4 SimpleDateFormat (java.text.SimpleDateFormat)3 List (java.util.List)3 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 TreeMap (java.util.TreeMap)2 Dimension (java.awt.Dimension)1 Font (java.awt.Font)1 Point (java.awt.Point)1 BufferedWriter (java.io.BufferedWriter)1 FileWriter (java.io.FileWriter)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1