Search in sources :

Example 6 with ApplicationForm

use of cz.metacentrum.perun.registrar.model.ApplicationForm in project perun by CESNET.

the class RegistrarBaseIntegrationTest method testEmbeddedGroupsSubmission.

@Test
public void testEmbeddedGroupsSubmission() 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 group1 = new Group("GroupA", "Cool folks");
    Group group2 = new Group("GroupB", "Cooler folks");
    groupsManager.createGroup(session, vo, group1);
    groupsManager.createGroup(session, vo, group2);
    registrarManager.addGroupsToAutoRegistration(session, List.of(group1, group2));
    // create user
    User user = new User(-1, "Jo", "Doe", "", "", "");
    user = perun.getUsersManagerBl().createUser(session, user);
    // prepare application
    Application application = prepareApplicationToVo(user);
    // set embedded groups as item in application and fill with our two groups
    String embGroupsValue = String.format("Group A#%d|Group B#%d", group1.getId(), group2.getId());
    List<ApplicationFormItemData> appItemsData = new ArrayList<>();
    appItemsData.add(new ApplicationFormItemData(embeddedGroupsItem, "Embedded groups", embGroupsValue, "0"));
    registrarManager.submitApplication(session, application, appItemsData);
    List<Group> expectedEmbeddedGroups = List.of(group1, group2);
    RegistrarManagerImpl registrarManagerImpl = AopTestUtils.getTargetObject(registrarManager);
    assertEquals(expectedEmbeddedGroups, registrarManagerImpl.getEmbeddedGroups(session, application.getId()));
    assertEquals(1, registrarManager.getApplicationsForUser(user).size());
    registrarManager.approveApplication(session, application.getId());
    assertEquals(3, registrarManager.getApplicationsForUser(user).size());
    assertEquals(1, registrarManager.getApplicationsForGroup(session, group1, List.of("NEW", "VERIFIED")).size());
    assertEquals(1, registrarManager.getApplicationsForGroup(session, group2, List.of("NEW", "VERIFIED")).size());
}
Also used : RegistrarManagerImpl(cz.metacentrum.perun.registrar.impl.RegistrarManagerImpl) 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) GroupsManager(cz.metacentrum.perun.core.api.GroupsManager) Test(org.junit.Test)

Example 7 with ApplicationForm

use of cz.metacentrum.perun.registrar.model.ApplicationForm in project perun by CESNET.

the class RegistrarBaseIntegrationTest method createVOformIntegrationTest.

