Skip to content

Commit

Permalink
Merge pull request #220 from Kernel360/fix/#178/fixRecordPage
Browse files Browse the repository at this point in the history
[#178] fix: Test 코드 수정
  • Loading branch information
xorwns118 authored Aug 30, 2024
2 parents 9cf4abb + 1b04a20 commit adcd558
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,11 @@ public class RecordIsUseDto {
@ToString
public static class Request {
private final Long recordId;

private final byte[] audio;

private final String languageCode;

private final boolean isAnalyzed;

private final ScriptEntity script;

private final boolean isUse;

private final ReportEntity report;

public Request(RecordEntity recordEntity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public void addRecordTest() {
@Test
public void deleteRecordTest() {
//given
RecordIsUseDto.Request request = mock(RecordIsUseDto.Request.class);
Long recordId = 1L;

//when
ResponseEntity<RecordIsUseDto.Response> actualResponse = recordController.deleteRecord(request);
ResponseEntity<RecordIsUseDto.Response> actualResponse = recordController.deleteRecord(recordId);

//then
assertNotNull(actualResponse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@ public void addRecordTest() throws IOException {
@Test
public void deleteRecordTest() {
// given
RecordIsUseDto.Request request = mock(RecordIsUseDto.Request.class);
when(request.getRecordEntity()).thenReturn(recordEntity);
Long recordId = 1L;
when(recordRepository.findById(recordId)).thenReturn(Optional.of(recordEntity));
when(recordEntity.getRecordId()).thenReturn(recordId);

// when
RecordEntity recordResult = RecordEntity.delete(request);
RecordEntity recordResult = RecordEntity.delete(recordId, recordEntity);
when(recordRepository.save(any(RecordEntity.class))).thenReturn(recordEntity);
RecordIsUseDto.Response actualResponse = recordService.deleteRecord(request);
RecordIsUseDto.Response actualResponse = recordService.deleteRecord(recordId);

// then
assertEquals(recordResult.getRecordId(), actualResponse.getRecordId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ void setUp() {
@Test
void testRequestDto() {
RecordIsUseDto.Request requestDto = new RecordIsUseDto.Request(mockRecordEntity);
when(mockRecordEntity.getRecordId()).thenReturn(1L);
when(mockRecordEntity.isUse()).thenReturn(true);

// Validate the Request DTO properties
assertEquals(mockRecordEntity, requestDto.getRecordEntity());
assertEquals(1L, requestDto.getRecordId());
assertEquals(true, requestDto.isUse());
}

@DisplayName("RecordIsUseDto.Response 생성자 및 getter 테스트")
Expand Down

0 comments on commit adcd558

Please sign in to comment.