Search in sources :

Example 21 with ApplicationForm

use of cz.metacentrum.perun.registrar.model.ApplicationForm 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 22 with ApplicationForm

use of cz.metacentrum.perun.registrar.model.ApplicationForm 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

ApplicationForm (cz.metacentrum.perun.registrar.model.ApplicationForm)22 Test (org.junit.Test)13 ApplicationFormItem (cz.metacentrum.perun.registrar.model.ApplicationFormItem)11 Group (cz.metacentrum.perun.core.api.Group)8 ApplicationFormItemData (cz.metacentrum.perun.registrar.model.ApplicationFormItemData)7 User (cz.metacentrum.perun.core.api.User)6 Application (cz.metacentrum.perun.registrar.model.Application)6 GroupsManager (cz.metacentrum.perun.core.api.GroupsManager)5 RichApplication (cz.metacentrum.perun.registrar.model.RichApplication)5 ApplicationMail (cz.metacentrum.perun.registrar.model.ApplicationMail)4 ExtSource (cz.metacentrum.perun.core.api.ExtSource)2 Vo (cz.metacentrum.perun.core.api.Vo)2 ApplicationMailNotExistsException (cz.metacentrum.perun.registrar.exceptions.ApplicationMailNotExistsException)2 RegistrarException (cz.metacentrum.perun.registrar.exceptions.RegistrarException)2 MailText (cz.metacentrum.perun.registrar.model.ApplicationMail.MailText)2 DuplicateKeyException (org.springframework.dao.DuplicateKeyException)2 EmptyResultDataAccessException (org.springframework.dao.EmptyResultDataAccessException)2 MailForGroupIdUpdated (cz.metacentrum.perun.audit.events.MailManagerEvents.MailForGroupIdUpdated)1 MailForVoIdUpdated (cz.metacentrum.perun.audit.events.MailManagerEvents.MailForVoIdUpdated)1 MailSentForApplication (cz.metacentrum.perun.audit.events.MailManagerEvents.MailSentForApplication)1