mirror of
https://github.com/valitydev/org-manager.git
synced 2024-11-06 00:15:23 +00:00
fix test
This commit is contained in:
parent
9fac32491b
commit
0cf22dee7a
5
pom.xml
5
pom.xml
@ -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>
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user