@Test
public void createVOformIntegrationTest() throws PerunException {
    System.out.println("createVOformIntegrationTest()");
    // get form for VO (if not exists, it's created)
    ApplicationForm applicationForm = registrarManager.getFormForVo(vo);
    // put in standard options
    ApplicationFormItem i0 = new ApplicationFormItem();
    i0.setShortname("pokecI");
    i0.setType(ApplicationFormItem.Type.HTML_COMMENT);
    i0.getTexts(CS).setLabel("Vyplňte, prosím, přihlášku.");
    i0.getTexts(EN).setLabel("Fill in the initial application, please.");
    i0.setApplicationTypes(Collections.singletonList(INITIAL));
    registrarManager.addFormItem(session, applicationForm, i0);
    ApplicationFormItem i0b = new ApplicationFormItem();
    i0b.setShortname("pokecE");
    i0b.setType(ApplicationFormItem.Type.HTML_COMMENT);
    i0b.getTexts(CS).setLabel("Zkontrolujte, prosím, před podáním žádosti o prodloužení účtu, svoje údaje.");
    i0b.getTexts(EN).setLabel("Please check you personal data before applying for account extension.");
    i0b.setApplicationTypes(Collections.singletonList(AppType.EXTENSION));
    registrarManager.addFormItem(session, applicationForm, i0b);
    ApplicationFormItem i1 = new ApplicationFormItem();
    i1.setShortname("titleBefore");
    i1.setPerunDestinationAttribute("urn:perun:user:attribute-def:core:titleBefore");
    i1.setRequired(false);
    i1.setType(ApplicationFormItem.Type.TEXTFIELD);
    i1.getTexts(CS).setLabel("Titul před jménem");
    i1.getTexts(CS).setHelp("Ing.,RNDr.,pplk., atd.");
    i1.getTexts(EN).setLabel("Title before name");
    registrarManager.addFormItem(session, applicationForm, i1);
    ApplicationFormItem i2 = new ApplicationFormItem();
    i2.setShortname("displayName");
    i2.setPerunDestinationAttribute("urn:perun:user:attribute-def:core:displayName");
    i2.setType(ApplicationFormItem.Type.TEXTFIELD);
    i2.setHidden(ApplicationFormItem.Hidden.ALWAYS);
    i2.setUpdatable(false);
    i2.setRequired(true);
    i2.setFederationAttribute("Shib-Person-displayName");
    registrarManager.addFormItem(session, applicationForm, i2);
    ApplicationFormItem i2a = new ApplicationFormItem();
    i2a.setShortname("firstName");
    i2a.setPerunDestinationAttribute("urn:perun:user:attribute-def:core:firstName");
    i2a.setType(ApplicationFormItem.Type.TEXTFIELD);
    i2a.setRequired(true);
    i2a.setFederationAttribute("Shib-Person-givenName");
    i2a.getTexts(CS).setLabel("Jméno");
    i2a.getTexts(EN).setLabel("First name");
    registrarManager.addFormItem(session, applicationForm, i2a);
    ApplicationFormItem i2b = new ApplicationFormItem();
    i2b.setShortname("lastName");
    i2b.setPerunDestinationAttribute("urn:perun:user:attribute-def:core:lastName");
    i2b.setType(ApplicationFormItem.Type.TEXTFIELD);
    i2b.setRequired(true);
    i2b.setFederationAttribute("Shib-Person-sureName");
    i2b.getTexts(CS).setLabel("Příjmení");
    i2b.getTexts(EN).setLabel("Last name");
    registrarManager.addFormItem(session, applicationForm, i2b);
    ApplicationFormItem i3 = new ApplicationFormItem();
    i3.setShortname("titleAfter");
    i3.setPerunDestinationAttribute("urn:perun:user:attribute-def:core:titleAfter");
    i3.setRequired(false);
    i3.setType(ApplicationFormItem.Type.TEXTFIELD);
    i3.getTexts(CS).setLabel("Titul za jménem");
    i3.getTexts(CS).setHelp("Ph.D., CSc., DrSc., atd.");
    i3.getTexts(EN).setLabel("Title after name");
    registrarManager.addFormItem(session, applicationForm, i3);
    ApplicationFormItem i4 = new ApplicationFormItem();
    i4.setShortname("preferredMail");
    i4.setPerunDestinationAttribute("urn:perun:user:attribute-def:def:preferredMail");
    i4.setRequired(true);
    i4.setType(ApplicationFormItem.Type.VALIDATED_EMAIL);
    i4.getTexts(CS).setLabel("Email");
    i4.getTexts(CS).setHelp("Bude ověřen zasláním zprávy.");
    i4.getTexts(EN).setLabel("Email");
    i4.getTexts(EN).setHelp("Will be validated by sending an email message.");
    registrarManager.addFormItem(session, applicationForm, i4);
    ApplicationFormItem i5 = new ApplicationFormItem();
    i5.setShortname("organization");
    i5.setPerunDestinationAttribute("urn:perun:user:attribute-def:def:organization");
    i5.setType(ApplicationFormItem.Type.TEXTFIELD);
    i5.setUpdatable(false);
    i5.setDisabled(ApplicationFormItem.Disabled.ALWAYS);
    i5.setRequired(true);
    i5.setFederationAttribute("Shib-Person-o");
    i5.getTexts(CS).setLabel("Organizace");
    i5.getTexts(EN).setLabel("Organisation");
    registrarManager.addFormItem(session, applicationForm, i5);
    ApplicationFormItem i5c = new ApplicationFormItem();
    i5c.setShortname("mail");
    i5c.setPerunDestinationAttribute("urn:perun:user:attribute-def:def:mail");
    i5c.setType(ApplicationFormItem.Type.TEXTFIELD);
    i5c.setUpdatable(false);
    i5c.setHidden(ApplicationFormItem.Hidden.ALWAYS);
    i5c.setRequired(true);
    i5c.setFederationAttribute("Shib-InetOrgPerson-mail");
    registrarManager.addFormItem(session, applicationForm, i5c);
    ApplicationFormItem i6 = new ApplicationFormItem();
    i6.setShortname("vyuziti");
    i6.setPerunDestinationAttribute("urn:perun:member:attribute-def:opt:registrationNote");
    i6.setRequired(true);
    i6.setType(ApplicationFormItem.Type.TEXTAREA);
    i6.getTexts(CS).setLabel("Popis plánovaného využití MetaCentra");
    i6.getTexts(CS).setHelp("Uveďte stručně, jakou činností se hodláte v MetaCentru zabývat. Uveďte také Vaše nadstandardní požadavky, požadavky, které nejsou pokryty položkami formuláře, případně jiné skutečnosti, které považujete za podstatné pro vyřízení přihlášky.");
    i6.getTexts(EN).setLabel("Description of planned activity");
    i6.getTexts(EN).setHelp("Describe shortly activity which you plane to perform at MetaCentrum. Mention your nonstandard demands, requests which are not covered in this form, eventually anything you consider important for this registration too.");
    registrarManager.addFormItem(session, applicationForm, i6);
    ApplicationFormItem i7 = new ApplicationFormItem();
    i7.setShortname("phone");
    i7.setPerunDestinationAttribute("urn:perun:user:attribute-def:def:phone");
    i7.setRequired(true);
    i7.setRegex("\\+*[0-9 ]*");
    i7.setType(ApplicationFormItem.Type.TEXTFIELD);
    i7.getTexts(CS).setLabel("Telefon");
    i7.getTexts(EN).setLabel("Phone");
    registrarManager.addFormItem(session, applicationForm, i7);
    ApplicationFormItem i8 = new ApplicationFormItem();
    i8.setShortname("workplace");
    i8.setPerunDestinationAttribute("urn:perun:user:attribute-def:def:workplace");
    i8.setRequired(true);
    i8.setType(ApplicationFormItem.Type.TEXTAREA);
    i8.getTexts(CS).setLabel("Katedra/ústav/výzkumná skupina");
    i8.getTexts(EN).setLabel("Department/research group");
    registrarManager.addFormItem(session, applicationForm, i8);
    ApplicationFormItem i9 = new ApplicationFormItem();
    i9.setShortname("jazyk");
    i9.setPerunDestinationAttribute("urn:perun:user:attribute-def:def:preferredLanguage");
    i9.setRequired(true);
    i9.setType(ApplicationFormItem.Type.SELECTIONBOX);
    i9.getTexts(CS).setLabel("Preferovaný jazyk");
    i9.getTexts(CS).setHelp("Zvolte jazyk, ve kterém chcete dostávát novinky a upozornění.");
    i9.getTexts(CS).setOptions("cs#česky|en#anglicky");
    i9.getTexts(EN).setLabel("Preffered language");
    i9.getTexts(EN).setHelp("Choose the language in which you want to receive news and notifications.");
    i9.getTexts(EN).setOptions("en#English|cs#Czech");
    registrarManager.addFormItem(session, applicationForm, i9);
    ApplicationFormItem i10 = new ApplicationFormItem();
    i10.setShortname("username");
    i10.setRequired(true);
    i10.setRegex("[a-z][a-z0-9_]+");
    i10.setType(ApplicationFormItem.Type.TEXTFIELD);
    i10.setPerunDestinationAttribute("urn:perun:user:attribute-def:def:login-namespace:einfra");
    i10.getTexts(CS).setLabel("Zvolte si uživatelské jméno");
    i10.getTexts(CS).setHelp("Uživatelské jméno musí začínat malým písmenem, a obsahovat pouze malá písmena, číslice a podtržení. Doporučujeme délku nanejvýš 8 znaků.");
    i10.getTexts(EN).setLabel("Choose you user name");
    i10.getTexts(EN).setHelp("User name must begin with a small letter, and can contain only small letters, digits and underscores. We recommend length max 8 characters.");
    i10.setApplicationTypes(Collections.singletonList(INITIAL));
    registrarManager.addFormItem(session, applicationForm, i10);
    ApplicationFormItem i11 = new ApplicationFormItem();
    i11.setShortname("heslo");
    i11.setRequired(true);
    i11.setRegex("\\p{Print}{8,20}");
    i11.setType(ApplicationFormItem.Type.PASSWORD);
    i11.getTexts(CS).setLabel("Heslo");
    i11.getTexts(CS).setHelp("Heslo musí být 8 až 20 znaků dlouhé, a obsahovat aspoň 3 písmena a 1 znak jiný než písmeno.");
    i11.getTexts(EN).setLabel("Password");
    i11.getTexts(EN).setHelp("Password must be from 8 up to 20 characters long and contain printable characters only.");
    i11.setApplicationTypes(Collections.singletonList(INITIAL));
    registrarManager.addFormItem(session, applicationForm, i11);
    ApplicationFormItem i12 = new ApplicationFormItem();
    i12.setShortname("pokec");
    i12.setType(ApplicationFormItem.Type.HTML_COMMENT);
    i12.getTexts(CS).setLabel("Stiskem tlačítka 'Podat žádost o členství ve VO MetaCentrum' souhlaste s pravidly využití VO MetaCentrum.");
    i12.getTexts(EN).setLabel("By pressing the button you agree with MetaCentrum rules.");
    i12.setApplicationTypes(Collections.singletonList(INITIAL));
    registrarManager.addFormItem(session, applicationForm, i12);
    ApplicationFormItem i13 = new ApplicationFormItem();
    i13.setShortname("souhlasI");
    i13.setType(ApplicationFormItem.Type.SUBMIT_BUTTON);
    i13.getTexts(CS).setLabel("Podat žádost o členství ve VO MetaCentrum");
    i13.getTexts(EN).setLabel("Apply for membership in the MetaCentrum VO");
    i13.setApplicationTypes(Collections.singletonList(INITIAL));
    registrarManager.addFormItem(session, applicationForm, i13);
    ApplicationFormItem i13b = new ApplicationFormItem();
    i13b.setShortname("souhlasE");
    i13b.setType(ApplicationFormItem.Type.SUBMIT_BUTTON);
    i13b.getTexts(CS).setLabel("Podat žádost o prodloužení účtu");
    i13b.getTexts(EN).setLabel("Apply for account extension");
    i13b.setApplicationTypes(Collections.singletonList(AppType.EXTENSION));
    registrarManager.addFormItem(session, applicationForm, i13b);
    // update form not to auto aprove
    applicationForm.setAutomaticApproval(false);
    registrarManager.updateForm(session, applicationForm);
    // test returned app form
    assertEquals("Application form not same as expected", applicationForm, registrarManager.getFormForVo(vo));
    // test form items
    List<ApplicationFormItem> items = registrarManager.getFormItems(session, applicationForm);
    assertTrue("Item i0 was not returned from form", items.contains(i0));
    assertTrue("Item i0b was not returned from form", items.contains(i0b));
    assertTrue("Item i1 was not returned from form", items.contains(i1));
    assertTrue("Item i2 was not returned from form", items.contains(i2));
    assertTrue("Item i2a was not returned from form", items.contains(i2a));
    assertTrue("Item i2b was not returned from form", items.contains(i2b));
    assertTrue("Item i3 was not returned from form", items.contains(i3));
    assertTrue("Item i4 was not returned from form", items.contains(i4));
    assertTrue("Item i5 was not returned from form", items.contains(i5));
    assertTrue("Item i5c was not returned from form", items.contains(i5c));
    assertTrue("Item i6 was not returned from form", items.contains(i6));
    assertTrue("Item i7 was not returned from form", items.contains(i7));
    assertTrue("Item i8 was not returned from form", items.contains(i8));
    assertTrue("Item i9 was not returned from form", items.contains(i9));
    assertTrue("Item i10 was not returned from form", items.contains(i10));
    assertTrue("Item i11 was not returned from form", items.contains(i11));
    assertTrue("Item i12 was not returned from form", items.contains(i12));
    assertTrue("Item i13 was not returned from form", items.contains(i13));
    assertTrue("Item i13b was not returned from form", items.contains(i13b));
    Random random = new Random();
    PerunSession applicant = perun.getPerunSession(new PerunPrincipal("rumcajs" + random.nextInt(100000) + "@raholec.cz", "http://www.raholec.cz/idp/", ExtSourcesManager.EXTSOURCE_IDP), new PerunClient());
}
Also used : ApplicationForm(cz.metacentrum.perun.registrar.model.ApplicationForm) ApplicationFormItem(cz.metacentrum.perun.registrar.model.ApplicationFormItem) PerunSession(cz.metacentrum.perun.core.api.PerunSession) PerunClient(cz.metacentrum.perun.core.api.PerunClient) PerunPrincipal(cz.metacentrum.perun.core.api.PerunPrincipal) Test(org.junit.Test)

Example 8 with ApplicationForm

use of cz.metacentrum.perun.registrar.model.ApplicationForm in project perun by CESNET.

the class RegistrarBaseIntegrationTest method getApplicationsPageApplicationFormSearch.

@Test
public void getApplicationsPageApplicationFormSearch() throws Exception {
    System.out.println("getApplicationsPageApplicationFormSearch");
    ApplicationForm form = registrarManager.getFormForVo(vo);
    Group group1 = setUpGroup("Group1", "Cool folks");
    Group group2 = setUpGroup("Group2", "Cooler folks");
    User user1 = setUpUser("Joe", "Doe");
    User user2 = setUpUser("Barney", "Stinson");
    // set up application
    ApplicationFormItem testItem = new ApplicationFormItem();
    testItem.setType(ApplicationFormItem.Type.TEXTFIELD);
    testItem.setShortname("testItem");
    testItem = registrarManager.addFormItem(session, form, testItem);
    registrarManager.updateFormItems(session, form, Collections.singletonList(testItem));
    ApplicationFormItemData testData = new ApplicationFormItemData(testItem, "test", "testval", "0");
    ApplicationFormItem testItem2 = new ApplicationFormItem();
    testItem2.setType(ApplicationFormItem.Type.TEXTFIELD);
    testItem2.setShortname("testItem2");
    testItem2 = registrarManager.addFormItem(session, form, testItem2);
    registrarManager.updateFormItems(session, form, Collections.singletonList(testItem2));
    ApplicationFormItemData testData2 = new ApplicationFormItemData(testItem2, "test2", "banana", "0");
    List<ApplicationFormItemData> appItemsData = new ArrayList<>();
    appItemsData.add(testData);
    appItemsData.add(testData2);
    Application application1 = setUpApplicationGroupWithData(user1, group1, appItemsData);
    Application application2 = setUpApplicationGroup(user2, group2);
    ApplicationsPageQuery query = new ApplicationsPageQuery(4, 0, SortingOrder.DESCENDING, ApplicationsOrderColumn.STATE, "testval", List.of(Application.AppState.VERIFIED, Application.AppState.APPROVED), true);
    query.setGetDetails(true);
    Paginated<RichApplication> result = registrarManager.getApplicationsPage(session, vo, query);
    List<User> returnedIds = result.getData().stream().map(Application::getUser).toList();
    assertThat(returnedIds).containsOnly(user1);
    assertThat(result.getData().get(0).getFormData().size()).isEqualTo(2);
}
Also used : RichApplication(cz.metacentrum.perun.registrar.model.RichApplication) ApplicationForm(cz.metacentrum.perun.registrar.model.ApplicationForm) Group(cz.metacentrum.perun.core.api.Group) ApplicationFormItem(cz.metacentrum.perun.registrar.model.ApplicationFormItem) ApplicationsPageQuery(cz.metacentrum.perun.registrar.model.ApplicationsPageQuery) 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) Test(org.junit.Test)

