Search in sources :

Example 21 with ApplicationFormItem

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));
}
Also used : ApplicationForm(cz.metacentrum.perun.registrar.model.ApplicationForm) ApplicationFormItem(cz.metacentrum.perun.registrar.model.ApplicationFormItem) Test(org.junit.Test)

Example 22 with ApplicationFormItem

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());
}
Also used : ApplicationForm(cz.metacentrum.perun.registrar.model.ApplicationForm) ApplicationFormItem(cz.metacentrum.perun.registrar.model.ApplicationFormItem) Vo(cz.metacentrum.perun.core.api.Vo) Test(org.junit.Test)

Example 23 with ApplicationFormItem

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());
}
Also used : ApplicationForm(cz.metacentrum.perun.registrar.model.ApplicationForm) ApplicationFormItem(cz.metacentrum.perun.registrar.model.ApplicationFormItem) Group(cz.metacentrum.perun.core.api.Group) User(cz.metacentrum.perun.core.api.User) ApplicationFormItemData(cz.metacentrum.perun.registrar.model.ApplicationFormItemData) Application(cz.metacentrum.perun.registrar.model.Application) RichApplication(cz.metacentrum.perun.registrar.model.RichApplication) Member(cz.metacentrum.perun.core.api.Member) GroupsManager(cz.metacentrum.perun.core.api.GroupsManager) Test(org.junit.Test)

Aggregations

ApplicationFormItem (cz.metacentrum.perun.registrar.model.ApplicationFormItem)23 ApplicationForm (cz.metacentrum.perun.registrar.model.ApplicationForm)10 ApplicationFormItemData (cz.metacentrum.perun.registrar.model.ApplicationFormItemData)10 Test (org.junit.Test)10 Group (cz.metacentrum.perun.core.api.Group)5 Application (cz.metacentrum.perun.registrar.model.Application)5 RichApplication (cz.metacentrum.perun.registrar.model.RichApplication)5 User (cz.metacentrum.perun.core.api.User)4 AppType (cz.metacentrum.perun.registrar.model.Application.AppType)4 DuplicateKeyException (org.springframework.dao.DuplicateKeyException)4 EmptyResultDataAccessException (org.springframework.dao.EmptyResultDataAccessException)4 MailException (org.springframework.mail.MailException)4 GroupsManager (cz.metacentrum.perun.core.api.GroupsManager)3 RegistrarException (cz.metacentrum.perun.registrar.exceptions.RegistrarException)3 ItemTexts (cz.metacentrum.perun.registrar.model.ApplicationFormItem.ItemTexts)3 RegistrarModule (cz.metacentrum.perun.registrar.RegistrarModule)2 ApplicationMailAlreadyRemovedException (cz.metacentrum.perun.registrar.exceptions.ApplicationMailAlreadyRemovedException)2 ApplicationMailExistsException (cz.metacentrum.perun.registrar.exceptions.ApplicationMailExistsException)2 ApplicationMailNotExistsException (cz.metacentrum.perun.registrar.exceptions.ApplicationMailNotExistsException)2 FormNotExistsException (cz.metacentrum.perun.registrar.exceptions.FormNotExistsException)2