use of cz.metacentrum.perun.registrar.model.ApplicationFormItem in project perun by CESNET.
the class AppAutoRejectionSchedulerTest method voAdminIgnoredCustomMessageByPreferredLangFromApplication.
@Test
public void voAdminIgnoredCustomMessageByPreferredLangFromApplication() throws Exception {
System.out.println(CLASS_NAME + "voAdminIgnoredCustomMessageByPreferredLangFromApplication");
ApplicationForm voform = registrarManager.getFormForVo(vo);
registrarManager.addFormItem(session, voform, new ApplicationFormItem(-1, "lang", true, ApplicationFormItem.Type.TEXTFIELD, null, null, A_U_D_PREF_LANG, ""));
setUpAndSubmitAppForPotentialAutoRejection(70, null, VO_APP_EXP_RULES, "cs", null);
String messageTemplate = "Vase zadost do %vo_name% byla zamitnuta";
String expectedReason = "Vase zadost do " + vo.getName() + " byla zamitnuta";
setVoMessagesAttribute("ignoredByAdmin-cs", messageTemplate);
ReflectionTestUtils.invokeMethod(spyScheduler, "voApplicationsAutoRejection", List.of(vo));
verify(mockMailManager).sendMessage(any(), any(), eq(expectedReason), eq(null));
}
use of cz.metacentrum.perun.registrar.model.ApplicationFormItem in project perun by CESNET.
the class RegistrarBaseIntegrationTest method copyItemsCorrectDependencyIds.
@Test
public void copyItemsCorrectDependencyIds() throws Exception {
ApplicationForm form = registrarManager.getFormForVo(vo);
ApplicationFormItem firstItem = new ApplicationFormItem();
firstItem.setShortname("dependency");
firstItem = registrarManager.addFormItem(session, form, firstItem);
ApplicationFormItem otherItem = new ApplicationFormItem();
otherItem.setShortname("dep");
otherItem.setHidden(ApplicationFormItem.Hidden.IF_PREFILLED);
otherItem.setHiddenDependencyItemId(firstItem.getId());
otherItem.setDisabledDependencyItemId(firstItem.getId());
registrarManager.addFormItem(session, form, otherItem);
Vo otherVo = perun.getVosManagerBl().createVo(session, new Vo(-1, "other", ""));
registrarManager.copyFormFromVoToVo(session, vo, otherVo);
var items = registrarManager.getFormItems(session, registrarManager.getFormForVo(otherVo));
assertThat(items).hasSize(2);
assertThat(items.get(1).getHiddenDependencyItemId()).isEqualTo(items.get(0).getId());
assertThat(items.get(1).getDisabledDependencyItemId()).isEqualTo(items.get(0).getId());
}
use of cz.metacentrum.perun.registrar.model.ApplicationFormItem in project perun by CESNET.
the class RegistrarBaseIntegrationTest method testEmbeddedGroupsSubmission_groupAutoApprove.
@Test
public void testEmbeddedGroupsSubmission_groupAutoApprove() throws PerunException {
GroupsManager groupsManager = perun.getGroupsManager();
ApplicationForm form = registrarManager.getFormForVo(vo);
// create embedded groups form item
ApplicationFormItem embeddedGroupsItem = new ApplicationFormItem();
embeddedGroupsItem.setType(ApplicationFormItem.Type.EMBEDDED_GROUP_APPLICATION);
embeddedGroupsItem.setShortname("embeddedGroups");
embeddedGroupsItem = registrarManager.addFormItem(session, form, embeddedGroupsItem);
registrarManager.updateFormItems(session, form, Collections.singletonList(embeddedGroupsItem));
// create groups in VO
Group group = new Group("GroupA", "Cool folks");
groupsManager.createGroup(session, vo, group);
registrarManager.addGroupsToAutoRegistration(session, List.of(group));
// allow auto-approve
ApplicationForm groupForm = registrarManager.getFormForGroup(group);
groupForm.setAutomaticApprovalEmbedded(true);
registrarManager.updateForm(session, groupForm);
// create user
final User user = new User(-1, "Jo", "Doe", "", "", "");
perun.getUsersManagerBl().createUser(session, user);
Application application = prepareApplicationToVo(user);
String embGroupsValue = String.format("Group A#%d", group.getId());
List<ApplicationFormItemData> appItemsData = new ArrayList<>();
appItemsData.add(new ApplicationFormItemData(embeddedGroupsItem, "Embedded groups", embGroupsValue, "0"));
registrarManager.submitApplication(session, application, appItemsData);
registrarManager.approveApplication(session, application.getId());
List<Member> groupMembers = groupsManager.getGroupMembers(session, group);
assertThat(groupMembers).anyMatch(member -> member.getUserId() == user.getId());
}
Aggregations