0

私は summaryData() メソッドを持っていて、値を取得するために何度も呼び出しました。1回目は作業ファイルですが、2回目はHashMapで実行値が増えています。

    void summarizeData() {

    HashMap outerMap = new HashMap();

    ArrayList list = new ArrayList(dataClass.getData());


    for (int indx = 0; indx < list.size(); indx++) {
        System.out.println("indx : " + indx);
        Resultset rs = new Resultset();
        rs = (Resultset) list.get(indx);


        if (rs != null) {

            int id = rs.getTestCaseNumber();
            if (id > 0) {
                Object isExists = outerMap.get(id);

                if (isExists != null) {
                    //System.out.println("found entry so updating");
                    Resultset inRs = new Resultset();
                    inRs = (Resultset) isExists;

                    if (inRs != null) {
                        int totExec = inRs.getTestExecution();
                        int totPass = inRs.getTestCasePass();
                        int totFail = inRs.getTestCaseFail();

                        //     System.out.println("totE :" + totExec + "  totP:" + totPass + "  totF:" + totFail);

                        int newRsStat = rs.getTestCasePass();

                        if (newRsStat == 1) {
                            totPass++;
                            inRs.setTestCasePass(totPass);
                        } else {
                            totFail++;
                            inRs.setTestCaseFail(totFail);
                        }
                        totExec++;

                        //      System.out.println("id : "+id+"  totPass: "+totPass+"  totFail:"+totFail);
                        //       System.out.println("key : " + id + "  val : " + inRs.getTestCaseNumber() + " " + inRs.getTestCasePass() + "  " + inRs.getTestCaseFail());

                        inRs.setTestExecution(totExec);
                        outerMap.put(id, inRs);
                    }

                } else {

                    //    System.out.println("not exist so new entry" + " totE:" + rs.getTestExecution() + "  totP:" + rs.getTestCasePass() + "  totF:" + rs.getTestCaseFail());
                    outerMap.put(id, rs);
                }
            }
        } else {
            System.out.println("rs null");
        }


    }

初回実行時の出力:

indx : 0
indx : 1
indx : 2
indx : 3
indx : 4
indx : 5
indx : 6
indx : 7
indx : 8
indx : 9
indx : 10
totE :1  totP:1  totF:0
indx : 11
totE :1  totP:1  totF:0
indx : 12
totE :1  totP:1  totF:0
indx : 13
totE :1  totP:1  totF:0
indx : 14
totE :1  totP:1  totF:0
indx : 15
totE :1  totP:1  totF:0
indx : 16
totE :1  totP:1  totF:0
indx : 17
totE :1  totP:1  totF:0
indx : 18
totE :1  totP:1  totF:0
indx : 19
totE :1  totP:1  totF:0

2回目の実行時の出力:

indx : 0
indx : 1
indx : 2
indx : 3
indx : 4
indx : 5
indx : 6
indx : 7
indx : 8
indx : 9
indx : 10
totE :2  totP:2  totF:0
indx : 11
totE :2  totP:2  totF:0
indx : 12
totE :2  totP:2  totF:0
indx : 13
totE :2  totP:2  totF:0
indx : 14
totE :2  totP:2  totF:0
indx : 15
totE :2  totP:2  totF:0
indx : 16
totE :2  totP:2  totF:0
indx : 17
totE :2  totP:2  totF:0
indx : 18
totE :2  totP:2  totF:0
indx : 19
totE :2  totP:2  totF:0

実行ごとに同じ出力が必要でしたが。

4

1 に答える 1