#31 loan: delete judgement
This commit is contained in:
@@ -39,4 +39,12 @@ public class JudgementController extends AbstractController {
|
||||
) {
|
||||
return ok(judgementService.update(judgementId, request));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{judgementId}")
|
||||
public ResponseDto<Void> delete(
|
||||
@PathVariable Long judgementId
|
||||
) {
|
||||
judgementService.delete(judgementId);
|
||||
return ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,6 @@ public interface JudgementService {
|
||||
JudgementDto.Response getJudgementOfApplication(Long applicationId);
|
||||
|
||||
JudgementDto.Response update(Long judgementId, JudgementDto.Request request);
|
||||
|
||||
void delete(Long judgementId);
|
||||
}
|
||||
|
||||
@@ -68,6 +68,16 @@ public class JudgementServiceImpl implements JudgementService {
|
||||
return modelMapper.map(judgement, JudgementDto.Response.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long judgementId) {
|
||||
Judgement judgement = judgementRepository.findById(judgementId)
|
||||
.orElseThrow(() -> new BaseException(ResultType.SYSTEM_ERROR));
|
||||
|
||||
judgement.setIsDeleted(true);
|
||||
|
||||
judgementRepository.save(judgement);
|
||||
}
|
||||
|
||||
private boolean isPresentApplication(Long applicationId) {
|
||||
return applicationRepository.findById(applicationId).isPresent();
|
||||
}
|
||||
|
||||
@@ -115,4 +115,19 @@ class JudgementServiceImplTest {
|
||||
assertThat(actual.getName()).isSameAs(request.getName());
|
||||
assertThat(actual.getApprovalAmount()).isSameAs(request.getApprovalAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
void Should_DeletedJudgementEntity_When_RequestDeleteExistJudgementInfo() {
|
||||
|
||||
Judgement entity = Judgement.builder()
|
||||
.judgementId(1L)
|
||||
.build();
|
||||
|
||||
when(judgementRepository.findById(1L)).thenReturn(Optional.ofNullable(entity));
|
||||
when(judgementRepository.save(ArgumentMatchers.any(Judgement.class))).thenReturn(entity);
|
||||
|
||||
judgementService.delete(1L);
|
||||
|
||||
assertThat(entity.getIsDeleted()).isTrue();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user