Search in sources :

Example 6 with I18nString

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

the class UnityCommunityGroupsDAOTest method shouldUpdateCommunity.

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

Example 7 with I18nString

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

the class UnityCommunityGroupsDAOTest method shouldGetMetaInfoAboutCommunity.

@Test
void shouldGetMetaInfoAboutCommunity() {
    // given
    String id = UUID.randomUUID().toString();
    Group group = new Group("/path/" + id);
    group.setDisplayedName(new I18nString("test"));
    when(unityClient.get(contains(id), eq(Group.class))).thenReturn(group);
    // when
    Optional<CommunityGroup> community = unityCommunityWebClient.get(id);
    // then
    assertThat(community).isPresent();
    assertThat(community.get().getId()).isEqualTo(id);
    assertThat(community.get().getName()).isEqualTo("test");
}
Also used : CommunityGroup(io.imunity.furms.domain.communities.CommunityGroup) Group(pl.edu.icm.unity.types.basic.Group) CommunityGroup(io.imunity.furms.domain.communities.CommunityGroup) I18nString(pl.edu.icm.unity.types.I18nString) I18nString(pl.edu.icm.unity.types.I18nString) Test(org.junit.jupiter.api.Test)

Example 8 with I18nString

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

the class UnityCommunityGroupsDAO method create.

@Override
public void create(CommunityGroup community) {
    if (community == null || isEmpty(community.getId())) {
        throw new IllegalArgumentException("Could not create Community in Unity. Missing Community or Community ID");
    }
    Map<String, Object> uriVariables = uriVariables(community);
    String groupPath = getCommunityPath(uriVariables, COMMUNITY_GROUP_PATTERN);
    Group group = new Group(groupPath);
    group.setDisplayedName(new I18nString(community.getName()));
    unityClient.post(GROUP_BASE, group);
    String createCommunityUsersPath = UriComponentsBuilder.newInstance().path(GROUP_BASE).pathSegment(groupPath + USERS_PATTERN).toUriString();
    unityClient.post(createCommunityUsersPath);
}
Also used : CommunityGroup(io.imunity.furms.domain.communities.CommunityGroup) Group(pl.edu.icm.unity.types.basic.Group) I18nString(pl.edu.icm.unity.types.I18nString) I18nString(pl.edu.icm.unity.types.I18nString)

Example 9 with I18nString

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

the class UnityCommunityGroupsDAO method update.

@Override
public void update(CommunityGroup community) {
    if (community == null || isEmpty(community.getId())) {
        throw new IllegalArgumentException("Could not update Community in Unity. Missing Community or Community ID");
    }
    Map<String, Object> uriVariables = uriVariables(community);
    String metaCommunityPath = UriComponentsBuilder.newInstance().path(GROUP_BASE).pathSegment(COMMUNITY_GROUP_PATTERN).path(META).uriVariables(uriVariables).buildAndExpand().encode().toUriString();
    Group group = unityClient.get(metaCommunityPath, Group.class);
    group.setDisplayedName(new I18nString(community.getName()));
    unityClient.put(GROUP_BASE, group);
}
Also used : CommunityGroup(io.imunity.furms.domain.communities.CommunityGroup) Group(pl.edu.icm.unity.types.basic.Group) I18nString(pl.edu.icm.unity.types.I18nString) I18nString(pl.edu.icm.unity.types.I18nString)

Example 10 with I18nString

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

the class UnitySiteGroupDAOTest method shouldUpdateSite.

@Test
void shouldUpdateSite() {
    // given
    Site site = Site.builder().id(UUID.randomUUID().toString()).name("test").build();
    Group group = new Group("/path/" + site.getId());
    group.setDisplayedName(new I18nString("test"));
    when(unityClient.get(contains(site.getId()), eq(Group.class))).thenReturn(group);
    // when
    unitySiteWebClient.update(site);
    // then
    verify(unityClient, times(1)).get(eq("/group/%2Ffenix%2Fsites%2F" + site.getId() + "/meta"), eq(Group.class));
    verify(unityClient, times(1)).put(anyString(), any());
}
Also used : Site(io.imunity.furms.domain.sites.Site) Group(pl.edu.icm.unity.types.basic.Group) I18nString(pl.edu.icm.unity.types.I18nString) Test(org.junit.jupiter.api.Test)

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