diff --git a/pom.xml b/pom.xml
index 7c70db7..d189c45 100644
--- a/pom.xml
+++ b/pom.xml
@@ -46,7 +46,7 @@
dev.vality
swag-organizations
- 1.22-cd6cc10-server
+ 1.25-de0cd06-server
dev.vality
diff --git a/src/main/java/dev/vality/orgmanager/controller/OrgsController.java b/src/main/java/dev/vality/orgmanager/controller/OrgsController.java
index 5f1d5ec..9aaf8ae 100644
--- a/src/main/java/dev/vality/orgmanager/controller/OrgsController.java
+++ b/src/main/java/dev/vality/orgmanager/controller/OrgsController.java
@@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import javax.validation.constraints.Size;
-
import java.util.Objects;
@Slf4j
@@ -147,11 +146,11 @@ public class OrgsController implements OrgsApi {
public ResponseEntity getOrgRole(
String requestId,
String orgId,
- RoleId roleId) {
+ String roleId) {
log.info("Get organization id: requestId={}, orgId={}, roleId={}", requestId, orgId, roleId);
ResourceDto resource = ResourceDto.builder()
.orgId(orgId)
- .roleId(roleId.getValue())
+ .roleId(roleId)
.build();
resourceAccessService.checkRights(resource);
return ResponseEntity.ok(organizationRoleService.get(orgId, roleId));
@@ -187,7 +186,7 @@ public class OrgsController implements OrgsApi {
ResourceDto resource = ResourceDto.builder()
.orgId(orgId)
.memberId(userId)
- .roleId(body.getRoleId().getValue())
+ .roleId(body.getRoleId())
.scopeResourceId(Objects.nonNull(body.getScope()) ? body.getScope().getResourceId() : null)
.build();
resourceAccessService.checkRights(resource);
diff --git a/src/main/java/dev/vality/orgmanager/converter/MemberRoleConverter.java b/src/main/java/dev/vality/orgmanager/converter/MemberRoleConverter.java
index 0bd8466..d55c71f 100644
--- a/src/main/java/dev/vality/orgmanager/converter/MemberRoleConverter.java
+++ b/src/main/java/dev/vality/orgmanager/converter/MemberRoleConverter.java
@@ -5,7 +5,6 @@ import dev.vality.orgmanager.service.dto.MemberWithRoleDto;
import dev.vality.swag.organizations.model.MemberRole;
import dev.vality.swag.organizations.model.MemberRoleScope;
import dev.vality.swag.organizations.model.ResourceScopeId;
-import dev.vality.swag.organizations.model.RoleId;
import org.springframework.stereotype.Service;
import java.util.Objects;
@@ -36,7 +35,7 @@ public class MemberRoleConverter {
.orElse(null);
return new MemberRole()
.id(entity.getId())
- .roleId(RoleId.fromValue(entity.getRoleId()))
+ .roleId(entity.getRoleId())
.scope(memberRoleScope);
}
@@ -49,7 +48,7 @@ public class MemberRoleConverter {
.orElse(null);
return new MemberRole()
.id(memberWithRoleDto.getMemberRoleId())
- .roleId(RoleId.fromValue(memberWithRoleDto.getRoleId()))
+ .roleId(memberWithRoleDto.getRoleId())
.scope(memberRoleScope);
}
}
diff --git a/src/main/java/dev/vality/orgmanager/converter/OrganizationRoleConverter.java b/src/main/java/dev/vality/orgmanager/converter/OrganizationRoleConverter.java
index 69ba4ff..d52ecbd 100644
--- a/src/main/java/dev/vality/orgmanager/converter/OrganizationRoleConverter.java
+++ b/src/main/java/dev/vality/orgmanager/converter/OrganizationRoleConverter.java
@@ -3,23 +3,20 @@ package dev.vality.orgmanager.converter;
import dev.vality.orgmanager.entity.OrganizationRoleEntity;
import dev.vality.swag.organizations.model.ResourceScopeId;
import dev.vality.swag.organizations.model.Role;
-import dev.vality.swag.organizations.model.RoleId;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
-import java.util.stream.Collectors;
-
@Service
@RequiredArgsConstructor
public class OrganizationRoleConverter {
public Role toDomain(OrganizationRoleEntity entity) {
return new Role()
- .id(RoleId.fromValue(entity.getRoleId()))
+ .id(entity.getRoleId())
.name(entity.getName())
.scopes(entity.getPossibleScopes()
.stream()
.map(s -> ResourceScopeId.fromValue(s.getId()))
- .collect(Collectors.toList()));
+ .toList());
}
}
\ No newline at end of file
diff --git a/src/main/java/dev/vality/orgmanager/service/OrganizationRoleService.java b/src/main/java/dev/vality/orgmanager/service/OrganizationRoleService.java
index 5035caf..e7ed442 100644
--- a/src/main/java/dev/vality/orgmanager/service/OrganizationRoleService.java
+++ b/src/main/java/dev/vality/orgmanager/service/OrganizationRoleService.java
@@ -8,7 +8,6 @@ import dev.vality.orgmanager.repository.OrganizationRepository;
import dev.vality.orgmanager.repository.OrganizationRoleRepository;
import dev.vality.swag.organizations.model.Role;
import dev.vality.swag.organizations.model.RoleAvailableListResult;
-import dev.vality.swag.organizations.model.RoleId;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -17,8 +16,6 @@ import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
-import static java.util.stream.Collectors.toList;
-
@Service
@RequiredArgsConstructor
public class OrganizationRoleService {
@@ -27,12 +24,12 @@ public class OrganizationRoleService {
private final OrganizationRoleRepository organizationRoleRepository;
private final OrganizationRoleConverter organizationRoleConverter;
- public Role get(String orgId, RoleId roleId) {
+ public Role get(String orgId, String roleId) {
if (!organizationRepository.existsById(orgId)) {
throw new ResourceNotFoundException();
}
OrganizationRoleEntity entity =
- organizationRoleRepository.findByOrganizationIdAndRoleId(orgId, roleId.toString())
+ organizationRoleRepository.findByOrganizationIdAndRoleId(orgId, roleId)
.orElseThrow(ResourceNotFoundException::new);
return organizationRoleConverter.toDomain(entity);
@@ -50,7 +47,7 @@ public class OrganizationRoleService {
List roles = entity.orElseThrow().getRoles()
.stream()
.map(organizationRoleConverter::toDomain)
- .collect(toList());
+ .toList();
return ResponseEntity
.status(HttpStatus.OK)
diff --git a/src/main/java/dev/vality/orgmanager/service/OrganizationService.java b/src/main/java/dev/vality/orgmanager/service/OrganizationService.java
index 533acb0..788c80d 100644
--- a/src/main/java/dev/vality/orgmanager/service/OrganizationService.java
+++ b/src/main/java/dev/vality/orgmanager/service/OrganizationService.java
@@ -26,9 +26,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
-import java.util.stream.Collectors;
-
-import static java.util.stream.Collectors.toList;
@Slf4j
@Service
@@ -85,7 +82,7 @@ public class OrganizationService {
private List getMemberRolesInOrg(String orgId, MemberEntity memberEntity) {
return memberEntity.getRoles().stream()
.filter(memberRole -> isActiveOrgMemberRole(orgId, memberRole))
- .collect(toList());
+ .toList();
}
private boolean isActiveOrgMemberRole(String orgId, MemberRoleEntity memberRole) {
@@ -159,7 +156,7 @@ public class OrganizationService {
String continuationToken = getContinuationId(entities, limitEntities);
List organizations = limitEntities
.stream().map(organizationConverter::toDomain)
- .collect(toList());
+ .toList();
return new OrganizationSearchResult()
.continuationToken(continuationToken)
@@ -180,7 +177,7 @@ public class OrganizationService {
}
return entities.stream()
.limit(limit)
- .collect(Collectors.toList());
+ .toList();
}
private String getContinuationId(List entities, List limitEntities) {
diff --git a/src/main/java/dev/vality/orgmanager/service/ResourceAccessServiceImpl.java b/src/main/java/dev/vality/orgmanager/service/ResourceAccessServiceImpl.java
index 5fd8a2b..5d29218 100644
--- a/src/main/java/dev/vality/orgmanager/service/ResourceAccessServiceImpl.java
+++ b/src/main/java/dev/vality/orgmanager/service/ResourceAccessServiceImpl.java
@@ -56,7 +56,7 @@ public class ResourceAccessServiceImpl implements ResourceAccessService {
MemberRoleScope scope = memberRole.getScope();
bouncerContext.setRole(RoleDto.builder()
.scopeResourceId(Objects.nonNull(scope) ? scope.getResourceId() : null)
- .roleId(memberRole.getRoleId().getValue())
+ .roleId(memberRole.getRoleId())
.build());
}
callBouncer(callerMethodName, bouncerContext);
diff --git a/src/test/java/dev/vality/orgmanager/TestObjectFactory.java b/src/test/java/dev/vality/orgmanager/TestObjectFactory.java
index 79dafd8..045fea5 100644
--- a/src/test/java/dev/vality/orgmanager/TestObjectFactory.java
+++ b/src/test/java/dev/vality/orgmanager/TestObjectFactory.java
@@ -89,7 +89,7 @@ public abstract class TestObjectFactory {
public static MemberRole testMemberRole() {
MemberRole memberRole = new MemberRole();
- memberRole.setRoleId(RoleId.MANAGER);
+ memberRole.setRoleId("Manager");
return memberRole;
}
@@ -165,15 +165,15 @@ public abstract class TestObjectFactory {
.organizationId(orgId)
.status("Pending")
.inviteeRoles(Set.of(
- buildMemberRole(RoleId.ADMINISTRATOR, orgId),
- buildMemberRole(RoleId.ACCOUNTANT, orgId)))
+ buildMemberRole("Administrator", orgId),
+ buildMemberRole("Accountant", orgId)))
.build();
}
- public static MemberRoleEntity buildMemberRole(RoleId role, String orgId) {
+ public static MemberRoleEntity buildMemberRole(String role, String orgId) {
return MemberRoleEntity.builder()
.id(randomString())
- .roleId(role.getValue())
+ .roleId(role)
.resourceId(randomString())
.scopeId(ResourceScopeId.SHOP.getValue())
.organizationId(orgId)
@@ -181,10 +181,10 @@ public abstract class TestObjectFactory {
.build();
}
- public static OrganizationRoleEntity buildOrganizationRole(RoleId role, String orgId) {
+ public static OrganizationRoleEntity buildOrganizationRole(String role, String orgId) {
return OrganizationRoleEntity.builder()
.id(randomString())
- .roleId(role.getValue())
+ .roleId(role)
.organizationId(orgId)
.name(randomString())
.build();
diff --git a/src/test/java/dev/vality/orgmanager/controller/OrgsControllerTest.java b/src/test/java/dev/vality/orgmanager/controller/OrgsControllerTest.java
index 099ffe7..64cc640 100644
--- a/src/test/java/dev/vality/orgmanager/controller/OrgsControllerTest.java
+++ b/src/test/java/dev/vality/orgmanager/controller/OrgsControllerTest.java
@@ -10,7 +10,6 @@ import dev.vality.orgmanager.service.dto.ResourceDto;
import dev.vality.orgmanager.util.TestData;
import dev.vality.swag.organizations.model.InvitationRequest;
import dev.vality.swag.organizations.model.MemberRole;
-import dev.vality.swag.organizations.model.RoleId;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatchers;
import org.springframework.transaction.annotation.Transactional;
@@ -81,7 +80,7 @@ public class OrgsControllerTest extends AbstractControllerTest {
MemberEntity memberEntity = TestObjectFactory.testMemberEntity(TestObjectFactory.randomString());
OrganizationEntity organization = TestObjectFactory.buildOrganization(memberEntity);
- MemberRoleEntity memberRoleEntity = TestObjectFactory.buildMemberRole(RoleId.ACCOUNTANT, organization.getId());
+ MemberRoleEntity memberRoleEntity = TestObjectFactory.buildMemberRole("Accountant", organization.getId());
MemberRoleEntity savedMemberRole = memberRoleRepository.save(
memberRoleEntity);
memberEntity.setRoles(Set.of(savedMemberRole));
@@ -91,13 +90,13 @@ public class OrgsControllerTest extends AbstractControllerTest {
MemberRole memberRole = TestData.buildMemberRole();
mockMvc.perform(post(String.format("/orgs/%s/members/%s/roles", savedOrganization.getId(), savedMember.getId()))
- .contentType("application/json")
- .content(objectMapper.writeValueAsString(memberRole))
- .header("Authorization", "Bearer " + generateRbkAdminJwt())
- .header("X-Request-ID", "testRequestId"))
+ .contentType("application/json")
+ .content(objectMapper.writeValueAsString(memberRole))
+ .header("Authorization", "Bearer " + generateRbkAdminJwt())
+ .header("X-Request-ID", "testRequestId"))
.andExpect(status().isCreated())
.andExpect(jsonPath("$.id").isNotEmpty())
- .andExpect(jsonPath("$.roleId", equalTo(memberRole.getRoleId().getValue())))
+ .andExpect(jsonPath("$.roleId", equalTo(memberRole.getRoleId())))
.andExpect(jsonPath("$.scope.id", equalTo(memberRole.getScope().getId().getValue())))
.andExpect(jsonPath("$.scope.resourceId", equalTo(memberRole.getScope().getResourceId())));
@@ -110,7 +109,7 @@ public class OrgsControllerTest extends AbstractControllerTest {
MemberEntity member = TestObjectFactory.testMemberEntity(TestObjectFactory.randomString());
OrganizationEntity organization = TestObjectFactory.buildOrganization(member);
MemberRoleEntity savedMemberRole =
- memberRoleRepository.save(TestObjectFactory.buildMemberRole(RoleId.ACCOUNTANT, organization.getId()));
+ memberRoleRepository.save(TestObjectFactory.buildMemberRole("Accountant", organization.getId()));
member.setRoles(Set.of(savedMemberRole));
MemberEntity savedMember = memberRepository.save(member);
OrganizationEntity savedOrganization = organizationRepository.save(organization);
@@ -133,7 +132,7 @@ public class OrgsControllerTest extends AbstractControllerTest {
void removeMemberRoleWithOnlyOneRole() throws Exception {
MemberEntity memberEntity = TestObjectFactory.testMemberEntity(TestObjectFactory.randomString());
OrganizationEntity organization = TestObjectFactory.buildOrganization(memberEntity);
- MemberRoleEntity memberRoleEntity = TestObjectFactory.buildMemberRole(RoleId.ACCOUNTANT, organization.getId());
+ MemberRoleEntity memberRoleEntity = TestObjectFactory.buildMemberRole("Accountant", organization.getId());
MemberRoleEntity savedMemberRole = memberRoleRepository.save(
memberRoleEntity);
memberEntity.setRoles(Set.of(savedMemberRole));
@@ -155,8 +154,8 @@ public class OrgsControllerTest extends AbstractControllerTest {
void removeMemberRole() throws Exception {
MemberEntity memberEntity = TestObjectFactory.testMemberEntity(TestObjectFactory.randomString());
OrganizationEntity organization = TestObjectFactory.buildOrganization(memberEntity);
- MemberRoleEntity memberRoleEntity = TestObjectFactory.buildMemberRole(RoleId.ACCOUNTANT, organization.getId());
- MemberRoleEntity roleToRemove = TestObjectFactory.buildMemberRole(RoleId.MANAGER, organization.getId());
+ MemberRoleEntity memberRoleEntity = TestObjectFactory.buildMemberRole("Accountant", organization.getId());
+ MemberRoleEntity roleToRemove = TestObjectFactory.buildMemberRole("Manager", organization.getId());
List roles = memberRoleRepository.saveAll(List.of(
memberRoleEntity, roleToRemove));
memberEntity.setRoles(new HashSet<>(roles));
@@ -164,9 +163,9 @@ public class OrgsControllerTest extends AbstractControllerTest {
OrganizationEntity savedOrganization = organizationRepository.save(organization);
mockMvc.perform(delete(
- String.format("/orgs/%s/members/%s/roles/%s", savedOrganization.getId(), savedMember.getId(),
- roleToRemove.getId())
- )
+ String.format("/orgs/%s/members/%s/roles/%s", savedOrganization.getId(), savedMember.getId(),
+ roleToRemove.getId())
+ )
.contentType("application/json")
.header("Authorization", "Bearer " + generateRbkAdminJwt())
.header("X-Request-ID", "testRequestId"))
diff --git a/src/test/java/dev/vality/orgmanager/controller/UserControllerTest.java b/src/test/java/dev/vality/orgmanager/controller/UserControllerTest.java
index eae3743..52d053c 100644
--- a/src/test/java/dev/vality/orgmanager/controller/UserControllerTest.java
+++ b/src/test/java/dev/vality/orgmanager/controller/UserControllerTest.java
@@ -115,7 +115,7 @@ public class UserControllerTest extends AbstractControllerTest {
assertEquals(savedOrg.getId(), organizationMembership.getOrg().getId());
assertEquals(userId, organizationMembership.getMember().getId());
List actualRoles =
- organizationMembership.getMember().getRoles().stream().map(MemberRole::getRoleId).map(RoleId::getValue)
+ organizationMembership.getMember().getRoles().stream().map(MemberRole::getRoleId)
.collect(Collectors.toList());
List expectedRoles = savedInvitation.getInviteeRoles().stream().map(MemberRoleEntity::getRoleId)
.collect(Collectors.toList());
@@ -147,7 +147,7 @@ public class UserControllerTest extends AbstractControllerTest {
assertEquals(savedOrg.getId(), organizationMembership.getOrg().getId());
assertEquals(userId, organizationMembership.getMember().getId());
List actualRoles =
- organizationMembership.getMember().getRoles().stream().map(MemberRole::getRoleId).map(RoleId::getValue)
+ organizationMembership.getMember().getRoles().stream().map(MemberRole::getRoleId)
.collect(Collectors.toList());
List expectedRoles = savedInvitation.getInviteeRoles().stream().map(MemberRoleEntity::getRoleId)
.collect(Collectors.toList());
diff --git a/src/test/java/dev/vality/orgmanager/converter/BouncerContextConverterTest.java b/src/test/java/dev/vality/orgmanager/converter/BouncerContextConverterTest.java
index fda2882..088953d 100644
--- a/src/test/java/dev/vality/orgmanager/converter/BouncerContextConverterTest.java
+++ b/src/test/java/dev/vality/orgmanager/converter/BouncerContextConverterTest.java
@@ -8,7 +8,6 @@ import dev.vality.orgmanager.TestObjectFactory;
import dev.vality.orgmanager.entity.MemberEntity;
import dev.vality.orgmanager.entity.MemberRoleEntity;
import dev.vality.orgmanager.entity.OrganizationEntity;
-import dev.vality.swag.organizations.model.RoleId;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -39,7 +38,7 @@ class BouncerContextConverterTest {
OrgRole actual = converter.toOrgRole(entity);
OrgRole expected = new OrgRole()
- .setId(RoleId.ADMINISTRATOR.getValue())
+ .setId("Administrator")
.setScope(new OrgRoleScope()
.setShop(new Entity().setId("resource")));
@@ -57,7 +56,7 @@ class BouncerContextConverterTest {
OrgRole actual = converter.toOrgRole(entity);
OrgRole expected = new OrgRole()
- .setId(RoleId.ADMINISTRATOR.getValue())
+ .setId("Administrator")
.setScope(null);
assertEquals(expected, actual);
@@ -91,7 +90,7 @@ class BouncerContextConverterTest {
void shouldConvertToOrganizationWithoutRolesAnotherOrganization() {
OrganizationEntity organizationEntity = TestObjectFactory.buildOrganization();
MemberRoleEntity memberRoleEntity =
- TestObjectFactory.buildMemberRole(RoleId.ADMINISTRATOR, TestObjectFactory.randomString());
+ TestObjectFactory.buildMemberRole("Administrator", TestObjectFactory.randomString());
var organization = converter.toOrganization(organizationEntity, Set.of(memberRoleEntity));
@@ -105,7 +104,7 @@ class BouncerContextConverterTest {
void shouldConvertToOrganization() {
OrganizationEntity organizationEntity = TestObjectFactory.buildOrganization();
MemberRoleEntity memberRoleEntity =
- TestObjectFactory.buildMemberRole(RoleId.ADMINISTRATOR, organizationEntity.getId());
+ TestObjectFactory.buildMemberRole("Administrator", organizationEntity.getId());
var organization = converter.toOrganization(organizationEntity, Set.of(memberRoleEntity));
diff --git a/src/test/java/dev/vality/orgmanager/converter/MemberRoleConverterTest.java b/src/test/java/dev/vality/orgmanager/converter/MemberRoleConverterTest.java
index 220f832..93c40df 100644
--- a/src/test/java/dev/vality/orgmanager/converter/MemberRoleConverterTest.java
+++ b/src/test/java/dev/vality/orgmanager/converter/MemberRoleConverterTest.java
@@ -4,7 +4,6 @@ import dev.vality.orgmanager.entity.MemberRoleEntity;
import dev.vality.swag.organizations.model.MemberRole;
import dev.vality.swag.organizations.model.MemberRoleScope;
import dev.vality.swag.organizations.model.ResourceScopeId;
-import dev.vality.swag.organizations.model.RoleId;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -23,7 +22,7 @@ class MemberRoleConverterTest {
void shouldConvertToEntityWithoutScope() {
// Given
MemberRole role = new MemberRole()
- .roleId(RoleId.ADMINISTRATOR);
+ .roleId("Administrator");
// When
MemberRoleEntity entity = converter.toEntity(role, "org");
@@ -45,7 +44,7 @@ class MemberRoleConverterTest {
void shouldConvertToEntity() {
// Given
MemberRole role = new MemberRole()
- .roleId(RoleId.ADMINISTRATOR)
+ .roleId("Administrator")
.scope(new MemberRoleScope()
.resourceId("resource")
.id(ResourceScopeId.SHOP));
@@ -84,7 +83,7 @@ class MemberRoleConverterTest {
// Then
MemberRole expected = new MemberRole()
.id(entity.getId())
- .roleId(RoleId.ADMINISTRATOR);
+ .roleId("Administrator");
assertThat(role).usingRecursiveComparison().isEqualTo(expected);
}
@@ -106,7 +105,7 @@ class MemberRoleConverterTest {
// Then
MemberRole expected = new MemberRole()
.id(entity.getId())
- .roleId(RoleId.ADMINISTRATOR)
+ .roleId("Administrator")
.scope(new MemberRoleScope()
.resourceId("resource")
.id(ResourceScopeId.SHOP));
diff --git a/src/test/java/dev/vality/orgmanager/converter/OrganizationRoleConverterTest.java b/src/test/java/dev/vality/orgmanager/converter/OrganizationRoleConverterTest.java
index 8a18ce5..ab1e1f9 100644
--- a/src/test/java/dev/vality/orgmanager/converter/OrganizationRoleConverterTest.java
+++ b/src/test/java/dev/vality/orgmanager/converter/OrganizationRoleConverterTest.java
@@ -4,7 +4,6 @@ import dev.vality.orgmanager.entity.OrganizationRoleEntity;
import dev.vality.orgmanager.entity.ScopeEntity;
import dev.vality.swag.organizations.model.ResourceScopeId;
import dev.vality.swag.organizations.model.Role;
-import dev.vality.swag.organizations.model.RoleId;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -40,7 +39,7 @@ class OrganizationRoleConverterTest {
// Then
Role expected = new Role()
- .id(RoleId.ADMINISTRATOR)
+ .id("Administrator")
.name("name")
.scopes(List.of(ResourceScopeId.SHOP));
diff --git a/src/test/java/dev/vality/orgmanager/service/OrganizationRoleServiceTest.java b/src/test/java/dev/vality/orgmanager/service/OrganizationRoleServiceTest.java
index 00b8cfc..75eda88 100644
--- a/src/test/java/dev/vality/orgmanager/service/OrganizationRoleServiceTest.java
+++ b/src/test/java/dev/vality/orgmanager/service/OrganizationRoleServiceTest.java
@@ -8,7 +8,6 @@ import dev.vality.orgmanager.repository.OrganizationRepository;
import dev.vality.orgmanager.repository.OrganizationRoleRepository;
import dev.vality.swag.organizations.model.Role;
import dev.vality.swag.organizations.model.RoleAvailableListResult;
-import dev.vality.swag.organizations.model.RoleId;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
@@ -85,10 +84,10 @@ public class OrganizationRoleServiceTest {
OrganizationRoleEntity organizationRoleEntity = new OrganizationRoleEntity();
Role role = new Role();
String orgId = "orgId";
- RoleId roleId = RoleId.ADMINISTRATOR;
+ String roleId = "Administrator";
when(organizationRepository.existsById(orgId))
.thenReturn(true);
- when(organizationRoleRepository.findByOrganizationIdAndRoleId(orgId, roleId.getValue()))
+ when(organizationRoleRepository.findByOrganizationIdAndRoleId(orgId, roleId))
.thenReturn(Optional.of(organizationRoleEntity));
when(organizationRoleConverter.toDomain(organizationRoleEntity))
.thenReturn(role);
@@ -102,7 +101,7 @@ public class OrganizationRoleServiceTest {
@Test
void shouldReturnNotFoundIfOrganizationDoesNotExist() {
String orgId = "orgId";
- RoleId roleId = RoleId.ADMINISTRATOR;
+ String roleId = "Administrator";
when(organizationRepository.existsById(orgId))
.thenReturn(false);
diff --git a/src/test/java/dev/vality/orgmanager/service/OrganizationServiceIntegrationTest.java b/src/test/java/dev/vality/orgmanager/service/OrganizationServiceIntegrationTest.java
index dc18a68..ea884ad 100644
--- a/src/test/java/dev/vality/orgmanager/service/OrganizationServiceIntegrationTest.java
+++ b/src/test/java/dev/vality/orgmanager/service/OrganizationServiceIntegrationTest.java
@@ -39,16 +39,16 @@ public class OrganizationServiceIntegrationTest extends AbstractRepositoryTest {
// Given
MemberEntity member = TestObjectFactory.testMemberEntity(TestObjectFactory.randomString());
OrganizationEntity organization = TestObjectFactory.buildOrganization(member);
- MemberRoleEntity nonActiveRoleInOrg = buildMemberRole(RoleId.ACCOUNTANT, organization.getId());
+ MemberRoleEntity nonActiveRoleInOrg = buildMemberRole("Accountant", organization.getId());
nonActiveRoleInOrg.setActive(Boolean.FALSE);
MemberRoleEntity savedMemberRoleNonActiveInOrg = memberRoleRepository.save(nonActiveRoleInOrg);
- MemberRoleEntity activeRoleInOrg = buildMemberRole(RoleId.ACCOUNTANT, organization.getId());
+ MemberRoleEntity activeRoleInOrg = buildMemberRole("Accountant", organization.getId());
activeRoleInOrg.setActive(Boolean.TRUE);
MemberRoleEntity savedMemberRoleInOrg =
memberRoleRepository.save(activeRoleInOrg);
MemberRoleEntity savedMemberRoleInAnotherOrg =
memberRoleRepository
- .save(TestObjectFactory.buildMemberRole(RoleId.ACCOUNTANT, TestObjectFactory.randomString()));
+ .save(TestObjectFactory.buildMemberRole("Accountant", TestObjectFactory.randomString()));
member.setRoles(Set.of(savedMemberRoleNonActiveInOrg, savedMemberRoleInOrg, savedMemberRoleInAnotherOrg));
MemberEntity savedMember = memberRepository.save(member);
OrganizationEntity savedOrganization = organizationRepository.save(organization);
@@ -70,7 +70,7 @@ public class OrganizationServiceIntegrationTest extends AbstractRepositoryTest {
void shouldThrowAccessDeniedExceptionOnJoinOrgTest() {
MemberEntity memberEntity = TestObjectFactory.testMemberEntity(TestObjectFactory.randomString());
OrganizationEntity organization = TestObjectFactory.buildOrganization(memberEntity);
- MemberRoleEntity memberRole = buildMemberRole(RoleId.ACCOUNTANT, organization.getId());
+ MemberRoleEntity memberRole = buildMemberRole("Accountant", organization.getId());
memberRole.setActive(Boolean.FALSE);
MemberRoleEntity savedMemberRole = memberRoleRepository.save(memberRole);
memberEntity.setRoles(Set.of(savedMemberRole));
@@ -97,7 +97,7 @@ public class OrganizationServiceIntegrationTest extends AbstractRepositoryTest {
alreadyAcceptedInvitation.setAcceptedMemberId(TestObjectFactory.randomString());
alreadyAcceptedInvitation.setStatus(InvitationStatusName.ACCEPTED.getValue());
invitationRepository.save(alreadyAcceptedInvitation);
- MemberRoleEntity memberRole = buildMemberRole(RoleId.ACCOUNTANT, savedOrganization.getId());
+ MemberRoleEntity memberRole = buildMemberRole("Accountant", savedOrganization.getId());
memberRole.setActive(Boolean.FALSE);
MemberRoleEntity savedMemberRole = memberRoleRepository.save(memberRole);
memberEntity.setRoles(Set.of(savedMemberRole));
@@ -114,7 +114,7 @@ public class OrganizationServiceIntegrationTest extends AbstractRepositoryTest {
void shouldJoinExistMember() {
MemberEntity memberEntity = TestObjectFactory.testMemberEntity(TestObjectFactory.randomString());
OrganizationEntity organization = TestObjectFactory.buildOrganization(memberEntity);
- MemberRoleEntity memberRole = buildMemberRole(RoleId.ACCOUNTANT, organization.getId());
+ MemberRoleEntity memberRole = buildMemberRole("Accountant", organization.getId());
memberRole.setActive(Boolean.FALSE);
MemberRoleEntity savedMemberRole = memberRoleRepository.save(memberRole);
memberEntity.setRoles(Set.of(savedMemberRole));
@@ -130,7 +130,6 @@ public class OrganizationServiceIntegrationTest extends AbstractRepositoryTest {
assertEquals(savedMember.getId(), organizationMembership.getMember().getId());
List actualRoles = organizationMembership.getMember().getRoles().stream()
.map(MemberRole::getRoleId)
- .map(RoleId::getValue)
.collect(Collectors.toList());
List expectedRoles = savedInvitation.getInviteeRoles().stream()
.map(MemberRoleEntity::getRoleId)
@@ -155,7 +154,6 @@ public class OrganizationServiceIntegrationTest extends AbstractRepositoryTest {
assertEquals(userId, organizationMembership.getMember().getId());
List actualRoles = organizationMembership.getMember().getRoles().stream()
.map(MemberRole::getRoleId)
- .map(RoleId::getValue)
.collect(Collectors.toList());
List expectedRoles = savedInvitation.getInviteeRoles().stream()
.map(MemberRoleEntity::getRoleId)
@@ -171,7 +169,7 @@ public class OrganizationServiceIntegrationTest extends AbstractRepositoryTest {
void shouldExpelOrgMember() {
MemberEntity member = TestObjectFactory.testMemberEntity(TestObjectFactory.randomString());
OrganizationEntity organization = TestObjectFactory.buildOrganization(member);
- MemberRoleEntity activeRoleInOrg = buildMemberRole(RoleId.ACCOUNTANT, organization.getId());
+ MemberRoleEntity activeRoleInOrg = buildMemberRole("Accountant", organization.getId());
activeRoleInOrg.setActive(Boolean.TRUE);
MemberRoleEntity savedMemberRole = memberRoleRepository.save(activeRoleInOrg);
member.setRoles(Set.of(savedMemberRole));
@@ -197,7 +195,7 @@ public class OrganizationServiceIntegrationTest extends AbstractRepositoryTest {
void shouldNotReturnOrganizationsAfterExpelOrgMember() {
MemberEntity member = TestObjectFactory.testMemberEntity(TestObjectFactory.randomString());
OrganizationEntity organization = TestObjectFactory.buildOrganization(member);
- MemberRoleEntity activeRoleInOrg = buildMemberRole(RoleId.ACCOUNTANT, organization.getId());
+ MemberRoleEntity activeRoleInOrg = buildMemberRole("Accountant", organization.getId());
activeRoleInOrg.setActive(Boolean.TRUE);
MemberRoleEntity savedMemberRole = memberRoleRepository.save(activeRoleInOrg);
member.setRoles(Set.of(savedMemberRole));
@@ -223,20 +221,20 @@ public class OrganizationServiceIntegrationTest extends AbstractRepositoryTest {
MemberEntity member1 = TestObjectFactory.testMemberEntity(TestObjectFactory.randomString());
MemberEntity member2 = TestObjectFactory.testMemberEntity(TestObjectFactory.randomString());
OrganizationEntity organization = TestObjectFactory.buildOrganization(Set.of(member1, member2));
- MemberRoleEntity activeMember1RoleInOrg = buildMemberRole(RoleId.ACCOUNTANT, organization.getId());
+ MemberRoleEntity activeMember1RoleInOrg = buildMemberRole("Accountant", organization.getId());
activeMember1RoleInOrg.setActive(Boolean.TRUE);
MemberRoleEntity savedMember1Role = memberRoleRepository.save(activeMember1RoleInOrg);
member1.setRoles(Set.of(savedMember1Role));
- MemberRoleEntity activeMember2RoleInOrg = buildMemberRole(RoleId.ACCOUNTANT, organization.getId());
+ MemberRoleEntity activeMember2RoleInOrg = buildMemberRole("Accountant", organization.getId());
activeMember2RoleInOrg.setActive(Boolean.TRUE);
MemberRoleEntity savedActiveMember2Role = memberRoleRepository.save(activeMember2RoleInOrg);
- MemberRoleEntity nonActiveMember2RoleInOrg = buildMemberRole(RoleId.ACCOUNTANT, organization.getId());
+ MemberRoleEntity nonActiveMember2RoleInOrg = buildMemberRole("Accountant", organization.getId());
nonActiveMember2RoleInOrg.setActive(Boolean.FALSE);
MemberRoleEntity savedNonActiveMember2Role = memberRoleRepository.save(nonActiveMember2RoleInOrg);
member2.setRoles(Set.of(savedActiveMember2Role, savedNonActiveMember2Role));
MemberEntity anotherMember = TestObjectFactory.testMemberEntity(TestObjectFactory.randomString());
OrganizationEntity anotherOrganization = TestObjectFactory.buildOrganization(Set.of(anotherMember));
- MemberRoleEntity activeAnotherMemberRoleInOrg = buildMemberRole(RoleId.ACCOUNTANT, anotherOrganization.getId());
+ MemberRoleEntity activeAnotherMemberRoleInOrg = buildMemberRole("Accountant", anotherOrganization.getId());
activeAnotherMemberRoleInOrg.setActive(Boolean.TRUE);
MemberRoleEntity savedAnotherRole = memberRoleRepository.save(activeAnotherMemberRoleInOrg);
anotherMember.setRoles(Set.of(savedAnotherRole));
@@ -265,7 +263,7 @@ public class OrganizationServiceIntegrationTest extends AbstractRepositoryTest {
MemberEntity member = TestObjectFactory.testMemberEntity(TestObjectFactory.randomString());
OrganizationEntity organization = TestObjectFactory.buildOrganization(member);
MemberRoleEntity role =
- memberRoleRepository.save(TestObjectFactory.buildMemberRole(RoleId.ACCOUNTANT, organization.getId()));
+ memberRoleRepository.save(TestObjectFactory.buildMemberRole("Accountant", organization.getId()));
member.setRoles(Set.of(role));
MemberEntity savedMember = memberRepository.save(member);
OrganizationEntity savedOrganization = organizationRepository.save(organization);
@@ -281,9 +279,9 @@ public class OrganizationServiceIntegrationTest extends AbstractRepositoryTest {
MemberEntity memberEntity = TestObjectFactory.testMemberEntity(TestObjectFactory.randomString());
OrganizationEntity organization = TestObjectFactory.buildOrganization(memberEntity);
MemberRoleEntity role =
- memberRoleRepository.save(TestObjectFactory.buildMemberRole(RoleId.ACCOUNTANT, organization.getId()));
+ memberRoleRepository.save(TestObjectFactory.buildMemberRole("Accountant", organization.getId()));
MemberRoleEntity roleToRemove =
- memberRoleRepository.save(TestObjectFactory.buildMemberRole(RoleId.MANAGER, organization.getId()));
+ memberRoleRepository.save(TestObjectFactory.buildMemberRole("Manager", organization.getId()));
memberEntity.setRoles(Set.of(role, roleToRemove));
MemberEntity savedMember = memberRepository.save(memberEntity);
OrganizationEntity savedOrganization = organizationRepository.save(organization);
diff --git a/src/test/java/dev/vality/orgmanager/service/ResourceAccessServiceImplTest.java b/src/test/java/dev/vality/orgmanager/service/ResourceAccessServiceImplTest.java
index f529164..28a09f6 100644
--- a/src/test/java/dev/vality/orgmanager/service/ResourceAccessServiceImplTest.java
+++ b/src/test/java/dev/vality/orgmanager/service/ResourceAccessServiceImplTest.java
@@ -8,7 +8,6 @@ import dev.vality.orgmanager.service.dto.BouncerContextDto;
import dev.vality.orgmanager.service.dto.ResourceDto;
import dev.vality.swag.organizations.model.MemberRole;
import dev.vality.swag.organizations.model.MemberRoleScope;
-import dev.vality.swag.organizations.model.RoleId;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -138,7 +137,7 @@ class ResourceAccessServiceImplTest {
when(memberRoleService.findById(resource.getMemberRoleId()))
.thenReturn(
new MemberRole()
- .roleId(RoleId.MANAGER)
+ .roleId("Manager")
.scope(new MemberRoleScope().resourceId(TestObjectFactory.randomString()))
);
diff --git a/src/test/java/dev/vality/orgmanager/service/UserServiceImplTest.java b/src/test/java/dev/vality/orgmanager/service/UserServiceImplTest.java
index bb695a0..3fe8f5c 100644
--- a/src/test/java/dev/vality/orgmanager/service/UserServiceImplTest.java
+++ b/src/test/java/dev/vality/orgmanager/service/UserServiceImplTest.java
@@ -6,7 +6,6 @@ import dev.vality.orgmanager.entity.MemberRoleEntity;
import dev.vality.orgmanager.entity.OrganizationEntity;
import dev.vality.orgmanager.repository.AbstractRepositoryTest;
import dev.vality.orgmanager.service.model.UserInfo;
-import dev.vality.swag.organizations.model.RoleId;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -14,9 +13,7 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
class UserServiceImplTest extends AbstractRepositoryTest {
@@ -65,7 +62,7 @@ class UserServiceImplTest extends AbstractRepositoryTest {
String memberId = TestObjectFactory.randomString();
var member = TestObjectFactory.testMemberEntity(memberId);
OrganizationEntity organization = TestObjectFactory.buildOrganization(member);
- MemberRoleEntity memberRole = TestObjectFactory.buildMemberRole(RoleId.ACCOUNTANT, organization.getId());
+ MemberRoleEntity memberRole = TestObjectFactory.buildMemberRole("Accountant", organization.getId());
memberRoleRepository.save(memberRole);
member.setRoles(Set.of(memberRole));
memberRepository.save(member);
@@ -84,7 +81,7 @@ class UserServiceImplTest extends AbstractRepositoryTest {
String memberId = TestObjectFactory.randomString();
var member = TestObjectFactory.testMemberEntity(memberId);
OrganizationEntity organization = TestObjectFactory.buildOrganization(member);
- MemberRoleEntity memberRole = TestObjectFactory.buildMemberRole(RoleId.ACCOUNTANT, organization.getId());
+ MemberRoleEntity memberRole = TestObjectFactory.buildMemberRole("Accountant", organization.getId());
OrganizationEntity ownedOrganization = TestObjectFactory.buildOrganization();
ownedOrganization.setOwner(memberId);
memberRoleRepository.save(memberRole);
@@ -111,9 +108,9 @@ class UserServiceImplTest extends AbstractRepositoryTest {
OrganizationEntity organization = TestObjectFactory.buildOrganization(member);
organization.setOwner(memberId);
organization.setRoles(
- Set.of(TestObjectFactory.buildOrganizationRole(RoleId.ACCOUNTANT, organization.getId()))
+ Set.of(TestObjectFactory.buildOrganizationRole("Accountant", organization.getId()))
);
- MemberRoleEntity memberRole = TestObjectFactory.buildMemberRole(RoleId.ACCOUNTANT, organization.getId());
+ MemberRoleEntity memberRole = TestObjectFactory.buildMemberRole("Accountant", organization.getId());
memberRoleRepository.save(memberRole);
member.setRoles(Set.of(memberRole));
memberRepository.save(member);
diff --git a/src/test/java/dev/vality/orgmanager/util/TestData.java b/src/test/java/dev/vality/orgmanager/util/TestData.java
index 27e1e6e..4f8ad71 100644
--- a/src/test/java/dev/vality/orgmanager/util/TestData.java
+++ b/src/test/java/dev/vality/orgmanager/util/TestData.java
@@ -23,7 +23,7 @@ public class TestData {
.id(memberId)
.email("email")
.roles(Set.of(MemberRoleEntity.builder()
- .id(RoleId.ADMINISTRATOR.getValue())
+ .id("Accountant")
.organizationId(organizationId)
.roleId("Accountant")
.scopeId("Shop")
@@ -67,14 +67,14 @@ public class TestData {
.inviteeRoles(Set.of(
MemberRoleEntity.builder()
.id("role1")
- .roleId(RoleId.ADMINISTRATOR.getValue())
+ .roleId("Administrator")
.resourceId("resource1")
.scopeId(ResourceScopeId.SHOP.getValue())
.organizationId(organizationId)
.build(),
MemberRoleEntity.builder()
.id("role2")
- .roleId(RoleId.MANAGER.getValue())
+ .roleId("Manager")
.resourceId("resource2")
.scopeId(ResourceScopeId.SHOP.getValue())
.organizationId(organizationId)
@@ -100,7 +100,7 @@ public class TestData {
public static MemberRole buildMemberRole() {
MemberRole memberRole = new MemberRole();
- memberRole.setRoleId(RoleId.ADMINISTRATOR);
+ memberRole.setRoleId("Administrator");
MemberRoleScope memberRoleScope = new MemberRoleScope();
memberRoleScope.setId(ResourceScopeId.SHOP);
memberRoleScope.setResourceId("testResourceIdKek");