From 1b04a2083df3e5d037698cbf96d717bfd6cb47e5 Mon Sep 17 00:00:00 2001 From: xorwns118 Date: Fri, 30 Aug 2024 17:15:00 +0900 Subject: [PATCH] =?UTF-8?q?[#178]=20fix:=20Test=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/speech/up/record/service/dto/RecordIsUseDto.java | 6 ------ .../speech/up/record/controller/RecordControllerTest.java | 4 ++-- .../com/speech/up/record/service/RecordServiceTest.java | 8 ++++---- .../speech/up/record/service/dto/RecordIsUseDtoTest.java | 5 ++++- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/speech/up/record/service/dto/RecordIsUseDto.java b/src/main/java/com/speech/up/record/service/dto/RecordIsUseDto.java index 7db1c41..8e10585 100644 --- a/src/main/java/com/speech/up/record/service/dto/RecordIsUseDto.java +++ b/src/main/java/com/speech/up/record/service/dto/RecordIsUseDto.java @@ -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) { diff --git a/src/test/java/com/speech/up/record/controller/RecordControllerTest.java b/src/test/java/com/speech/up/record/controller/RecordControllerTest.java index d52eee4..b6ff003 100644 --- a/src/test/java/com/speech/up/record/controller/RecordControllerTest.java +++ b/src/test/java/com/speech/up/record/controller/RecordControllerTest.java @@ -74,10 +74,10 @@ public void addRecordTest() { @Test public void deleteRecordTest() { //given - RecordIsUseDto.Request request = mock(RecordIsUseDto.Request.class); + Long recordId = 1L; //when - ResponseEntity actualResponse = recordController.deleteRecord(request); + ResponseEntity actualResponse = recordController.deleteRecord(recordId); //then assertNotNull(actualResponse); diff --git a/src/test/java/com/speech/up/record/service/RecordServiceTest.java b/src/test/java/com/speech/up/record/service/RecordServiceTest.java index 241d066..fa5919a 100644 --- a/src/test/java/com/speech/up/record/service/RecordServiceTest.java +++ b/src/test/java/com/speech/up/record/service/RecordServiceTest.java @@ -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()); diff --git a/src/test/java/com/speech/up/record/service/dto/RecordIsUseDtoTest.java b/src/test/java/com/speech/up/record/service/dto/RecordIsUseDtoTest.java index f1c1195..2068251 100644 --- a/src/test/java/com/speech/up/record/service/dto/RecordIsUseDtoTest.java +++ b/src/test/java/com/speech/up/record/service/dto/RecordIsUseDtoTest.java @@ -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 테스트")