Package com.asakusafw.runtime.value

Examples of com.asakusafw.runtime.value.Date


            int secs = DateUtil.getSecondFromTime(h, min, s);
            DateTime dt = new DateTime();
            dt.setElapsedSeconds((long) days * 86400 + secs);
            model.getCDatetimeOption().modify(dt);

            Date date = new Date();
            date.setElapsedDays(days);
            model.getCDateOption().modify(date);
        }
        inspector.clear();
        inspector.inspect(dataHolder);
        for (Cause cause : inspector.getCauses()) {
            System.out.println(cause.getMessage());
            assertEquals("エラー原因のチェック", Type.CONDITION_TODAY_ON_INVALID_COLUMN, cause.getType());
        }
        assertEquals("エラー原因のリストの要素数", 32, inspector.getCauses().size()); // 8件成功するのでNG件数が40-8=36(件)となる。
        assertFalse("検査失敗", inspector.isSuccess());

        // OKとなるケース(実値に現在日の00:00:00を指定して、inspect()を実行)
        for (AllTypesWNoerr model : getActualList()) {
            Calendar cal = Calendar.getInstance();
            cal.setTimeInMillis(System.currentTimeMillis());
            int y = cal.get(Calendar.YEAR);
            int m = cal.get(Calendar.MONTH);
            int d = cal.get(Calendar.DAY_OF_MONTH);
            int days = DateUtil.getDayFromDate(y, m + 1, d);
            DateTime dt = new DateTime();
            dt.setElapsedSeconds((long) days * 86400);
            model.getCDatetimeOption().modify(dt);

            Date date = new Date();
            date.setElapsedDays(days);
            model.getCDateOption().modify(date);
        }
        inspector.clear();
        // テストが日をまたいで実行された場合に期待したテストができなくなるので、
        // finishTimeにstartTimeと同じ値を入れ、日をまたがないでテストが終了
        // した状況を作り出す。
        inspector.setFinishTime(inspector.getStartTime());
        inspector.inspect(dataHolder);
        for (Cause cause : inspector.getCauses()) {
            System.out.println(cause.getMessage());
            assertEquals("エラー原因のチェック", Type.CONDITION_TODAY_ON_INVALID_COLUMN, cause.getType());
        }
        assertEquals("エラー原因のリストの要素数", 32, inspector.getCauses().size()); // 8件成功するのでNG件数が40-8=36(件)となる。
        assertFalse("検査失敗", inspector.isSuccess());

        // NGとなるケース(実値に翌日の00:00:00を指定して、inspect()を実行)
        for (AllTypesWNoerr model : getActualList()) {
            Calendar cal = Calendar.getInstance();
            cal.setTimeInMillis(System.currentTimeMillis());
            int y = cal.get(Calendar.YEAR);
            int m = cal.get(Calendar.MONTH);
            int d = cal.get(Calendar.DAY_OF_MONTH);
            int days = DateUtil.getDayFromDate(y, m + 1, d) + 1;
            DateTime dt = new DateTime();
            dt.setElapsedSeconds((long) days * 86400);
            model.getCDatetimeOption().modify(dt);

            Date date = new Date();
            date.setElapsedDays(days);
            model.getCDateOption().modify(date);
        }
        inspector.clear();

        // テストが日をまたいで実行された場合に期待したテストができなくなるので、
        // finishTimeにstartTimeと同じ値を入れ、日をまたがないでテストが終了
        // した状況を作り出す。
        inspector.setFinishTime(inspector.getStartTime());
        inspector.inspect(dataHolder);
        for (Cause cause : inspector.getCauses()) {
            System.out.println(cause.getMessage());
            String columnName = cause.getColumnInfo().getColumnName();
            if ("C_DATETIME".equals(columnName) || "C_DATE".equals(columnName)) {
                assertEquals("エラー原因のチェック", Type.NOT_IN_TEST_DAY, cause.getType());
            } else {
                assertEquals("エラー原因のチェック", Type.CONDITION_TODAY_ON_INVALID_COLUMN, cause.getType());
            }
        }
        assertEquals("エラー原因のリストの要素数", 40, inspector.getCauses().size());
        assertFalse("検査失敗", inspector.isSuccess());

        // OKとなるケース(実値に翌日の00:00:00を指定して、inspect()を実行、テストが日を跨ぐケース)
        for (AllTypesWNoerr model : getActualList()) {
            Calendar cal = Calendar.getInstance();
            cal.setTimeInMillis(System.currentTimeMillis());
            int y = cal.get(Calendar.YEAR);
            int m = cal.get(Calendar.MONTH);
            int d = cal.get(Calendar.DAY_OF_MONTH);
            int days = DateUtil.getDayFromDate(y, m + 1, d) + 1;
            DateTime dt = new DateTime();
            dt.setElapsedSeconds((long) days * 86400);
            model.getCDatetimeOption().modify(dt);

            Date date = new Date();
            date.setElapsedDays(days);
            model.getCDateOption().modify(date);
        }
        inspector.clear();
        // テストが日をまたいで実行された状況を作り出す。
        inspector.setFinishTime(inspector.getStartTime() + 86400 * 1000 );
        inspector.inspect(dataHolder);
        for (Cause cause : inspector.getCauses()) {
            System.out.println(cause.getMessage());
            String columnName = cause.getColumnInfo().getColumnName();
            if ("C_DATETIME".equals(columnName) || "C_DATE".equals(columnName)) {
                assertEquals("エラー原因のチェック", Type.NOT_IN_TEST_DAY, cause.getType());
            } else {
                assertEquals("エラー原因のチェック", Type.CONDITION_TODAY_ON_INVALID_COLUMN, cause.getType());
            }
        }


        // NGとなるケース(実値に未来時刻を指定して、inspect()を実行)
        for (AllTypesWNoerr model : getActualList()) {
            Calendar cal = Calendar.getInstance();
            cal.setTimeInMillis(System.currentTimeMillis());
            int y = cal.get(Calendar.YEAR);
            int m = cal.get(Calendar.MONTH);
            int d = cal.get(Calendar.DAY_OF_MONTH);
            int h = cal.get(Calendar.HOUR_OF_DAY);
            int min = cal.get(Calendar.MINUTE);
            int s = cal.get(Calendar.SECOND);
            int days = DateUtil.getDayFromDate(y + 1, m + 1, d); // 1年後を指定
            int secs = DateUtil.getSecondFromTime(h, min, s);
            DateTime dt = new DateTime();
            dt.setElapsedSeconds((long) days * 86400 + secs);
            model.getCDatetimeOption().modify(dt);

            Date date = new Date();
            date.setElapsedDays(days);
            model.getCDateOption().modify(date);
        }
        inspector.clear();
        inspector.inspect(dataHolder);
        for (Cause cause : inspector.getCauses()) {
            System.out.println(cause.getMessage());
            String columnName = cause.getColumnInfo().getColumnName();
            if ("C_DATETIME".equals(columnName) || "C_DATE".equals(columnName)) {
                assertEquals("エラー原因のチェック", Type.NOT_IN_TEST_DAY, cause.getType());
            } else {
                assertEquals("エラー原因のチェック", Type.CONDITION_TODAY_ON_INVALID_COLUMN, cause.getType());
            }
        }
        assertEquals("エラー原因のリストの要素数", 40, inspector.getCauses().size());
        assertFalse("検査失敗", inspector.isSuccess());

        // NGとなるケース(実値に翌日の00:00:00を指定して、inspect()を実行)
        for (AllTypesWNoerr model : getActualList()) {
            Calendar cal = Calendar.getInstance();
            cal.setTimeInMillis(System.currentTimeMillis());
            int y = cal.get(Calendar.YEAR);
            int m = cal.get(Calendar.MONTH);
            int d = cal.get(Calendar.DAY_OF_MONTH);
            int days = DateUtil.getDayFromDate(y, m + 1, d);
            DateTime dt = new DateTime();
            dt.setElapsedSeconds((long) days * 86400);
            model.getCDatetimeOption().modify(dt);

            Date date = new Date();
            date.setElapsedDays(days);
            model.getCDateOption().modify(date);
        }
        inspector.clear();
        inspector.inspect(dataHolder);
        for (Cause cause : inspector.getCauses()) {
View Full Code Here


        input.close();
    }

    private Date date(int year, int month, int day) {
        Date date = new Date();
        date.setElapsedDays(DateUtil.getDayFromDate(year, month, day));
        return date;
    }
View Full Code Here

        input.close();
    }

    private Date date(int year, int month, int day) {
        Date date = new Date();
        date.setElapsedDays(DateUtil.getDayFromDate(year, month, day));
        return date;
    }
View Full Code Here

TOP

Related Classes of com.asakusafw.runtime.value.Date

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.