Skip to content

Commit

Permalink
MOSIP-38450: Admin API review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Swetha K <[email protected]>
  • Loading branch information
Swetha K committed Jan 10, 2025
1 parent 432e184 commit e264ad0
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -825,30 +825,36 @@ public void getAllPoliciesTest() throws Exception {

@Test
public void deactivatePolicyTest() throws Exception {
ResponseWrapperV2<DeactivatePolicyResponseDto> responseWrapper = new ResponseWrapperV2<>();
RequestWrapperV2<DeactivateRequestDto> requestWrapper = new RequestWrapperV2<>();
DeactivateRequestDto requestDto = new DeactivateRequestDto();
requestDto.setStatus("De-Activate");
requestWrapper.setRequest(requestDto);

ResponseWrapperV2<DeactivatePolicyResponseDto> responseWrapper = new ResponseWrapperV2<>();
DeactivatePolicyResponseDto deactivatePolicyResponseDto = new DeactivatePolicyResponseDto();
responseWrapper.setResponse(deactivatePolicyResponseDto);

Mockito.when(policyManagementService.deactivatePolicy(anyString(), any()))
.thenReturn(responseWrapper);
policyManagementController.deactivatePolicy("policy123", requestWrapper);
mockMvc.perform(MockMvcRequestBuilders.patch("/policies/12345").contentType(MediaType.APPLICATION_JSON_VALUE)
.content(objectMapper.writeValueAsString(requestWrapper))).andExpect(status().isOk());
}

@Test
public void deactivatePolicyGroupTest() throws Exception {
String policyGroupId = "test-policy-group-id";
ResponseWrapperV2<DeactivatePolicyGroupResponseDto> responseWrapper = new ResponseWrapperV2<>();

RequestWrapperV2<DeactivateRequestDto> requestWrapper = new RequestWrapperV2<>();
DeactivateRequestDto requestDto = new DeactivateRequestDto();
requestDto.setStatus("De-Activate");
requestWrapper.setRequest(requestDto);

when(policyManagementService.deactivatePolicyGroup(policyGroupId, requestDto)).thenReturn(responseWrapper);
ResponseWrapperV2<DeactivatePolicyGroupResponseDto> responseWrapper = new ResponseWrapperV2<>();
DeactivatePolicyGroupResponseDto deactivatePolicyGroupResponseDto = new DeactivatePolicyGroupResponseDto();
responseWrapper.setResponse(deactivatePolicyGroupResponseDto);

Mockito.when(policyManagementService.deactivatePolicyGroup(anyString(), any())).thenReturn(responseWrapper);

policyManagementController.deactivatePolicyGroup(policyGroupId, requestWrapper);
mockMvc.perform(MockMvcRequestBuilders.patch("/policies/group/12345").contentType(MediaType.APPLICATION_JSON_VALUE)
.content(objectMapper.writeValueAsString(requestWrapper))).andExpect(status().isOk());
}

}

0 comments on commit e264ad0

Please sign in to comment.