Search in sources :

Example 1 with RichApplication

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

the class RegistrarBaseIntegrationTest method getApplicationsPageBasedOnSearchString.

@Test
public void getApplicationsPageBasedOnSearchString() throws Exception {
    System.out.println("getApplicationsPageBasedOnSearchString");
    // create groups
    Group group1 = setUpGroup("Group1", "Cool folks");
    // create users
    User user1 = setUpUser("Joe", "Doe");
    User user2 = setUpUser("Barney", "Stinson");
    setUpApplicationGroup(user1, group1);
    setUpApplicationGroup(user2, group1);
    ApplicationsPageQuery query = new ApplicationsPageQuery(4, 0, SortingOrder.DESCENDING, ApplicationsOrderColumn.ID, "barn", List.of(Application.AppState.APPROVED), true);
    Paginated<RichApplication> result = registrarManager.getApplicationsPage(session, vo, query);
    List<User> returnedUsers = result.getData().stream().map(Application::getUser).toList();
    assertThat(returnedUsers).containsOnly(user2);
}
Also used : RichApplication(cz.metacentrum.perun.registrar.model.RichApplication) Group(cz.metacentrum.perun.core.api.Group) ApplicationsPageQuery(cz.metacentrum.perun.registrar.model.ApplicationsPageQuery) User(cz.metacentrum.perun.core.api.User) Test(org.junit.Test)

Example 2 with RichApplication

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

the class RegistrarBaseIntegrationTest method getApplicationsPageFindByGroupDescription.

@Test
public void getApplicationsPageFindByGroupDescription() throws Exception {
    System.out.println("getApplicationsPageFindByGroupDescription");
    // create groups
    Group group1 = setUpGroup("Group1", "Cool folks");
    Group group2 = setUpGroup("Group2", "Cooler folks");
    // create users
    User user1 = setUpUser("Joe", "Doe");
    User user2 = setUpUser("Barney", "Stinson");
    setUpApplicationGroup(user1, group1);
    setUpApplicationGroup(user2, group2);
    ApplicationsPageQuery query = new ApplicationsPageQuery(4, 0, SortingOrder.DESCENDING, ApplicationsOrderColumn.ID, "cooler", List.of(Application.AppState.APPROVED, Application.AppState.VERIFIED), true);
    Paginated<RichApplication> result = registrarManager.getApplicationsPage(session, vo, query);
    List<Group> returnedGroups = result.getData().stream().map(Application::getGroup).filter(Predicate.not(Objects::isNull)).toList();
    assertThat(returnedGroups).containsOnly(group2);
}
Also used : RichApplication(cz.metacentrum.perun.registrar.model.RichApplication) Group(cz.metacentrum.perun.core.api.Group) ApplicationsPageQuery(cz.metacentrum.perun.registrar.model.ApplicationsPageQuery) User(cz.metacentrum.perun.core.api.User) Application(cz.metacentrum.perun.registrar.model.Application) RichApplication(cz.metacentrum.perun.registrar.model.RichApplication) Test(org.junit.Test)

Example 3 with RichApplication

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

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

the class RegistrarBaseIntegrationTest method getApplicationsPageOffsetWorks.

@Test
public void getApplicationsPageOffsetWorks() throws Exception {
    System.out.println("getApplicationsPageOffsetWorks");
    // create groups
    Group group1 = setUpGroup("Group1", "Cool folks");
    // create users
    User user1 = setUpUser("Joe", "Doe");
    User user2 = setUpUser("Barney", "Stinson");
    Application voApplication1 = setUpApplicationGroup(user1, group1);
    Application voApplication2 = setUpApplicationGroup(user2, group1);
    ApplicationsPageQuery query = new ApplicationsPageQuery(1, 1, SortingOrder.ASCENDING, ApplicationsOrderColumn.ID, List.of(Application.AppState.APPROVED), true);
    Paginated<RichApplication> result = registrarManager.getApplicationsPage(session, vo, query);
    assertThat(result.getData()).hasSize(1);
    assertThat(result.getData().get(0).getUser().getId()).isEqualTo(voApplication2.getUser().getId());
}
Also used : RichApplication(cz.metacentrum.perun.registrar.model.RichApplication) Group(cz.metacentrum.perun.core.api.Group) ApplicationsPageQuery(cz.metacentrum.perun.registrar.model.ApplicationsPageQuery) User(cz.metacentrum.perun.core.api.User) Application(cz.metacentrum.perun.registrar.model.Application) RichApplication(cz.metacentrum.perun.registrar.model.RichApplication) Test(org.junit.Test)

Example 5 with RichApplication

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

the class RegistrarBaseIntegrationTest method getApplicationsPageForUserIsNotMember.

@Test
public void getApplicationsPageForUserIsNotMember() throws Exception {
    System.out.println("getApplicationsPageForUserIsNotMember");
    // create groups
    Group group1 = setUpGroup("Group1", "Cool folks");
    Group group2 = setUpGroup("Group2", "Cooler folks");
    // create users
    User user1 = setUpUser("Joe", "Doe");
    User user2 = setUpUser("Barney", "Stinson");
    Application application1 = setUpApplicationGroup(user1, group1);
    Application application2 = setUpApplicationGroup(user2, group2);
    ApplicationsPageQuery query = new ApplicationsPageQuery(4, 0, SortingOrder.DESCENDING, ApplicationsOrderColumn.STATE, List.of(Application.AppState.VERIFIED), user1.getId(), group2.getId());
    Paginated<RichApplication> result = registrarManager.getApplicationsPage(session, vo, query);
    assertEquals(0, result.getData().size());
}
Also used : RichApplication(cz.metacentrum.perun.registrar.model.RichApplication) Group(cz.metacentrum.perun.core.api.Group) ApplicationsPageQuery(cz.metacentrum.perun.registrar.model.ApplicationsPageQuery) User(cz.metacentrum.perun.core.api.User) Application(cz.metacentrum.perun.registrar.model.Application) RichApplication(cz.metacentrum.perun.registrar.model.RichApplication) Test(org.junit.Test)

Aggregations

Group (cz.metacentrum.perun.core.api.Group)13 User (cz.metacentrum.perun.core.api.User)13 ApplicationsPageQuery (cz.metacentrum.perun.registrar.model.ApplicationsPageQuery)13 RichApplication (cz.metacentrum.perun.registrar.model.RichApplication)13 Test (org.junit.Test)13 Application (cz.metacentrum.perun.registrar.model.Application)11 ApplicationForm (cz.metacentrum.perun.registrar.model.ApplicationForm)1 ApplicationFormItem (cz.metacentrum.perun.registrar.model.ApplicationFormItem)1 ApplicationFormItemData (cz.metacentrum.perun.registrar.model.ApplicationFormItemData)1