use of io.imunity.furms.domain.communities.CommunityGroup in project furms by unity-idm.
the class CommunityServiceImplTest method shouldAllowToUpdateCommunity.
@Test
void shouldAllowToUpdateCommunity() {
// given
Community request = Community.builder().id("id").name("userFacingName").build();
CommunityGroup groupRequest = CommunityGroup.builder().id("id").name("userFacingName").build();
when(communityRepository.exists(request.getId())).thenReturn(true);
when(communityRepository.isUniqueName(request.getName())).thenReturn(true);
when(communityRepository.findById("id")).thenReturn(Optional.of(request));
// when
service.update(request);
orderVerifier.verify(communityRepository).update(eq(request));
orderVerifier.verify(communityGroupsDAO).update(eq(groupRequest));
orderVerifier.verify(publisher).publishEvent(eq(new CommunityUpdatedEvent(request, request)));
}
use of io.imunity.furms.domain.communities.CommunityGroup in project furms by unity-idm.
the class CommunityServiceImpl method update.
@Override
@Transactional
@FurmsAuthorize(capability = COMMUNITY_WRITE, resourceType = COMMUNITY, id = "community.id")
public void update(Community community) {
validator.validateUpdate(community);
Community oldCommunity = communityRepository.findById(community.getId()).get();
communityRepository.update(community);
communityGroupsDAO.update(new CommunityGroup(community.getId(), community.getName()));
LOG.info("Community was updated: {}", community);
publisher.publishEvent(new CommunityUpdatedEvent(oldCommunity, community));
}
use of io.imunity.furms.domain.communities.CommunityGroup in project furms by unity-idm.
the class UnityCommunityGroupsDAOTest method shouldCreateCommunity.
@Test
void shouldCreateCommunity() {
// given
CommunityGroup community = CommunityGroup.builder().id(UUID.randomUUID().toString()).name("test").build();
doNothing().when(unityClient).post(contains(community.getId()), any());
doNothing().when(unityClient).post(contains("users"), any());
// when
unityCommunityWebClient.create(community);
// then
verify(unityClient, times(1)).post(anyString(), any());
verify(unityClient, times(1)).post(anyString());
}
use of io.imunity.furms.domain.communities.CommunityGroup 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 io.imunity.furms.domain.communities.CommunityGroup 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");
}
Aggregations