BJ-1020: modify organization

This commit is contained in:
vitaxa 2020-12-09 15:26:01 +03:00
parent b3b45c70f4
commit e4382c07a7
7 changed files with 50 additions and 17 deletions

View File

@ -52,7 +52,7 @@
<dependency>
<groupId>com.rbkmoney</groupId>
<artifactId>swag-organizations</artifactId>
<version>1.10-260e548-server</version>
<version>1.11-5a058ca-server</version>
</dependency>
<!--spring-->

View File

@ -68,8 +68,8 @@ public class OrgsController implements OrgsApi {
}
@Override
public ResponseEntity<Void> revokeInvitation(String xRequestID, String orgId, String invitationId, InlineObject inlineObject) {
return invitationService.revoke(orgId, invitationId, inlineObject);
public ResponseEntity<Void> revokeInvitation(String xRequestID, String orgId, String invitationId, InlineObject1 inlineObject1) {
return invitationService.revoke(orgId, invitationId, inlineObject1);
}
@Override
@ -85,6 +85,11 @@ public class OrgsController implements OrgsApi {
return organizationRoleService.list(orgId);
}
@Override
public ResponseEntity<Organization> patchOrg(String xRequestID, String orgId, InlineObject inlineObject) {
return null;
}
@Override
public ResponseEntity<Void> assignMemberRole(
String xRequestID,

View File

@ -4,10 +4,7 @@ import com.rbkmoney.orgmanager.converter.InvitationConverter;
import com.rbkmoney.orgmanager.entity.InvitationEntity;
import com.rbkmoney.orgmanager.repository.InvitationRepository;
import com.rbkmoney.orgmanager.repository.OrganizationRepository;
import com.rbkmoney.swag.organizations.model.InlineObject;
import com.rbkmoney.swag.organizations.model.InlineResponse2002;
import com.rbkmoney.swag.organizations.model.Invitation;
import com.rbkmoney.swag.organizations.model.InvitationStatusName;
import com.rbkmoney.swag.organizations.model.*;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -75,7 +72,7 @@ public class InvitationService {
.results(invitations));
}
public ResponseEntity<Void> revoke(String orgId, String invitationId, InlineObject inlineObject) {
public ResponseEntity<Void> revoke(String orgId, String invitationId, InlineObject1 inlineObject) {
Optional<InvitationEntity> entity = invitationRepository.findById(invitationId);
if (entity.isEmpty()) {

View File

@ -67,6 +67,15 @@ public class OrganizationService {
.body(savedOrganization);
}
@Transactional
public ResponseEntity<Organization> modify(String orgId, String orgName) {
OrganizationEntity organizationEntity = organizationRepository.getOne(orgId);
organizationEntity.setName(orgName);
Organization savedOrganization = organizationConverter.toDomain(organizationEntity);
return ResponseEntity.ok(savedOrganization);
}
public ResponseEntity<Organization> get(String orgId) {
Optional<OrganizationEntity> entity = organizationRepository.findById(orgId);

View File

@ -17,7 +17,6 @@ import com.rbkmoney.swag.organizations.model.OrganizationSearchResult;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.springframework.beans.factory.annotation.Autowired;
@ -30,7 +29,6 @@ import org.springframework.http.ResponseEntity;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;

View File

@ -7,6 +7,7 @@ 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.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@ -47,6 +48,32 @@ public class OrganizationRepositoryTest extends AbstractRepositoryTest {
@Autowired
private OrganizationRoleRepository scopeRepository;
@Test
public void shouldModifyOrganization() {
// Given
MemberEntity member = MemberEntity.builder()
.id("memberId")
.email("email")
.build();
OrganizationEntity organization = OrganizationEntity.builder()
.id(ORGANIZATION_ID)
.createdAt(LocalDateTime.now())
.name("name")
.owner("owner")
.members(Set.of(member))
.build();
// When
organizationRepository.save(organization);
String modifyOrgName = "testOrgName";
organizationService.modify(ORGANIZATION_ID, modifyOrgName);
Optional<OrganizationEntity> organizationEntityOptional = organizationService.findById(ORGANIZATION_ID);
Assert.assertTrue(organizationEntityOptional.isPresent());
Assert.assertEquals(modifyOrgName, organizationEntityOptional.get().getName());
}
@Test
public void shouldSaveOrganizationWithMembers() {
// Given

View File

@ -4,10 +4,7 @@ import com.rbkmoney.orgmanager.converter.InvitationConverter;
import com.rbkmoney.orgmanager.entity.InvitationEntity;
import com.rbkmoney.orgmanager.repository.InvitationRepository;
import com.rbkmoney.orgmanager.repository.OrganizationRepository;
import com.rbkmoney.swag.organizations.model.InlineObject;
import com.rbkmoney.swag.organizations.model.InlineResponse2002;
import com.rbkmoney.swag.organizations.model.Invitation;
import com.rbkmoney.swag.organizations.model.InvitationStatusName;
import com.rbkmoney.swag.organizations.model.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@ -154,9 +151,9 @@ public class InvitationServiceTest {
.thenReturn(Optional.of(entity));
// When
ResponseEntity<Void> response = service.revoke(orgId, invitationId, new InlineObject()
ResponseEntity<Void> response = service.revoke(orgId, invitationId, new InlineObject1()
.reason("reason")
.status(InlineObject.StatusEnum.REVOKED));
.status(InlineObject1.StatusEnum.REVOKED));
// Then
assertThat(entity.getStatus())
@ -179,7 +176,7 @@ public class InvitationServiceTest {
.thenReturn(Optional.empty());
// When
ResponseEntity<Void> response = service.revoke(orgId, invitationId, new InlineObject());
ResponseEntity<Void> response = service.revoke(orgId, invitationId, new InlineObject1());
// Then
assertThat(response.getStatusCode())