Search in sources :

Example 1 with CommunityGroup

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)));
}
Also used : CommunityGroup(io.imunity.furms.domain.communities.CommunityGroup) Community(io.imunity.furms.domain.communities.Community) CommunityUpdatedEvent(io.imunity.furms.domain.communities.CommunityUpdatedEvent) Test(org.junit.jupiter.api.Test)

Example 2 with CommunityGroup

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));
}
Also used : CommunityGroup(io.imunity.furms.domain.communities.CommunityGroup) Community(io.imunity.furms.domain.communities.Community) CommunityUpdatedEvent(io.imunity.furms.domain.communities.CommunityUpdatedEvent) FurmsAuthorize(io.imunity.furms.core.config.security.method.FurmsAuthorize) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with CommunityGroup

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());
}
Also used : CommunityGroup(io.imunity.furms.domain.communities.CommunityGroup) Test(org.junit.jupiter.api.Test)

Example 4 with CommunityGroup

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());
}
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 5 with CommunityGroup

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

Aggregations

CommunityGroup (io.imunity.furms.domain.communities.CommunityGroup)12 Community (io.imunity.furms.domain.communities.Community)6 Test (org.junit.jupiter.api.Test)5 I18nString (pl.edu.icm.unity.types.I18nString)5 Group (pl.edu.icm.unity.types.basic.Group)5 FurmsAuthorize (io.imunity.furms.core.config.security.method.FurmsAuthorize)2 CommunityCreatedEvent (io.imunity.furms.domain.communities.CommunityCreatedEvent)2 CommunityUpdatedEvent (io.imunity.furms.domain.communities.CommunityUpdatedEvent)2 Transactional (org.springframework.transaction.annotation.Transactional)2 Project (io.imunity.furms.domain.projects.Project)1 ProjectGroup (io.imunity.furms.domain.projects.ProjectGroup)1 PersistentId (io.imunity.furms.domain.users.PersistentId)1