refactor: 클라이언트 버킷 상태 모니터링 custom.inflow 패키지로 분리
- InflowTargetBucketService/Controller에서 클라이언트 관련 메서드/엔드포인트 제거 - ClientInflowTargetBucketService/Controller를 custom.inflow 패키지에 신규 생성 (ClientInflowTargetMetricService/Controller 패턴과 일치) - 관련 단위 테스트 추가 및 기존 테스트에서 클라이언트 케이스 제거 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
*
|
||||
* <p>Spring MVC를 기동하지 않고 컨트롤러를 직접 인스턴스화하여
|
||||
* 응답 구조(success, data, count, message)를 검증한다.
|
||||
* 클라이언트 관련 테스트는 ClientInflowTargetBucketControllerTest 에서 검증한다.
|
||||
*/
|
||||
class InflowTargetBucketControllerTest {
|
||||
|
||||
@@ -148,64 +149,4 @@ class InflowTargetBucketControllerTest {
|
||||
assertEquals(Boolean.TRUE, body.get("success"));
|
||||
assertEquals(1, body.get("count"));
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// 클라이언트 — 단일 조회
|
||||
// =========================================================================
|
||||
|
||||
@Test
|
||||
void getClientBucketStatus_found_successTrueAndDataPresent() {
|
||||
TargetBucketStatusDTO dto = makeDTO("CLIENT_A", "CLIENT");
|
||||
when(mockService.getClientBucketStatus("CLIENT_A")).thenReturn(dto);
|
||||
|
||||
ResponseEntity<?> response = controller.getClientBucketStatus("CLIENT_A");
|
||||
Map<String, Object> body = body(response);
|
||||
|
||||
assertEquals(200, response.getStatusCodeValue());
|
||||
assertEquals(Boolean.TRUE, body.get("success"));
|
||||
assertSame(dto, body.get("data"));
|
||||
assertFalse(body.containsKey("message"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getClientBucketStatus_notFound_successFalseWithClientId() {
|
||||
when(mockService.getClientBucketStatus("CLIENT_X")).thenReturn(null);
|
||||
|
||||
ResponseEntity<?> response = controller.getClientBucketStatus("CLIENT_X");
|
||||
Map<String, Object> body = body(response);
|
||||
|
||||
assertEquals(Boolean.FALSE, body.get("success"));
|
||||
assertTrue(body.get("message").toString().contains("CLIENT_X"));
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// 클라이언트 — 전체 조회
|
||||
// =========================================================================
|
||||
|
||||
@Test
|
||||
void getAllClientBucketStatus_returnsListAndCount() {
|
||||
List<TargetBucketStatusDTO> list = Arrays.asList(
|
||||
makeDTO("CLIENT_A", "CLIENT"),
|
||||
makeDTO("CLIENT_B", "CLIENT"),
|
||||
makeDTO("CLIENT_C", "CLIENT")
|
||||
);
|
||||
when(mockService.getAllClientBucketStatus()).thenReturn(list);
|
||||
|
||||
ResponseEntity<?> response = controller.getAllClientBucketStatus();
|
||||
Map<String, Object> body = body(response);
|
||||
|
||||
assertEquals(Boolean.TRUE, body.get("success"));
|
||||
assertSame(list, body.get("data"));
|
||||
assertEquals(3, body.get("count"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAllClientBucketStatus_emptyList_countZero() {
|
||||
when(mockService.getAllClientBucketStatus()).thenReturn(Collections.emptyList());
|
||||
|
||||
Map<String, Object> body = body(controller.getAllClientBucketStatus());
|
||||
|
||||
assertEquals(Boolean.TRUE, body.get("success"));
|
||||
assertEquals(0, body.get("count"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user