mirror of
https://github.com/valitydev/org-manager.git
synced 2024-11-06 00:15:23 +00:00
add default true for active flag in role while create invitation
This commit is contained in:
parent
bb3b646e3d
commit
b4caa6c2d3
@ -23,6 +23,7 @@ public class MemberRoleConverter {
|
||||
.resourceId(Objects.nonNull(scope) ? scope.getResourceId() : null)
|
||||
.roleId(role.getRoleId().toString())
|
||||
.scopeId(Objects.nonNull(scope) ? scope.getId().toString() : null)
|
||||
.active(Boolean.TRUE)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -98,12 +98,12 @@ public abstract class TestObjectFactory {
|
||||
}
|
||||
|
||||
public static OrganizationEntity buildOrganization() {
|
||||
return OrganizationEntity.builder()
|
||||
.id(randomString())
|
||||
.createdAt(LocalDateTime.now())
|
||||
.name(randomString())
|
||||
.owner(randomString())
|
||||
.build();
|
||||
OrganizationEntity entity = new OrganizationEntity();
|
||||
entity.setId(randomString());
|
||||
entity.setCreatedAt(LocalDateTime.now());
|
||||
entity.setName(randomString());
|
||||
entity.setOwner(randomString());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public static OrganizationEntity buildOrganization(MemberEntity memberEntity) {
|
||||
@ -156,6 +156,7 @@ public abstract class TestObjectFactory {
|
||||
.resourceId(randomString())
|
||||
.scopeId(ResourceScopeId.SHOP.getValue())
|
||||
.organizationId(orgId)
|
||||
.active(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.rbkmoney.orgmanager.TestObjectFactory.buildInvitation;
|
||||
import static com.rbkmoney.orgmanager.TestObjectFactory.buildMemberRole;
|
||||
import static com.rbkmoney.orgmanager.TestObjectFactory.*;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
@ -92,6 +91,32 @@ public class OrganizationServiceIntegrationTest extends AbstractRepositoryTest {
|
||||
assertEquals(invitationEntity.getStatus(), InvitationStatusName.ACCEPTED.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
void shouldJoinNewMember() {
|
||||
String userId = TestObjectFactory.randomString();
|
||||
String email = TestObjectFactory.randomString();
|
||||
OrganizationEntity savedOrg = organizationRepository.save(buildOrganization());
|
||||
InvitationEntity savedInvitation = invitationRepository.save(buildInvitation(savedOrg.getId()));
|
||||
|
||||
OrganizationMembership organizationMembership = organizationService
|
||||
.joinOrganization(savedInvitation.getAcceptToken(), userId, email);
|
||||
|
||||
assertEquals(savedOrg.getId(), organizationMembership.getOrg().getId());
|
||||
assertEquals(userId, organizationMembership.getMember().getId());
|
||||
List<String> actualRoles = organizationMembership.getMember().getRoles().stream()
|
||||
.map(MemberRole::getRoleId)
|
||||
.map(RoleId::getValue)
|
||||
.collect(Collectors.toList());
|
||||
List<String> expectedRoles = savedInvitation.getInviteeRoles().stream()
|
||||
.map(MemberRoleEntity::getRoleId)
|
||||
.collect(Collectors.toList());
|
||||
assertIterableEquals(expectedRoles, actualRoles);
|
||||
InvitationEntity invitationEntity = invitationRepository.findById(savedInvitation.getId()).get();
|
||||
assertEquals(invitationEntity.getStatus(), InvitationStatusName.ACCEPTED.getValue());
|
||||
assertTrue(memberRoleRepository.findAll().stream().allMatch(MemberRoleEntity::isActive));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
void shouldExpelOrgMember() {
|
||||
|
Loading…
Reference in New Issue
Block a user