use of cz.metacentrum.perun.registrar.model.Application.AppType.INITIAL in project perun by CESNET.
the class AppAutoRejectionSchedulerTest method setUpAndSubmitAppForPotentialAutoRejection.
/**
* In the first step method sets the return value for getCurrentLocalDay method. Then sets the application expiration
* attribute for Vo or Group and creates and submits application. If the application has an item mapping to
* user:preferredLanguage attribute, set it the given lang value.
*
* @param days number of days for move today
* @param group optional group
* @param attribute application expiration attribute for Vo or Group
* @return submitted application
* @throws Exception exception
*/
private Application setUpAndSubmitAppForPotentialAutoRejection(int days, Group group, String attribute, String lang, User user) throws Exception {
// change today date for test
LocalDate today = LocalDate.now().plusDays(days);
when(spyScheduler.getCurrentLocalDate()).thenReturn(today);
// set application expiration attribute for Vo
Attribute appExp = new Attribute(perun.getAttributesManager().getAttributeDefinition(session, attribute));
Map<String, String> attrValue = new LinkedHashMap<>();
attrValue.put("emailVerification", "14");
attrValue.put("ignoredByAdmin", "60");
appExp.setValue(attrValue);
if (group != null) {
perun.getAttributesManagerBl().setAttribute(session, group, appExp);
} else {
perun.getAttributesManagerBl().setAttribute(session, vo, appExp);
}
// create application
Application application = new Application();
application.setType(INITIAL);
application.setCreatedBy("testUser");
application.setVo(vo);
// get application form item data
ApplicationForm applicationForm;
if (group != null) {
application.setGroup(group);
registrarManager.createApplicationFormInGroup(session, group);
applicationForm = registrarManager.getFormForGroup(group);
} else {
applicationForm = registrarManager.getFormForVo(vo);
}
List<ApplicationFormItemData> data = registrarManager.getFormItemsWithPrefilledValues(session, INITIAL, applicationForm).stream().map(item -> convertAppFormItemWithPrefValToAppFormItemData(item, lang)).collect(Collectors.toList());
application.setUser(user);
return registrarManager.submitApplication(session, application, data);
}
Aggregations