Commit 00f3c34a authored by Jason's avatar Jason
Browse files

Merge branch 'update-response-code' into 'master'

Update response codes

See merge request !22
parents 12f24a0c e1b65840
Pipeline #27490 passed with stages
in 36 minutes and 7 seconds
......@@ -43,7 +43,7 @@ public class AddMemberApi {
.partitionId(partitionIdHeader)
.build();
addMemberService.run(addMemberDto, addMemberServiceDto);
return new ResponseEntity<>(addMemberDto, HttpStatus.ACCEPTED);
return new ResponseEntity<>(addMemberDto, HttpStatus.OK);
}
private void performValidation(String groupEmail, AddMemberDto addMemberDto, String partitionId, String partitionDomain) {
......
......@@ -38,6 +38,6 @@ public class CreateGroupApi {
.partitionId(dataPartitionId).build();
EntityNode outputGroupNode = createGroupService.run(inputGroupNode, createGroupServiceDto);
GroupDto output = GroupDto.createFromEntityNode(outputGroupNode);
return new ResponseEntity<>(output, HttpStatus.ACCEPTED);
return new ResponseEntity<>(output, HttpStatus.CREATED);
}
}
......@@ -45,6 +45,6 @@ public class DeleteGroupApi {
.partitionId(requestInfo.getHeaders().getPartitionId())
.build();
deleteService.run(groupNode, deleteGroupServiceDto);
return new ResponseEntity<>(HttpStatus.ACCEPTED);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
}
......@@ -37,6 +37,6 @@ public class RemoveMemberApi {
.requesterId(requestInfoUtilService.getUserId(requestInfo.getHeaders()))
.partitionId(partitionId).build();
removeMemberService.removeMember(removeMemberServiceDto);
return new ResponseEntity<>("", HttpStatus.ACCEPTED);
return new ResponseEntity<>("", HttpStatus.NO_CONTENT);
}
}
......@@ -56,7 +56,7 @@ public class UpdateGroupApi {
.build();
UpdateGroupResponseDto result = updateGroupService.updateGroup(updateGroupServiceDto);
return new ResponseEntity<>(result, HttpStatus.ACCEPTED);
return new ResponseEntity<>(result, HttpStatus.OK);
}
private void performValidation(String groupEmail, String partitionId, String partitionDomain) {
......
......@@ -64,7 +64,7 @@ public class AddMemberApiTest {
public void shouldMatchExpectedHttpRequest() throws Exception {
AddMemberDto dto = new AddMemberDto("a@common.com", Role.OWNER);
String group = "service.viewers.users@common.contoso.com";
performRequest(dto, group).andExpect(status().isAccepted());
performRequest(dto, group).andExpect(status().isOk());
}
@Test
......@@ -79,7 +79,7 @@ public class AddMemberApiTest {
AddMemberDto dto = new AddMemberDto("a@common.com", Role.OWNER);
String group = "service.viewers.users@common.contoso.com";
String result = performRequest(dto, group).andExpect(status().isAccepted())
String result = performRequest(dto, group).andExpect(status().isOk())
.andReturn().getResponse().getContentAsString();
assertThat(result)
......@@ -93,7 +93,7 @@ public class AddMemberApiTest {
AddMemberDto dto = new AddMemberDto("MEMBER@xxx.com", Role.OWNER);
String group = "service.viewers.users@common.contoso.com";
performRequest(dto, group).andExpect(status().isAccepted());
performRequest(dto, group).andExpect(status().isOk());
verify(service, times(1)).run(captor1.capture(), captor2.capture());
......@@ -119,7 +119,7 @@ public class AddMemberApiTest {
.header(DpsHeaders.DATA_PARTITION_ID, "common")
.content(body));
resultActions.andExpect(status().isAccepted());
resultActions.andExpect(status().isOk());
verify(service, times(1)).run(captor1.capture(), captor2.capture());
......@@ -145,7 +145,7 @@ public class AddMemberApiTest {
.header(DpsHeaders.DATA_PARTITION_ID, "common")
.content(body));
resultActions.andExpect(status().isAccepted());
resultActions.andExpect(status().isOk());
verify(service, times(1)).run(captor1.capture(), captor2.capture());
......
......@@ -67,7 +67,7 @@ public class CreateGroupApiTest {
@Test
public void shouldMatchExpectedHttpRequest() throws Exception {
CreateGroupDto dto = new CreateGroupDto("service.viewers_123-{{tenant}}", "My viewers group");
performCreateGroupRequest(dto).andExpect(status().isAccepted());
performCreateGroupRequest(dto).andExpect(status().isCreated());
}
@Test
......@@ -83,7 +83,7 @@ public class CreateGroupApiTest {
CreateGroupDto dto = new CreateGroupDto("service.viewers", "My viewers group");
GroupDto expectedResult = new GroupDto("service.viewers", "service.viewers@common.contoso.com", "My viewers group");
String result = performCreateGroupRequest(dto).andExpect(status().isAccepted())
String result = performCreateGroupRequest(dto).andExpect(status().isCreated())
.andReturn().getResponse().getContentAsString();
assertThat(result)
......@@ -96,7 +96,7 @@ public class CreateGroupApiTest {
ArgumentCaptor<EntityNode> captor1 = ArgumentCaptor.forClass(EntityNode.class);
ArgumentCaptor<CreateGroupServiceDto> captor2 = ArgumentCaptor.forClass(CreateGroupServiceDto.class);
performCreateGroupRequest(dto).andExpect(status().isAccepted());
performCreateGroupRequest(dto).andExpect(status().isCreated());
verify(createGroupService, times(1)).run(captor1.capture(), captor2.capture());
......@@ -119,7 +119,7 @@ public class CreateGroupApiTest {
.header(DpsHeaders.DATA_PARTITION_ID, "common")
.content(body));
resultActions.andExpect(status().isAccepted());
resultActions.andExpect(status().isCreated());
verify(createGroupService, times(1)).run(captor1.capture(), captor2.capture());
......
......@@ -61,7 +61,7 @@ public class DeleteGroupApiTests {
@Test
public void shouldMatchExpectedHttpRequest() throws Exception {
String groupId = "service.viewers.users@common.contoso.com";
performDeleteGroupRequest(groupId).andExpect(status().isAccepted());
performDeleteGroupRequest(groupId).andExpect(status().isNoContent());
}
@Test
......@@ -76,7 +76,7 @@ public class DeleteGroupApiTests {
ArgumentCaptor<EntityNode> captor1 = ArgumentCaptor.forClass(EntityNode.class);
ArgumentCaptor<DeleteGroupServiceDto> captor2 = ArgumentCaptor.forClass(DeleteGroupServiceDto.class);
String groupId = "service.VIEWERS@common.contoso.com";
performDeleteGroupRequest(groupId).andExpect(status().isAccepted());
performDeleteGroupRequest(groupId).andExpect(status().isNoContent());
verify(service, times(1)).run(captor1.capture(), captor2.capture());
assertThat(captor1.getValue().getNodeId()).isEqualTo("service.viewers@common.contoso.com");
......
......@@ -58,7 +58,7 @@ public class RemoveMemberApiTest {
@Test
public void shouldMatchExpectedHttpRequest() throws Exception {
performRequest("a@common.com", "service.viewers.users@common.contoso.com")
.andExpect(status().isAccepted());
.andExpect(status().isNoContent());
}
@Test
......@@ -72,7 +72,7 @@ public class RemoveMemberApiTest {
ArgumentCaptor<RemoveMemberServiceDto> captor = ArgumentCaptor.forClass(RemoveMemberServiceDto.class);
performRequest("ABC@common.com", "service.VIEWERS.users@common.contoso.com")
.andExpect(status().isAccepted());
.andExpect(status().isNoContent());
verify(service, times(1)).removeMember(captor.capture());
......
......@@ -90,7 +90,7 @@ public class UpdateGroupApiTests {
public void shouldUpdateAppIdsMatchExpectedHttpRequest() throws Exception {
String groupEmail = "users.common.test@common.contoso.com";
List<UpdateGroupOperation> request = getRequestBody("replace", "/appIds", "app1", "app2");
performRequest(request, groupEmail).andExpect(status().isAccepted());
performRequest(request, groupEmail).andExpect(status().isOk());
}
@Test
......@@ -98,7 +98,7 @@ public class UpdateGroupApiTests {
String groupEmail = "users.common.test@common.contoso.com";
String newGroupEmail = "users.test";
List<UpdateGroupOperation> request = getRequestBody("replace", "/name", newGroupEmail);
performRequest(request, groupEmail).andExpect(status().isAccepted());
performRequest(request, groupEmail).andExpect(status().isOk());
}
@Test
......@@ -112,7 +112,7 @@ public class UpdateGroupApiTests {
when(service.updateGroup(any())).thenReturn(response);
List<UpdateGroupOperation> request = getRequestBody("replace", "/name", newGroupEmail);
String result = performRequest(request, groupEmail)
.andExpect(status().isAccepted())
.andExpect(status().isOk())
.andReturn().getResponse().getContentAsString();
assertThat(result).isEqualToIgnoringWhitespace(objectMapper.writeValueAsString(response));
}
......@@ -138,7 +138,7 @@ public class UpdateGroupApiTests {
String newGroupName = "users.TEST";
ArgumentCaptor<UpdateGroupServiceDto> captor = ArgumentCaptor.forClass(UpdateGroupServiceDto.class);
List<UpdateGroupOperation> request = getRequestBody("replace", "/name", newGroupName);
performRequest(request, groupEmail).andExpect(status().isAccepted());
performRequest(request, groupEmail).andExpect(status().isOk());
verify(service, times(1)).updateGroup(captor.capture());
assertThat(captor.getValue().getExistingGroupEmail()).isEqualTo("users.common.test@common.contoso.com");
assertThat(captor.getValue().getRenameOperation().getValue().get(0)).isEqualTo("users.TEST");
......
......@@ -520,7 +520,7 @@ public class CreateMembershipsWorkflowSinglePartitionTest {
.header(DpsHeaders.AUTHORIZATION, "Bearer " + jwt)
.header(DpsHeaders.DATA_PARTITION_ID, "common")
.content(objectMapper.writeValueAsString(dto)))
.andExpect(MockMvcResultMatchers.status().isAccepted());
.andExpect(MockMvcResultMatchers.status().isCreated());
} catch (Exception e) {
Assert.fail("Exception shouldn't take place here");
}
......@@ -533,7 +533,7 @@ public class CreateMembershipsWorkflowSinglePartitionTest {
.characterEncoding(StandardCharsets.UTF_8.name())
.header(DpsHeaders.AUTHORIZATION, "Bearer " + jwt)
.header(DpsHeaders.DATA_PARTITION_ID, "common"))
.andExpect(MockMvcResultMatchers.status().isAccepted());
.andExpect(MockMvcResultMatchers.status().isNoContent());
} catch (Exception e) {
Assert.fail("Exception shouldn't take place here");
}
......@@ -547,7 +547,7 @@ public class CreateMembershipsWorkflowSinglePartitionTest {
.header(DpsHeaders.AUTHORIZATION, "Bearer " + jwt)
.header(DpsHeaders.DATA_PARTITION_ID, "common")
.content(objectMapper.writeValueAsString(dto)))
.andExpect(MockMvcResultMatchers.status().isAccepted());
.andExpect(MockMvcResultMatchers.status().isOk());
} catch (Exception e) {
Assert.fail("Exception shouldn't take place here");
}
......@@ -594,7 +594,7 @@ public class CreateMembershipsWorkflowSinglePartitionTest {
.characterEncoding(StandardCharsets.UTF_8.name())
.header(DpsHeaders.AUTHORIZATION, "Bearer " + jwt)
.header(DpsHeaders.DATA_PARTITION_ID, "common"))
.andExpect(status().isAccepted());
.andExpect(status().isNoContent());
} catch (Exception e) {
Assert.fail("Exception shouldn't take place here");
}
......@@ -607,7 +607,7 @@ public class CreateMembershipsWorkflowSinglePartitionTest {
.header(DpsHeaders.AUTHORIZATION, "Bearer " + jwt)
.header(DpsHeaders.DATA_PARTITION_ID, "common")
.content(objectMapper.writeValueAsString(operations)))
.andExpect(status().isAccepted());
.andExpect(status().isOk());
}
private void assertGroupsEquals(String[] expectedGroupEmails, ListGroupResponseDto dto) {
......
......@@ -554,7 +554,7 @@ public class CreateMembershipsWorkflowSinglePartitionTest {
.header(DpsHeaders.AUTHORIZATION, "Bearer " + jwt)
.header(DpsHeaders.DATA_PARTITION_ID, "common")
.content(objectMapper.writeValueAsString(dto)))
.andExpect(status().isAccepted());
.andExpect(status().isCreated());
}
private ListGroupResponseDto performListGroupRequest(String jwt) throws Exception {
......@@ -575,7 +575,7 @@ public class CreateMembershipsWorkflowSinglePartitionTest {
.header(DpsHeaders.AUTHORIZATION, "Bearer " + jwt)
.header(DpsHeaders.DATA_PARTITION_ID, "common")
.content(objectMapper.writeValueAsString(dto)))
.andExpect(status().isAccepted());
.andExpect(status().isOk());
}
private ListMemberResponseDto performListMemberRequest(String groupEmail, String jwt) throws Exception {
......@@ -597,7 +597,7 @@ public class CreateMembershipsWorkflowSinglePartitionTest {
.characterEncoding(StandardCharsets.UTF_8.name())
.header(DpsHeaders.AUTHORIZATION, "Bearer " + jwt)
.header(DpsHeaders.DATA_PARTITION_ID, "common"))
.andExpect(status().isAccepted());
.andExpect(status().isNoContent());
}
private void performDeleteGroupRequest(String groupEmail, String jwt) throws Exception {
......@@ -606,7 +606,7 @@ public class CreateMembershipsWorkflowSinglePartitionTest {
.characterEncoding(StandardCharsets.UTF_8.name())
.header(DpsHeaders.AUTHORIZATION, "Bearer " + jwt)
.header(DpsHeaders.DATA_PARTITION_ID, "common"))
.andExpect(status().isAccepted());
.andExpect(status().isNoContent());
}
private void performUpdateGroupRequest(List<UpdateGroupOperation> operations, String groupEmail, String jwt) throws Exception {
......@@ -616,7 +616,7 @@ public class CreateMembershipsWorkflowSinglePartitionTest {
.header(DpsHeaders.AUTHORIZATION, "Bearer " + jwt)
.header(DpsHeaders.DATA_PARTITION_ID, "common")
.content(objectMapper.writeValueAsString(operations)))
.andExpect(status().isAccepted());
.andExpect(status().isOk());
}
private void assertMembersEquals(final String[] expectedMemberEmails, final ListMemberResponseDto dto) {
......
......@@ -37,7 +37,7 @@ public abstract class UpdateGroupTest extends AcceptanceBaseTest {
ClientResponse response = httpClientService.send(getRenameGroupRequestData(oldGroupName, newGroupName, token.getValue()));
UpdateGroupResponse updateGroupResponse = new Gson().fromJson(response.getEntity(String.class), UpdateGroupResponse.class);
Assert.assertEquals(202, response.getStatus());
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals(newGroupName.toLowerCase(), updateGroupResponse.getName());
Assert.assertEquals(configurationService.getIdOfGroup(newGroupName).toLowerCase(), updateGroupResponse.getEmail());
......@@ -61,7 +61,7 @@ public abstract class UpdateGroupTest extends AcceptanceBaseTest {
ClientResponse response = httpClientService.send(getUpdateAppIdsRequestData(groupName, newAppIds, token.getValue()));
UpdateGroupResponse updateGroupResponse = new Gson().fromJson(response.getEntity(String.class), UpdateGroupResponse.class);
Assert.assertEquals(202, response.getStatus());
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals(groupName.toLowerCase(), updateGroupResponse.getName());
Assert.assertEquals(configurationService.getIdOfGroup(groupName).toLowerCase(), updateGroupResponse.getEmail());
Assert.assertEquals(new HashSet<>(updateGroupResponse.getAppIds()), newAppIds);
......
......@@ -41,7 +41,7 @@ public class EntitlementsV2Service {
.token(token)
.body(new Gson().toJson(GroupItem.builder().name(groupName).description("desc").build())).build();
ClientResponse response = httpClientService.send(requestData);
Assert.assertEquals(202, response.getStatus());
Assert.assertEquals(201, response.getStatus());
return new Gson().fromJson(response.getEntity(String.class), GroupItem.class);
}
......@@ -53,7 +53,7 @@ public class EntitlementsV2Service {
.token(token)
.build();
ClientResponse response = httpClientService.send(requestData);
Assert.assertEquals(202, response.getStatus());
Assert.assertEquals(204, response.getStatus());
}
public ListMemberResponse getMembers(String groupEmail, String token) throws Exception {
......@@ -77,7 +77,7 @@ public class EntitlementsV2Service {
.token(token)
.body(new Gson().toJson(requestBody)).build();
ClientResponse response = httpClientService.send(requestData);
Assert.assertEquals(202, response.getStatus());
Assert.assertEquals(200, response.getStatus());
return new Gson().fromJson(response.getEntity(String.class), GroupItem.class);
}
......@@ -87,6 +87,6 @@ public class EntitlementsV2Service {
.relativePath(String.format("groups/%s/members/%s", groupEmail, memberEmail))
.token(token).build();
ClientResponse response = httpClientService.send(requestData);
Assert.assertEquals(202, response.getStatus());
Assert.assertEquals(204, response.getStatus());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment