use of org.dbflute.cbean.chelper.HpManualOrderThemeListHandler in project dbflute-core by dbflute.
the class ManualOrderOptionTest method test_DateFromTo.
public void test_DateFromTo() throws Exception {
// ## Arrange ##
Date fromDate = DfTypeUtil.toDate("1969/01/01");
Date toDate = DfTypeUtil.toDate("1970/12/31");
ManualOrderOption mob = new ManualOrderOption();
// ## Act ##
mob.when_FromTo(fromDate, toDate, op -> op.compareAsDate());
// ## Assert ##
List<HpMobCaseWhenElement> caseWhenAcceptedList = mob.getCaseWhenAcceptedList();
{
assertEquals(1, caseWhenAcceptedList.size());
final HpMobCaseWhenElement fromElement = caseWhenAcceptedList.get(0);
assertEquals(ConditionKey.CK_GREATER_EQUAL, fromElement.getConditionKey());
assertNull(fromElement.getConnectionMode());
HpMobCaseWhenElement toElement = fromElement.getConnectedElementList().get(0);
assertEquals(ConditionKey.CK_LESS_THAN, toElement.getConditionKey());
assertEquals(HpMobConnectionMode.AND, toElement.getConnectionMode());
assertEquals(0, mob.getCaseWhenBoundList().size());
String fromExp = DfTypeUtil.toString(fromElement.getOrderValue(), "yyyy/MM/dd");
String toExp = DfTypeUtil.toString(toElement.getOrderValue(), "yyyy/MM/dd");
assertEquals("1969/01/01", fromExp);
assertEquals("1971/01/01", toExp);
}
// ## Act ##
mob.bind(new HpManualOrderThemeListHandler() {
int index = 0;
public String register(String themeKey, Object orderValue) {
++index;
return "foo" + index;
}
});
// ## Assert ##
List<HpMobCaseWhenElement> caseWhenBoundList = mob.getCaseWhenBoundList();
{
assertNotSame(0, caseWhenBoundList.size());
assertEquals(1, caseWhenBoundList.size());
final HpMobCaseWhenElement fromElement = caseWhenBoundList.get(0);
assertEquals(ConditionKey.CK_GREATER_EQUAL, fromElement.getConditionKey());
assertNull(fromElement.getConnectionMode());
HpMobCaseWhenElement toElement = fromElement.getConnectedElementList().get(0);
assertEquals(ConditionKey.CK_LESS_THAN, toElement.getConditionKey());
assertEquals(HpMobConnectionMode.AND, toElement.getConnectionMode());
}
}
Aggregations