feat: 리플렉션 제거 - InflowControlManager.getGroupBucket() public 메서드 추가
groupBucketList private 필드에 리플렉션 없이 접근할 수 있도록 getGroupBucket(String groupId) public 메서드 제공. 그룹 테이블 테스트 픽스처 SQL 추가 및 InflowControlManagerTest에 getGroupBucket() 동작 검증 테스트 케이스 2개 추가. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -371,6 +371,10 @@ public class InflowControlManager implements Lifecycle, Bucket {
|
||||
return groupIds;
|
||||
}
|
||||
|
||||
public CustomGroupBucket getGroupBucket(String groupId) {
|
||||
return groupBucketList.get(groupId);
|
||||
}
|
||||
|
||||
private CustomBucket makeBucketUsingInflowVO(InflowTargetVO inflowTarget) {
|
||||
if (InflowControlManager.isInflowTarget(inflowTarget)) {
|
||||
LocalBucketBuilder builder = Bucket4j.builder();
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.eactive.eai.common.inflow;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
@@ -21,21 +24,37 @@ import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.common.inflow" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.inflow" })
|
||||
@Sql({ "/com/eactive/eai/common/inflow/init_tseaifr09.sql", "/com/eactive/eai/common/inflow/init_tseaifr11.sql" })
|
||||
@Sql({
|
||||
"/com/eactive/eai/common/inflow/init_tseaifr09.sql",
|
||||
"/com/eactive/eai/common/inflow/init_tseaifr11.sql",
|
||||
"/com/eactive/eai/common/inflow/init_inflow_control_group.sql",
|
||||
"/com/eactive/eai/common/inflow/init_inflow_control_group_mapping.sql"
|
||||
})
|
||||
class InflowControlManagerTest {
|
||||
|
||||
@Autowired
|
||||
InflowControlManager inflowControlManager;
|
||||
|
||||
@Test
|
||||
void testStart() throws LifecycleException {
|
||||
// given
|
||||
|
||||
// when
|
||||
@BeforeEach
|
||||
void setUp() throws LifecycleException {
|
||||
if (!inflowControlManager.isStarted()) {
|
||||
inflowControlManager.start();
|
||||
}
|
||||
}
|
||||
|
||||
// then
|
||||
@Test
|
||||
void testStart() {
|
||||
assertTrue(inflowControlManager.isStarted());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetGroupBucket_existingGroup_returnsNotNull() {
|
||||
assertNotNull(inflowControlManager.getGroupBucket("test-group-001"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetGroupBucket_unknownGroup_returnsNull() {
|
||||
assertNull(inflowControlManager.getGroupBucket("non-existent-group"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
INSERT INTO inflow_control_group (group_id, group_name, threshold, threshold_per_second, threshold_time_unit, use_yn) VALUES
|
||||
('test-group-001', '테스트 그룹', 100, 10, 'MIN', '1');
|
||||
@@ -0,0 +1,2 @@
|
||||
INSERT INTO inflow_control_group_mapping (interface_id, group_id, use_yn) VALUES
|
||||
('FASSFEP00000004S2', 'test-group-001', '1');
|
||||
Reference in New Issue
Block a user