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