This commit is contained in:
ggmaleva 2021-02-19 13:42:40 +03:00
parent 9fac32491b
commit 0cf22dee7a
4 changed files with 19 additions and 9 deletions

View File

@ -60,6 +60,11 @@
<artifactId>damsel</artifactId>
<version>1.475-bde841f</version>
</dependency>
<dependency>
<groupId>com.rbkmoney</groupId>
<artifactId>org-management-proto</artifactId>
<version>1.2-06c5c84</version>
</dependency>
<!--spring-->
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@ -1,8 +1,8 @@
package com.rbkmoney.orgmanager.converter;
import com.rbkmoney.bouncer.context.v1.*;
import com.rbkmoney.bouncer.context.v1.Entity;
import com.rbkmoney.bouncer.context.v1.User;
import com.rbkmoney.orgmanager.entity.MemberEntity;
import com.rbkmoney.orgmanager.entity.OrganizationEntity;
import com.rbkmoney.swag.organizations.model.Member;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

View File

@ -20,7 +20,6 @@ import com.rbkmoney.swag.organizations.model.Organization;
import com.rbkmoney.swag.organizations.model.OrganizationMembership;
import lombok.RequiredArgsConstructor;
import org.hibernate.Hibernate;
import org.keycloak.representations.AccessToken;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
@ -28,10 +27,8 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.Set;
@ -299,7 +296,12 @@ public class OrganizationService {
private MemberEntity findOrCreateMember(String userId, String userEmail, Set<MemberRoleEntity> inviteeRoles) {
Optional<MemberEntity> memberEntityOptional = memberRepository.findById(userId);
if (memberEntityOptional.isEmpty()) {
return memberRepository.save(new MemberEntity(userId, inviteeRoles, userEmail));
return memberRepository.save(
MemberEntity.builder()
.id(userId)
.roles(inviteeRoles)
.email(userEmail)
.build());
}
return memberEntityOptional.get();
}

View File

@ -6,13 +6,12 @@ import com.rbkmoney.orgmanager.entity.OrganizationEntity;
import com.rbkmoney.orgmanager.entity.OrganizationRoleEntity;
import com.rbkmoney.orgmanager.entity.ScopeEntity;
import com.rbkmoney.orgmanager.service.OrganizationService;
import com.rbkmoney.swag.organizations.model.Organization;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.ResponseEntity;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@ -22,7 +21,6 @@ import java.util.Optional;
import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@DirtiesContext
@ -48,6 +46,11 @@ public class OrganizationRepositoryTest extends AbstractRepositoryTest {
@Autowired
private OrganizationRoleRepository scopeRepository;
@Before
public void setUp() throws Exception {
organizationRepository.deleteAll();
}
@Test
public void shouldModifyOrganization() {
// Given