From a5398a990562d86b53b14aa7139b8d83c0e89010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EB=AA=85=EC=9A=B0?= Date: Tue, 26 Sep 2023 17:32:45 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=EC=9E=84=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profile/ProfileNameServiceTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/test/java/com/siliconvalley/profile/ProfileNameServiceTests.java diff --git a/src/test/java/com/siliconvalley/profile/ProfileNameServiceTests.java b/src/test/java/com/siliconvalley/profile/ProfileNameServiceTests.java new file mode 100644 index 0000000..518a767 --- /dev/null +++ b/src/test/java/com/siliconvalley/profile/ProfileNameServiceTests.java @@ -0,0 +1,12 @@ +package com.siliconvalley.profile; + +import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@Slf4j +@ExtendWith(MockitoExtension.class) +public class ProfileNameServiceTests { + +} From eb422f9bf7f5139e73d79db62fcb18f4f60dc60f Mon Sep 17 00:00:00 2001 From: Fishphobiagg Date: Wed, 27 Sep 2023 13:15:20 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=EC=8A=A4=ED=85=8C=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C=20API=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=20[BACK-85]=20Resolves=20:=20issue=20#85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../canvas/controller/CanvasController.java | 9 +++ .../canvas/service/CanvasConvertService.java | 4 ++ .../controller/DetectingTestController.java | 24 ++++++++ .../domain/google/dto/LabelResultDto.java | 18 ++++++ .../service/GoogleVisionApiService.java | 16 +++--- .../service/VisionDetectingService.java | 23 ++++++-- .../domain/profile/api/ProfileApi.java | 4 +- .../domain/rabbitMQ/code/RabbitMQCode.java | 1 + .../rabbitMQ/dto/DemoConversionRequest.java | 17 ++++++ .../rabbitMQ/dto/DemoConversionResponse.java | 11 ++++ .../service/ConvertRequestSender.java | 7 +++ .../application/RecordCreateService.java | 2 +- .../domain/record/dao/RecordFindDao.java | 1 + .../application/CanvasSseEmitterService.java | 1 - .../global/config/RabbitMqConfig.java | 8 +++ .../post/EmotionServiceTests.java | 4 ++ .../profile/ProfileNameServiceTests.java | 55 ++++++++++++++++++- .../vision/VisionDetectingServiceTests.java | 10 ++-- 18 files changed, 193 insertions(+), 22 deletions(-) create mode 100644 src/main/java/com/siliconvalley/domain/google/controller/DetectingTestController.java create mode 100644 src/main/java/com/siliconvalley/domain/google/dto/LabelResultDto.java create mode 100644 src/main/java/com/siliconvalley/domain/rabbitMQ/dto/DemoConversionRequest.java create mode 100644 src/main/java/com/siliconvalley/domain/rabbitMQ/dto/DemoConversionResponse.java create mode 100644 src/test/java/com/siliconvalley/post/EmotionServiceTests.java diff --git a/src/main/java/com/siliconvalley/domain/canvas/controller/CanvasController.java b/src/main/java/com/siliconvalley/domain/canvas/controller/CanvasController.java index 0ea2900..7236f1e 100644 --- a/src/main/java/com/siliconvalley/domain/canvas/controller/CanvasController.java +++ b/src/main/java/com/siliconvalley/domain/canvas/controller/CanvasController.java @@ -53,4 +53,13 @@ public SseEmitter connectSseForConvertedCanvas( return canvasSseEmitterService.connect(profileId); } + @GetMapping("") + public ResponseEntity convertSketchToCanvasTest( + @RequestParam MultipartFile sketchFile + )throws IOException{ + String sketchUrl = s3ImageUploadService.uploadFile(sketchFile, "rendingPage"); + Response response = canvasConvertService.convertSketchToCanvasDemo(sketchUrl); + return ResponseEntity.ok(response); + } + } diff --git a/src/main/java/com/siliconvalley/domain/canvas/service/CanvasConvertService.java b/src/main/java/com/siliconvalley/domain/canvas/service/CanvasConvertService.java index e74ed0f..dc5140b 100644 --- a/src/main/java/com/siliconvalley/domain/canvas/service/CanvasConvertService.java +++ b/src/main/java/com/siliconvalley/domain/canvas/service/CanvasConvertService.java @@ -43,6 +43,10 @@ public Response convertSketchToCanvas(Long profileId, Long subjectId, String ske return convertRequestSender.sendSketchConversionRequest(sketch, canvas.getId(), profileId, subject); } + public Response convertSketchToCanvasDemo(String sketch){ + + } + public Response updateSketchAndCanvas(Long profileId, Long canvasId, String sketch){ Canvas canvas = canvasFindDao.findById(canvasId); return canvasUpdateService.updateSketchAndCanvas(canvas, sketch, profileId); diff --git a/src/main/java/com/siliconvalley/domain/google/controller/DetectingTestController.java b/src/main/java/com/siliconvalley/domain/google/controller/DetectingTestController.java new file mode 100644 index 0000000..c180221 --- /dev/null +++ b/src/main/java/com/siliconvalley/domain/google/controller/DetectingTestController.java @@ -0,0 +1,24 @@ +package com.siliconvalley.domain.google.controller; + +import com.siliconvalley.domain.google.service.VisionDetectingService; +import com.siliconvalley.global.common.code.CommonCode; +import com.siliconvalley.global.common.dto.Response; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/api/test/google") +@RequiredArgsConstructor +public class DetectingTestController { + + private final VisionDetectingService visionDetectingService; + + @GetMapping("{canvasId}") + public ResponseEntity test( + @PathVariable Long canvasId + ){ + return ResponseEntity.ok(visionDetectingService.testLabelDetecting(canvasId)); + } + +} diff --git a/src/main/java/com/siliconvalley/domain/google/dto/LabelResultDto.java b/src/main/java/com/siliconvalley/domain/google/dto/LabelResultDto.java new file mode 100644 index 0000000..000a8b4 --- /dev/null +++ b/src/main/java/com/siliconvalley/domain/google/dto/LabelResultDto.java @@ -0,0 +1,18 @@ +package com.siliconvalley.domain.google.dto; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class LabelResultDto { + + private String label; + private Float confidence;; + + public LabelResultDto(String label, Float confidence){ + this.label = label; + this.confidence = confidence; + } +} diff --git a/src/main/java/com/siliconvalley/domain/google/service/GoogleVisionApiService.java b/src/main/java/com/siliconvalley/domain/google/service/GoogleVisionApiService.java index d581401..7af4c71 100644 --- a/src/main/java/com/siliconvalley/domain/google/service/GoogleVisionApiService.java +++ b/src/main/java/com/siliconvalley/domain/google/service/GoogleVisionApiService.java @@ -3,8 +3,6 @@ import com.google.api.gax.core.FixedCredentialsProvider; import com.google.auth.oauth2.GoogleCredentials; import com.google.cloud.vision.v1.*; -import com.google.cloud.vision.v1.ImageAnnotatorClient; -import com.google.cloud.vision.v1.ImageAnnotatorSettings; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -24,14 +22,17 @@ public class GoogleVisionApiService { @Value("${google.service.account.key}") private String serviceAccountKey; - public Map detectObjects(String filePath) { + public Map detectLabels(String filePath) { List requests = new ArrayList<>(); Map results = new HashMap<>(); try { ImageSource imageSource = ImageSource.newBuilder().setImageUri(filePath).build(); Image img = Image.newBuilder().setSource(imageSource).build(); - Feature feat = Feature.newBuilder().setType(Feature.Type.OBJECT_LOCALIZATION).build(); + + // LABEL_DETECTION 유형으로 변경 + Feature feat = Feature.newBuilder().setType(Feature.Type.LABEL_DETECTION).build(); + AnnotateImageRequest request = AnnotateImageRequest.newBuilder() .addFeatures(feat) .setImage(img) @@ -56,9 +57,10 @@ public Map detectObjects(String filePath) { continue; } - for (LocalizedObjectAnnotation entity : res.getLocalizedObjectAnnotationsList()) { - log.info("Detected object: " + entity.getName() + " with confidence: " + entity.getScore()); - results.put(entity.getName().toLowerCase(), entity.getScore()); + // EntityAnnotation 리스트로 변경 + for (EntityAnnotation annotation : res.getLabelAnnotationsList()) { + log.info("Detected label: " + annotation.getDescription() + " with confidence: " + annotation.getScore()); + results.put(annotation.getDescription().toLowerCase(), annotation.getScore()); } } } diff --git a/src/main/java/com/siliconvalley/domain/google/service/VisionDetectingService.java b/src/main/java/com/siliconvalley/domain/google/service/VisionDetectingService.java index 9ec4899..9074dd8 100644 --- a/src/main/java/com/siliconvalley/domain/google/service/VisionDetectingService.java +++ b/src/main/java/com/siliconvalley/domain/google/service/VisionDetectingService.java @@ -2,12 +2,17 @@ import com.siliconvalley.domain.canvas.dao.CanvasFindDao; import com.siliconvalley.domain.canvas.domain.Canvas; +import com.siliconvalley.domain.google.dto.LabelResultDto; import com.siliconvalley.domain.stage.domain.Score; +import com.siliconvalley.global.common.code.CommonCode; +import com.siliconvalley.global.common.dto.Response; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.List; import java.util.Map; @Service @@ -21,12 +26,22 @@ public class VisionDetectingService { public Score calculateCanvasScore(Long canvasId) { Canvas canvas = canvasFindDao.findById(canvasId); - Map detectResult = visionService.detectObjects(canvas.getCanvas()); - - if (detectResult.size() == 0) {return Score.LOW;} - Float detectionScore = detectResult.get(canvas.getSubject().getPix2Pix().getModelName()); + Map detectResult = visionService.detectLabels(canvas.getCanvas()); + if (detectResult.size() == 0 || canvas.getSubject().getPix2Pix().getVisionName().equals(null)) {return Score.LOW;} + Float detectionScore = detectResult.get(canvas.getSubject().getPix2Pix().getVisionName()); return Score.determineScore(detectionScore); } + public Response testLabelDetecting(Long canvasId){ + Canvas canvas = canvasFindDao.findById(canvasId); + List results = new ArrayList<>(); + for (Map.Entry entry : visionService.detectLabels(canvas.getCanvas()).entrySet()){ + results.add(new LabelResultDto(entry.getKey(), entry.getValue())); + } + + return Response.of(CommonCode.GOOD_REQUEST, results); + + } + } diff --git a/src/main/java/com/siliconvalley/domain/profile/api/ProfileApi.java b/src/main/java/com/siliconvalley/domain/profile/api/ProfileApi.java index 2b1d293..4dc9c8e 100644 --- a/src/main/java/com/siliconvalley/domain/profile/api/ProfileApi.java +++ b/src/main/java/com/siliconvalley/domain/profile/api/ProfileApi.java @@ -245,7 +245,7 @@ public ResponseEntity getStageWithRecord( } @PostMapping("/{profileId}/stages/{stageId}/record") - public ResponseEntity evaluateCanvasAndcreateRecord( + public ResponseEntity evaluateCanvasAndCreateRecord( @PathVariable(name = "profileId") Long profileId, @PathVariable(name = "stageId") Long stageId, @RequestBody RecordCreateRequest dto @@ -254,7 +254,7 @@ public ResponseEntity evaluateCanvasAndcreateRecord( } @PatchMapping("/{profileId}/stages/{stageId}/records/{recordId}") - public ResponseEntity evaluateCanvasAndupdateRecord( + public ResponseEntity evaluateCanvasAndUpdateRecord( @PathVariable(name = "recordId") Long recordId, @RequestBody RecordUpdateRequest dto ) { diff --git a/src/main/java/com/siliconvalley/domain/rabbitMQ/code/RabbitMQCode.java b/src/main/java/com/siliconvalley/domain/rabbitMQ/code/RabbitMQCode.java index e6d84f4..568c349 100644 --- a/src/main/java/com/siliconvalley/domain/rabbitMQ/code/RabbitMQCode.java +++ b/src/main/java/com/siliconvalley/domain/rabbitMQ/code/RabbitMQCode.java @@ -8,6 +8,7 @@ public enum RabbitMQCode implements ResponseCode { CONVERSION_REQUEST_FAILURE(400, "변환 요청에 실패하였습니다.", HttpStatus.BAD_REQUEST), CONVERSION_RESPONSE_SUCCESS(200, "변환 응답을 성공적으로 수신하였습니다.", HttpStatus.OK), CONVERSION_RESPONSE_FAILURE(500, "변환 응답 수신에 실패하였습니다.", HttpStatus.INTERNAL_SERVER_ERROR), + DEMO_CONVERSION_SUCCESS(200, "체험 변환 요청에 성공하였습니다.", HttpStatus.OK) ; private final int code; diff --git a/src/main/java/com/siliconvalley/domain/rabbitMQ/dto/DemoConversionRequest.java b/src/main/java/com/siliconvalley/domain/rabbitMQ/dto/DemoConversionRequest.java new file mode 100644 index 0000000..3870860 --- /dev/null +++ b/src/main/java/com/siliconvalley/domain/rabbitMQ/dto/DemoConversionRequest.java @@ -0,0 +1,17 @@ +package com.siliconvalley.domain.rabbitMQ.dto; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class DemoConversionRequest { + private String sketchUrl; + private String modelName; + + public DemoConversionRequest(String sketchUrl, String modelName){ + this.sketchUrl = sketchUrl; + this.modelName = modelName; + } +} diff --git a/src/main/java/com/siliconvalley/domain/rabbitMQ/dto/DemoConversionResponse.java b/src/main/java/com/siliconvalley/domain/rabbitMQ/dto/DemoConversionResponse.java new file mode 100644 index 0000000..89cfa4c --- /dev/null +++ b/src/main/java/com/siliconvalley/domain/rabbitMQ/dto/DemoConversionResponse.java @@ -0,0 +1,11 @@ +package com.siliconvalley.domain.rabbitMQ.dto; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class DemoConversionResponse { + private String canvasUrl; +} diff --git a/src/main/java/com/siliconvalley/domain/rabbitMQ/service/ConvertRequestSender.java b/src/main/java/com/siliconvalley/domain/rabbitMQ/service/ConvertRequestSender.java index 79f7253..0d31368 100644 --- a/src/main/java/com/siliconvalley/domain/rabbitMQ/service/ConvertRequestSender.java +++ b/src/main/java/com/siliconvalley/domain/rabbitMQ/service/ConvertRequestSender.java @@ -4,6 +4,7 @@ import com.siliconvalley.domain.item.subject.domain.Subject; import com.siliconvalley.domain.post.service.RankCachingService; import com.siliconvalley.domain.rabbitMQ.code.RabbitMQCode; +import com.siliconvalley.domain.rabbitMQ.dto.DemoConversionRequest; import com.siliconvalley.domain.rabbitMQ.dto.SketchConversionRequest; import com.siliconvalley.global.common.dto.Response; import lombok.RequiredArgsConstructor; @@ -28,4 +29,10 @@ public Response sendSketchConversionRequest(String sketchUrl, Long canvasId, Lon rabbitTemplate.convertAndSend(exchange, "sketch_conversion_request_queue" , request); return Response.of(RabbitMQCode.CONVERSION_REQUEST_SUCCESS, new CanvasConvertResponse(canvasId, rankCachingService.getTopPostThisWeek(subject.getId()))); } + + public Response sendDemoConversionRequest(String sketchUrl){ + DemoConversionRequest request = new DemoConversionRequest(sketchUrl, "panda"); + rabbitTemplate.convertAndSend(exchange, "demo_conversion_request_queue", request); + return Response.of(RabbitMQCode.CONVERSION_REQUEST_SUCCESS); + } } diff --git a/src/main/java/com/siliconvalley/domain/record/application/RecordCreateService.java b/src/main/java/com/siliconvalley/domain/record/application/RecordCreateService.java index 6dff7ba..38aae7a 100644 --- a/src/main/java/com/siliconvalley/domain/record/application/RecordCreateService.java +++ b/src/main/java/com/siliconvalley/domain/record/application/RecordCreateService.java @@ -36,7 +36,7 @@ public Response evaluateCanvasAndcreateRecord(Long profileId, Long stageId,Recor Profile profile = profileFindDao.findById(profileId); Stage stage = stageFindDao.findById(stageId); - if (recordFindDao.findByProfileId(profileId).isPresent()) { + if (recordFindDao.findByProfileIdAndStageId(profileId, stageId).isPresent()) { throw new RecordAlreadyExist(stage.getStageNum() + "번 스테이지 기록"); } diff --git a/src/main/java/com/siliconvalley/domain/record/dao/RecordFindDao.java b/src/main/java/com/siliconvalley/domain/record/dao/RecordFindDao.java index 02ead34..33de792 100644 --- a/src/main/java/com/siliconvalley/domain/record/dao/RecordFindDao.java +++ b/src/main/java/com/siliconvalley/domain/record/dao/RecordFindDao.java @@ -29,4 +29,5 @@ public Optional findByProfileId(Long profileId) { public Optional findByProfileIdAndStageId(Long profileId, Long stageId) { return recordRepository.findByProfileIdAndStageId(profileId, stageId); } + } diff --git a/src/main/java/com/siliconvalley/domain/sse/application/CanvasSseEmitterService.java b/src/main/java/com/siliconvalley/domain/sse/application/CanvasSseEmitterService.java index 3988746..4c6a4e1 100644 --- a/src/main/java/com/siliconvalley/domain/sse/application/CanvasSseEmitterService.java +++ b/src/main/java/com/siliconvalley/domain/sse/application/CanvasSseEmitterService.java @@ -12,7 +12,6 @@ public class CanvasSseEmitterService { private final CanvasSseEmitterRepository canvasSseEmitterRepository; private final CanvasSseEmitterCreater canvasSseEmitterCreater; - private final SseEmitterSender sseEmitterSender; public SseEmitter connect(Long profileId) { diff --git a/src/main/java/com/siliconvalley/global/config/RabbitMqConfig.java b/src/main/java/com/siliconvalley/global/config/RabbitMqConfig.java index ddb3e18..74868e7 100644 --- a/src/main/java/com/siliconvalley/global/config/RabbitMqConfig.java +++ b/src/main/java/com/siliconvalley/global/config/RabbitMqConfig.java @@ -31,6 +31,9 @@ Queue requestQueue() { return new Queue("sketch_conversion_request_queue", true); } + @Bean + Queue demoConversionRequestQueue() {return new Queue("demo_conversion_request_queue", true);} + @Bean Queue responseQueue() { return QueueBuilder.durable("sketch_conversion_response_queue") @@ -85,6 +88,11 @@ public Binding bindingRequestQueue(Queue requestQueue, TopicExchange topicExchan return BindingBuilder.bind(requestQueue).to(topicExchange).with("sketch_conversion_request_queue"); } + @Bean + public Binding bindingDemoRequestQueue(Queue demoConversionRequestQueue, TopicExchange topicExchange){ + return BindingBuilder.bind(demoConversionRequestQueue).to(topicExchange).with("demo_conversion_request_queue"); + } + @Bean public Binding bindingResponseQueue(Queue responseQueue, TopicExchange topicExchange) { return BindingBuilder.bind(responseQueue).to(topicExchange).with("sketch_conversion_response_queue"); diff --git a/src/test/java/com/siliconvalley/post/EmotionServiceTests.java b/src/test/java/com/siliconvalley/post/EmotionServiceTests.java new file mode 100644 index 0000000..77c4a04 --- /dev/null +++ b/src/test/java/com/siliconvalley/post/EmotionServiceTests.java @@ -0,0 +1,4 @@ +package com.siliconvalley.post; + +public class EmotionServiceTests { +} diff --git a/src/test/java/com/siliconvalley/profile/ProfileNameServiceTests.java b/src/test/java/com/siliconvalley/profile/ProfileNameServiceTests.java index 518a767..5aa22a9 100644 --- a/src/test/java/com/siliconvalley/profile/ProfileNameServiceTests.java +++ b/src/test/java/com/siliconvalley/profile/ProfileNameServiceTests.java @@ -1,12 +1,63 @@ package com.siliconvalley.profile; -import lombok.extern.slf4j.Slf4j; +import com.siliconvalley.domain.profile.dao.ProfileFindDao; +import com.siliconvalley.domain.profile.exception.ProfileNameDuplicateException; +import com.siliconvalley.domain.profile.exception.ProfileNameIncludeBadWordException; +import com.siliconvalley.domain.profile.application.ProfileNameFilterService; import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -@Slf4j +import static org.mockito.Mockito.when; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + @ExtendWith(MockitoExtension.class) +@DisplayName("프로필 이름 생성 정책 테스트") public class ProfileNameServiceTests { + @InjectMocks + private ProfileNameFilterService profileNameFilterService; + + @Mock + private ProfileFindDao profileFindDao; + + @Test + @DisplayName("정책에 위반되지 않는 프로필 이름 생성") + void 유효한_프로필_이름_테스트() { + //given + String 유효한프로필이름 = "유효한이름"; + + //when + when(profileFindDao.existsByProfileName(유효한프로필이름)).thenReturn(false); + + //then + assertDoesNotThrow(() -> profileNameFilterService.profileNameFilter(유효한프로필이름)); + } + + @Test + @DisplayName("프로필 이름에 부적절한 단어 포함 시 예외 발생") + void 부적절한_단어_테스트() { + //given + String 부적절한단어포함프로필이름 = "지랄"; + + //then + assertThrows(ProfileNameIncludeBadWordException.class, () -> profileNameFilterService.profileNameFilter(부적절한단어포함프로필이름)); + } + + @Test + @DisplayName("이미 사용 중인 프로필 이름 제공 시 예외 발생") + void 중복_프로필_이름_테스트() { + //given + String 중복된프로필이름 = "중복이름"; + + //when + when(profileFindDao.existsByProfileName(중복된프로필이름)).thenReturn(true); + + //then + assertThrows(ProfileNameDuplicateException.class, () -> profileNameFilterService.profileNameFilter(중복된프로필이름)); + } } diff --git a/src/test/java/com/siliconvalley/vision/VisionDetectingServiceTests.java b/src/test/java/com/siliconvalley/vision/VisionDetectingServiceTests.java index 595bac2..79a719f 100644 --- a/src/test/java/com/siliconvalley/vision/VisionDetectingServiceTests.java +++ b/src/test/java/com/siliconvalley/vision/VisionDetectingServiceTests.java @@ -41,7 +41,7 @@ public class VisionDetectingServiceTests { Canvas mockCanvas = mock(Canvas.class, RETURNS_DEEP_STUBS); when(canvasFindDao.findById(canvasId)).thenReturn(mockCanvas); when(mockCanvas.getCanvas()).thenReturn("sampleCanvasData"); - when(visionService.detectObjects("sampleCanvasData")).thenReturn(Map.of("anotherModelName", 0.8f)); // 수정된 점수 + when(visionService.detectLabels("sampleCanvasData")).thenReturn(Map.of("anotherModelName", 0.8f)); // 수정된 점수 when(mockCanvas.getSubject().getPix2Pix().getModelName()).thenReturn("sampleModelName"); // When @@ -59,7 +59,7 @@ public class VisionDetectingServiceTests { Canvas mockCanvas = mock(Canvas.class, RETURNS_DEEP_STUBS); when(canvasFindDao.findById(canvasId)).thenReturn(mockCanvas); when(mockCanvas.getCanvas()).thenReturn("sampleCanvasData"); - when(visionService.detectObjects("sampleCanvasData")).thenReturn(Map.of("sampleModelName", 0.3f)); // 수정된 점수 + when(visionService.detectLabels("sampleCanvasData")).thenReturn(Map.of("sampleModelName", 0.3f)); // 수정된 점수 when(mockCanvas.getSubject().getPix2Pix().getModelName()).thenReturn("sampleModelName"); // When @@ -77,7 +77,7 @@ public class VisionDetectingServiceTests { Canvas mockCanvas = mock(Canvas.class, RETURNS_DEEP_STUBS); when(canvasFindDao.findById(canvasId)).thenReturn(mockCanvas); when(mockCanvas.getCanvas()).thenReturn("sampleCanvasData"); - when(visionService.detectObjects("sampleCanvasData")).thenReturn(Map.of("sampleModelName", 0.8f)); // 수정된 점수 + when(visionService.detectLabels("sampleCanvasData")).thenReturn(Map.of("sampleModelName", 0.8f)); // 수정된 점수 when(mockCanvas.getSubject().getPix2Pix().getModelName()).thenReturn("sampleModelName"); // When @@ -97,7 +97,7 @@ public class VisionDetectingServiceTests { when(mockCanvas.getCanvas()).thenReturn("sampleCanvasData"); // 탐지된 물체가 없을 경우 빈 Map 반환 - when(visionService.detectObjects("sampleCanvasData")).thenReturn(Map.of()); + when(visionService.detectLabels("sampleCanvasData")).thenReturn(Map.of()); // When Score result = visionDetectingService.calculateCanvasScore(canvasId); @@ -116,7 +116,7 @@ public class VisionDetectingServiceTests { when(mockCanvas.getCanvas()).thenReturn("sampleCanvasData"); // 탐지된 물체가 없을 경우 빈 Map 반환 - when(visionService.detectObjects("sampleCanvasData")).thenReturn(Map.of("Error", -1f)); + when(visionService.detectLabels("sampleCanvasData")).thenReturn(Map.of("Error", -1f)); // When Score result = visionDetectingService.calculateCanvasScore(canvasId);