diff --git a/pom.xml b/pom.xml index e371246..f726546 100644 --- a/pom.xml +++ b/pom.xml @@ -60,6 +60,11 @@ damsel 1.475-bde841f + + com.rbkmoney + org-management-proto + 1.2-06c5c84 + org.springframework.boot diff --git a/src/main/java/com/rbkmoney/orgmanager/converter/MemberConverter.java b/src/main/java/com/rbkmoney/orgmanager/converter/MemberConverter.java index 993d25a..b346108 100644 --- a/src/main/java/com/rbkmoney/orgmanager/converter/MemberConverter.java +++ b/src/main/java/com/rbkmoney/orgmanager/converter/MemberConverter.java @@ -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; diff --git a/src/main/java/com/rbkmoney/orgmanager/service/OrganizationService.java b/src/main/java/com/rbkmoney/orgmanager/service/OrganizationService.java index e50c1e6..9409f63 100644 --- a/src/main/java/com/rbkmoney/orgmanager/service/OrganizationService.java +++ b/src/main/java/com/rbkmoney/orgmanager/service/OrganizationService.java @@ -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 inviteeRoles) { Optional 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(); } diff --git a/src/test/java/com/rbkmoney/orgmanager/repository/OrganizationRepositoryTest.java b/src/test/java/com/rbkmoney/orgmanager/repository/OrganizationRepositoryTest.java index 47a2b2b..38172d5 100644 --- a/src/test/java/com/rbkmoney/orgmanager/repository/OrganizationRepositoryTest.java +++ b/src/test/java/com/rbkmoney/orgmanager/repository/OrganizationRepositoryTest.java @@ -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