Search in sources :

Example 1 with I18nString

use of pl.edu.icm.unity.types.I18nString in project furms by unity-idm.

the class UnityProjectGroupsDAOTest method shouldUpdateCommunity.

@Test
void shouldUpdateCommunity() {
    // given
    ProjectGroup project = ProjectGroup.builder().id(UUID.randomUUID().toString()).communityId(UUID.randomUUID().toString()).name("test").build();
    Group group = new Group("/path/" + project.getId());
    group.setDisplayedName(new I18nString("test"));
    when(unityClient.get(contains(project.getId()), eq(Group.class))).thenReturn(group);
    doNothing().when(unityClient).put(contains(project.getId()), eq(Group.class));
    // when
    unityProjectGroupsDAO.update(project);
    // then
    verify(unityClient, times(1)).put(anyString(), any());
}
Also used : ProjectGroup(io.imunity.furms.domain.projects.ProjectGroup) Group(pl.edu.icm.unity.types.basic.Group) I18nString(pl.edu.icm.unity.types.I18nString) ProjectGroup(io.imunity.furms.domain.projects.ProjectGroup) Test(org.junit.jupiter.api.Test)

Example 2 with I18nString

use of pl.edu.icm.unity.types.I18nString in project furms by unity-idm.

the class UnityProjectGroupsDAOTest method shouldGetMetaInfoAboutProject.

@Test
void shouldGetMetaInfoAboutProject() {
    // given
    String communityId = UUID.randomUUID().toString();
    String projectId = UUID.randomUUID().toString();
    Group group = new Group("/path/" + communityId + "/projects/" + projectId);
    group.setDisplayedName(new I18nString("test"));
    when(unityClient.get(contains(projectId), eq(Group.class))).thenReturn(group);
    // when
    Optional<ProjectGroup> project = unityProjectGroupsDAO.get(communityId, projectId);
    // then
    assertThat(project).isPresent();
    assertThat(project.get().getId()).isEqualTo(projectId);
    assertThat(project.get().getName()).isEqualTo("test");
    assertThat(project.get().getCommunityId()).isEqualTo(communityId);
}
Also used : ProjectGroup(io.imunity.furms.domain.projects.ProjectGroup) Group(pl.edu.icm.unity.types.basic.Group) I18nString(pl.edu.icm.unity.types.I18nString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) I18nString(pl.edu.icm.unity.types.I18nString) ProjectGroup(io.imunity.furms.domain.projects.ProjectGroup) Test(org.junit.jupiter.api.Test)

Example 3 with I18nString

use of pl.edu.icm.unity.types.I18nString in project furms by unity-idm.

the class UnityProjectGroupsDAO method updateGroupName.

private void updateGroupName(ProjectGroup projectGroup) {
    Map<String, Object> uriVariables = getUriVariables(projectGroup.getCommunityId(), projectGroup.getId());
    String metaCommunityPath = UriComponentsBuilder.newInstance().path(PROJECT_GROUP_PATTERN).uriVariables(uriVariables).buildAndExpand().toUriString();
    Group group = new Group(metaCommunityPath);
    group.setDisplayedName(new I18nString(projectGroup.getName()));
    unityClient.put(GROUP_BASE, group);
}
Also used : ProjectGroup(io.imunity.furms.domain.projects.ProjectGroup) Group(pl.edu.icm.unity.types.basic.Group) I18nString(pl.edu.icm.unity.types.I18nString) I18nString(pl.edu.icm.unity.types.I18nString)

Example 4 with I18nString

use of pl.edu.icm.unity.types.I18nString in project furms by unity-idm.

the class UnitySiteGroupDAO method update.

@Override
public void update(Site site) {
    assertTrue(site != null && !isEmpty(site.getId()), () -> new IllegalArgumentException("Could not update Site in Unity. Missing Site or Site ID."));
    Map<String, Object> uriVariables = uriVariables(site);
    String metaSitePath = UriComponentsBuilder.newInstance().path(GROUP_BASE).pathSegment(SITE_PATTERN).path(META).uriVariables(uriVariables).buildAndExpand().encode().toUriString();
    try {
        Group group = unityClient.get(metaSitePath, Group.class);
        group.setDisplayedName(new I18nString(site.getName()));
        unityClient.put(GROUP_BASE, group);
    } catch (WebClientResponseException e) {
        throw new UnityFailureException(e.getMessage(), e);
    }
}
Also used : Group(pl.edu.icm.unity.types.basic.Group) WebClientResponseException(org.springframework.web.reactive.function.client.WebClientResponseException) UnityFailureException(io.imunity.furms.spi.exceptions.UnityFailureException) I18nString(pl.edu.icm.unity.types.I18nString) I18nString(pl.edu.icm.unity.types.I18nString)

Example 5 with I18nString

use of pl.edu.icm.unity.types.I18nString in project furms by unity-idm.

the class UnitySiteGroupDAO method create.

@Override
public void create(Site site) {
    assertTrue(site != null && !isEmpty(site.getId()), () -> new IllegalArgumentException("Could not create Site in Unity. Missing Site or Site ID"));
    Map<String, Object> uriVariables = uriVariables(site);
    String groupPath = UriComponentsBuilder.newInstance().path(SITE_PATTERN).uriVariables(uriVariables).toUriString();
    Group group = new Group(groupPath);
    group.setDisplayedName(new I18nString(site.getName()));
    try {
        unityClient.post(GROUP_BASE, group);
    } catch (WebClientResponseException e) {
        throw new UnityFailureException(e.getMessage(), e);
    }
    try {
        String createSiteUsersPath = UriComponentsBuilder.newInstance().path(GROUP_BASE).pathSegment(groupPath + USERS_PATTERN).toUriString();
        unityClient.post(createSiteUsersPath);
    } catch (WebClientResponseException e) {
        throw new UnityFailureException(e.getMessage(), e);
    }
}
Also used : Group(pl.edu.icm.unity.types.basic.Group) WebClientResponseException(org.springframework.web.reactive.function.client.WebClientResponseException) UnityFailureException(io.imunity.furms.spi.exceptions.UnityFailureException) I18nString(pl.edu.icm.unity.types.I18nString) I18nString(pl.edu.icm.unity.types.I18nString)

Aggregations

I18nString (pl.edu.icm.unity.types.I18nString)11 Group (pl.edu.icm.unity.types.basic.Group)11 Test (org.junit.jupiter.api.Test)6 CommunityGroup (io.imunity.furms.domain.communities.CommunityGroup)4 ProjectGroup (io.imunity.furms.domain.projects.ProjectGroup)3 Site (io.imunity.furms.domain.sites.Site)2 UnityFailureException (io.imunity.furms.spi.exceptions.UnityFailureException)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 WebClientResponseException (org.springframework.web.reactive.function.client.WebClientResponseException)2