Example 9 with ApplicationForm

use of cz.metacentrum.perun.registrar.model.ApplicationForm in project perun by CESNET.

the class RegistrarBaseIntegrationTest method saveDependencyOnUnsavedItemWithTempId.

@Test
public void saveDependencyOnUnsavedItemWithTempId() throws Exception {
    ApplicationForm form = registrarManager.getFormForVo(vo);
    ApplicationFormItem savedItem = new ApplicationFormItem();
    savedItem.setShortname("saved");
    savedItem = registrarManager.addFormItem(session, form, savedItem);
    registrarManager.updateFormItems(session, form, new ArrayList<>(Arrays.asList(savedItem)));
    ApplicationFormItem firstUnsavedItem = new ApplicationFormItem();
    firstUnsavedItem.setShortname("unsaved1");
    firstUnsavedItem.setId(-1);
    ApplicationFormItem secondUnsavedItem = new ApplicationFormItem();
    secondUnsavedItem.setShortname("unsaved2");
    secondUnsavedItem.setId(-2);
    savedItem.setHidden(ApplicationFormItem.Hidden.IF_PREFILLED);
    savedItem.setHiddenDependencyItemId(-1);
    secondUnsavedItem.setHidden(ApplicationFormItem.Hidden.IF_PREFILLED);
    secondUnsavedItem.setHiddenDependencyItemId(-1);
    savedItem.setDisabled(ApplicationFormItem.Disabled.IF_PREFILLED);
    savedItem.setDisabledDependencyItemId(-2);
    firstUnsavedItem.setDisabled(ApplicationFormItem.Disabled.IF_PREFILLED);
    firstUnsavedItem.setDisabledDependencyItemId(-2);
    registrarManager.updateFormItems(session, form, new ArrayList<>(Arrays.asList(savedItem, firstUnsavedItem, secondUnsavedItem)));
    var items = registrarManager.getFormItems(session, registrarManager.getFormForVo(vo));
    assertThat(items).hasSize(3);
    // ids were changed from negative to positive
    assertThat(items.get(1).getId()).isGreaterThan(0);
    assertThat(items.get(2).getId()).isGreaterThan(0);
    // dependencies are valid
    assertThat(items.get(0).getHiddenDependencyItemId()).isEqualTo(items.get(1).getId());
    assertThat(items.get(2).getHiddenDependencyItemId()).isEqualTo(items.get(1).getId());
    assertThat(items.get(0).getDisabledDependencyItemId()).isEqualTo(items.get(2).getId());
    assertThat(items.get(1).getDisabledDependencyItemId()).isEqualTo(items.get(2).getId());
}
Also used : ApplicationForm(cz.metacentrum.perun.registrar.model.ApplicationForm) ApplicationFormItem(cz.metacentrum.perun.registrar.model.ApplicationFormItem) Test(org.junit.Test)

