use of org.mifos.dto.domain.CustomFieldDto in project head by mifos.
the class AddGroupMembershipActionStrutsTest method getCustomFields.
private List<CustomFieldDto> getCustomFields() {
List<CustomFieldDto> fields = new ArrayList<CustomFieldDto>();
fields.add(new CustomFieldDto(Short.valueOf("5"), "value1", CustomFieldType.ALPHA_NUMERIC.getValue()));
fields.add(new CustomFieldDto(Short.valueOf("6"), "value2", CustomFieldType.ALPHA_NUMERIC.getValue()));
return fields;
}
use of org.mifos.dto.domain.CustomFieldDto in project head by mifos.
the class GroupActionStrutsTest method testPreviewManageSuccessForNameChange_AfterTrainedSet.
/**
* This test asserts that when a group name for a trained group is edited, there are no errors and the trained date
* is present in the action form.
*/
@Test
public void testPreviewManageSuccessForNameChange_AfterTrainedSet() throws Exception {
Calendar cal = new GregorianCalendar();
cal.set(Calendar.DAY_OF_MONTH, 2);
cal.set(Calendar.MONTH, 5);
cal.set(Calendar.YEAR, 2008);
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
createTrainedGroupAndSetInSession(cal.getTime());
setRequestPathInfo("/groupCustAction.do");
addRequestParameter("method", "manage");
addRequestParameter("officeId", "3");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
List<CustomFieldDto> customFieldDefs = getCustomFieldsFromSession();
setRequestPathInfo("/groupCustAction.do");
addRequestParameter("method", "previewManage");
addRequestParameter("officeId", "3");
// editing group name
addRequestParameter("displayName", "group123");
int i = 0;
for (CustomFieldDto customFieldDef : customFieldDefs) {
addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
addRequestParameter("customField[" + i + "].fieldValue", "Req");
i++;
}
addRequestParameter("trained", "1");
addRequestParameter("trainedDate", "2/6/2008");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
GroupCustActionForm actionForm = (GroupCustActionForm) getActionForm();
Assert.assertEquals("2/6/2008", actionForm.getTrainedDate());
Assert.assertEquals(0, getErrorSize());
}
use of org.mifos.dto.domain.CustomFieldDto in project head by mifos.
the class GroupActionStrutsTest method testPreviewManageFailureForName.
@Test
public void testPreviewManageFailureForName() throws Exception {
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
createGroupWithCenterAndSetInSession();
setRequestPathInfo("/groupCustAction.do");
addRequestParameter("method", "manage");
addRequestParameter("officeId", "3");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
List<CustomFieldDto> customFieldDefs = getCustomFieldsFromSession();
setRequestPathInfo("/groupCustAction.do");
addRequestParameter("method", "previewManage");
addRequestParameter("officeId", "3");
addRequestParameter("displayName", "");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
int i = 0;
for (CustomFieldDto customFieldDef : customFieldDefs) {
addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
addRequestParameter("customField[" + i + "].fieldValue", "Req");
i++;
}
addRequestParameter("trained", "1");
addRequestParameter("trainedDate", "20/3/2006");
actionPerform();
Assert.assertEquals(1, getErrorSize());
Assert.assertEquals("Group Name not present", 1, getErrorSize(CustomerConstants.NAME));
}
use of org.mifos.dto.domain.CustomFieldDto in project head by mifos.
the class GroupActionStrutsTest method testFailurePreview_WithoutMandatoryCustomField_IfAny.
@Test
public void testFailurePreview_WithoutMandatoryCustomField_IfAny() throws Exception {
createParentCustomer();
StaticHibernateUtil.flushAndClearSession();
setRequestPathInfo("/groupCustAction.do");
addRequestParameter("method", "load");
addRequestParameter("centerSystemId", center.getGlobalCustNum());
actionPerform();
List<CustomFieldDto> customFieldDefs = getCustomFieldsFromSession();
boolean isCustomFieldMandatory = false;
for (CustomFieldDto customFieldDef : customFieldDefs) {
if (customFieldDef.isMandatory()) {
isCustomFieldMandatory = true;
break;
}
}
setRequestPathInfo("/groupCustAction.do");
addRequestParameter("method", "preview");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
addRequestParameter("displayName", "group");
addRequestParameter("status", CustomerStatus.GROUP_PENDING.getValue().toString());
addRequestParameter("formedByPersonnel", center.getPersonnel().getPersonnelId().toString());
addRequestParameter("loanOfficerId", center.getLoanOfficerId().toString());
int i = 0;
for (CustomFieldDto customFieldDef : customFieldDefs) {
addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
addRequestParameter("customField[" + i + "].fieldValue", "");
i++;
}
actionPerform();
if (isCustomFieldMandatory) {
Assert.assertEquals("CustomField", 1, getErrorSize(CustomerConstants.CUSTOM_FIELD));
verifyInputForward();
} else {
Assert.assertEquals("CustomField", 0, getErrorSize(CustomerConstants.CUSTOM_FIELD));
verifyForward(ActionForwards.preview_success.toString());
}
center = TestObjectFactory.getCenter(center.getCustomerId());
}
use of org.mifos.dto.domain.CustomFieldDto in project head by mifos.
the class GroupActionStrutsTest method testFailureCreate_DuplicateName.
@Test
public void testFailureCreate_DuplicateName() throws Exception {
createGroupWithCenter();
setRequestPathInfo("/groupCustAction.do");
addRequestParameter("method", "load");
addRequestParameter("centerSystemId", center.getGlobalCustNum());
actionPerform();
List<CustomFieldDto> customFieldDefs = getCustomFieldsFromSession();
setRequestPathInfo("/groupCustAction.do");
addRequestParameter("method", "preview");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
addRequestParameter("displayName", "group");
addRequestParameter("status", CustomerStatus.GROUP_PENDING.getValue().toString());
addRequestParameter("formedByPersonnel", center.getPersonnel().getPersonnelId().toString());
int i = 0;
for (CustomFieldDto customFieldDef : customFieldDefs) {
addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
addRequestParameter("customField[" + i + "].fieldValue", "11");
i++;
}
actionPerform();
setRequestPathInfo("/groupCustAction.do");
addRequestParameter("method", "create");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
verifyActionErrors(new String[] { CustomerConstants.ERRORS_DUPLICATE_CUSTOMER });
verifyForward(ActionForwards.create_failure.toString());
group = TestObjectFactory.getGroup(group.getCustomerId());
center = TestObjectFactory.getCenter(center.getCustomerId());
GroupCustActionForm actionForm = (GroupCustActionForm) request.getSession().getAttribute("groupCustActionForm");
actionForm.setParentCustomer(null);
}
Aggregations