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());
}
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");
}
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);
}
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);
}
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());
}
Aggregations