Search in sources :

Example 1 with TestScenario

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

the class ConsoleTestEstimateReporterService method report.

public void report(TestController controller) {
    try {
        TestScenarioGroup[] groups = controller.getScenarioGroups();
        for (int index = 0; index < groups.length; index++) {
            String scenarioGroupId = groups[index].getScenarioGroupId();
            TestScenarioGroup testScenarioGroup = controller.getScenarioGroup(scenarioGroupId);
            TestScenario[] testScenarios = controller.getScenarios(scenarioGroupId);
            TestScenarioGroup.TestScenarioGroupResource testScenarioGroupResource = testScenarioGroup.getTestScenarioGroupResource();
            if (testScenarioGroupResource == null) {
                continue;
            }
            System.out.println(scenarioGroupId + ":" + new BigDecimal(testScenarioGroupResource.getExpectedCost() / rate).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
            for (int index2 = 0; index2 < testScenarios.length; index2++) {
                TestScenario testScenario = testScenarios[index2];
                TestScenario.TestScenarioResource testScenarioResource = testScenario.getTestScenarioResource();
                if (testScenarioResource == null) {
                    continue;
                }
                System.out.println("  " + testScenario.getScenarioId() + ":" + new BigDecimal(testScenarioResource.getExpectedCost() / rate).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
            }
        }
    } catch (Exception e) {
        ServiceManagerFactory.getLogger().write("CTR__00001", e);
        return;
    }
}
Also used : TestScenario(jp.ossc.nimbus.service.test.TestScenario) TestScenarioGroup(jp.ossc.nimbus.service.test.TestScenarioGroup) BigDecimal(java.math.BigDecimal)

Example 2 with TestScenario

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

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

the class CSVTestEstimateReporterService method report.

public void report(TestController controller) {
    PrintWriter pw = null;
    try {
        TestScenarioGroup[] groups = controller.getScenarioGroups();
        pw = new PrintWriter(new BufferedWriter(new FileWriter(outputFile)));
        pw.println("scenrioGroup" + "," + "scenario" + "," + "cost");
        for (int index = 0; index < groups.length; index++) {
            String scenarioGroupId = groups[index].getScenarioGroupId();
            TestScenarioGroup testScenarioGroup = controller.getScenarioGroup(scenarioGroupId);
            TestScenarioGroup.TestScenarioGroupResource testScenarioGroupResource = testScenarioGroup.getTestScenarioGroupResource();
            if (testScenarioGroupResource == null) {
                continue;
            }
            TestScenario[] testScenarios = controller.getScenarios(scenarioGroupId);
            pw.println(scenarioGroupId + "," + "" + "," + new BigDecimal(testScenarioGroupResource.getExpectedCost() / rate).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
            for (int index2 = 0; index2 < testScenarios.length; index2++) {
                TestScenario testScenario = testScenarios[index2];
                TestScenario.TestScenarioResource testScenarioResource = testScenario.getTestScenarioResource();
                if (testScenarioResource == null) {
                    continue;
                }
                pw.println("" + "," + testScenario.getScenarioId() + "," + new BigDecimal(testScenarioResource.getExpectedCost() / rate).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
            }
        }
        pw.flush();
    } catch (Exception e) {
        ServiceManagerFactory.getLogger().write("CTR__00001", e);
        return;
    } finally {
        if (pw != null) {
            pw.close();
        }
    }
}
Also used : TestScenario(jp.ossc.nimbus.service.test.TestScenario) TestScenarioGroup(jp.ossc.nimbus.service.test.TestScenarioGroup) FileWriter(java.io.FileWriter) BigDecimal(java.math.BigDecimal) BufferedWriter(java.io.BufferedWriter) PrintWriter(java.io.PrintWriter)

Example 4 with TestScenario

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

use of jp.ossc.nimbus.service.test.TestScenario 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)

Aggregations

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