Example 10 with ApplicationForm

use of cz.metacentrum.perun.registrar.model.ApplicationForm 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);
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) JdbcPerunTemplate(org.springframework.jdbc.core.JdbcPerunTemplate) INITIAL(cz.metacentrum.perun.registrar.model.Application.AppType.INITIAL) Vo(cz.metacentrum.perun.core.api.Vo) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) Mockito.spy(org.mockito.Mockito.spy) GroupExistsException(cz.metacentrum.perun.core.api.exceptions.GroupExistsException) Group(cz.metacentrum.perun.core.api.Group) Compatibility(cz.metacentrum.perun.core.impl.Compatibility) LinkedHashMap(java.util.LinkedHashMap) ExtSource(cz.metacentrum.perun.core.api.ExtSource) ExtSourcesManager(cz.metacentrum.perun.core.api.ExtSourcesManager) Map(java.util.Map) AppAutoRejectionScheduler(cz.metacentrum.perun.registrar.impl.AppAutoRejectionScheduler) ApplicationForm(cz.metacentrum.perun.registrar.model.ApplicationForm) ApplicationFormItemWithPrefilledValue(cz.metacentrum.perun.registrar.model.ApplicationFormItemWithPrefilledValue) Before(org.junit.Before) Attribute(cz.metacentrum.perun.core.api.Attribute) ApplicationFormItem(cz.metacentrum.perun.registrar.model.ApplicationFormItem) ReflectionTestUtils(org.springframework.test.util.ReflectionTestUtils) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) AttributesManager(cz.metacentrum.perun.core.api.AttributesManager) Auditer(cz.metacentrum.perun.core.impl.Auditer) ApplicationFormItemData(cz.metacentrum.perun.registrar.model.ApplicationFormItemData) Collectors(java.util.stream.Collectors) User(cz.metacentrum.perun.core.api.User) Mockito.verify(org.mockito.Mockito.verify) Application(cz.metacentrum.perun.registrar.model.Application) List(java.util.List) LocalDate(java.time.LocalDate) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) ApplicationForm(cz.metacentrum.perun.registrar.model.ApplicationForm) Attribute(cz.metacentrum.perun.core.api.Attribute) ApplicationFormItemData(cz.metacentrum.perun.registrar.model.ApplicationFormItemData) LocalDate(java.time.LocalDate) Application(cz.metacentrum.perun.registrar.model.Application) LinkedHashMap(java.util.LinkedHashMap)

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