diff --git a/src/main/java/com/eactive/eai/custom/inbound/processor/DJBRequestProcessor.java b/src/main/java/com/eactive/eai/custom/inbound/processor/DJBRequestProcessor.java index 8e7c133..d356c6b 100644 --- a/src/main/java/com/eactive/eai/custom/inbound/processor/DJBRequestProcessor.java +++ b/src/main/java/com/eactive/eai/custom/inbound/processor/DJBRequestProcessor.java @@ -1,11 +1,14 @@ package com.eactive.eai.custom.inbound.processor; +import java.util.Properties; + import org.apache.commons.lang3.StringUtils; import com.eactive.eai.common.inflow.Bucket; import com.eactive.eai.common.inflow.InflowTargetVO; import com.eactive.eai.common.inflow.dual.DualBucket; import com.eactive.eai.common.inflow.dual.DualCustomBucket; +import com.eactive.eai.common.message.EAIMessage; import com.eactive.eai.custom.inflow.ClientDualBucket; import com.eactive.eai.inbound.processor.RequestProcessor; @@ -23,7 +26,8 @@ import com.eactive.eai.inbound.processor.RequestProcessor; public class DJBRequestProcessor extends RequestProcessor { @Override - protected String checkClientInflow(Bucket bucket, String clientId) { + protected String checkCustomInflow(Bucket bucket, EAIMessage eaiMsg, Properties prop) { + String clientId = eaiMsg.getClientId(); if (StringUtils.isBlank(clientId)) return null; if (bucket instanceof ClientDualBucket) { return ((ClientDualBucket) bucket).isClientPassDetail(clientId); @@ -32,9 +36,9 @@ public class DJBRequestProcessor extends RequestProcessor { } @Override - protected InflowTargetVO resolveClientInflowThreshold(Bucket bucket, String clientId) { + protected InflowTargetVO resolveCustomInflowThreshold(Bucket bucket, EAIMessage eaiMsg, Properties prop) { if (bucket instanceof ClientDualBucket) { - return ((ClientDualBucket) bucket).getClientInflowThreshold(clientId); + return ((ClientDualBucket) bucket).getClientInflowThreshold(eaiMsg.getClientId()); } return null; } diff --git a/src/test/java/com/eactive/eai/custom/inbound/processor/DJBRequestProcessorTest.java b/src/test/java/com/eactive/eai/custom/inbound/processor/DJBRequestProcessorTest.java index 84cf054..2c38e58 100644 --- a/src/test/java/com/eactive/eai/custom/inbound/processor/DJBRequestProcessorTest.java +++ b/src/test/java/com/eactive/eai/custom/inbound/processor/DJBRequestProcessorTest.java @@ -8,6 +8,8 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.util.Properties; + import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; @@ -17,6 +19,7 @@ import com.eactive.eai.common.inflow.Bucket; import com.eactive.eai.common.inflow.InflowTargetVO; import com.eactive.eai.common.inflow.dual.DualBucket; import com.eactive.eai.common.inflow.dual.DualCustomBucket; +import com.eactive.eai.common.message.EAIMessage; import com.eactive.eai.common.server.EAIServerManager; import com.eactive.eai.common.util.ApplicationContextProvider; import com.eactive.eai.custom.inflow.ClientDualBucket; @@ -53,6 +56,12 @@ class DJBRequestProcessorTest { return vo; } + private EAIMessage mockEaiMsg(String clientId) { + EAIMessage msg = mock(EAIMessage.class); + when(msg.getClientId()).thenReturn(clientId); + return msg; + } + // ------------------------------------------------------------------------- // checkAdapterInflow // ------------------------------------------------------------------------- @@ -148,43 +157,43 @@ class DJBRequestProcessorTest { } // ------------------------------------------------------------------------- - // checkClientInflow — ClientDualBucket 기반 + // checkCustomInflow — ClientDualBucket 기반 // ------------------------------------------------------------------------- @Test - void checkClientInflow_clientDualBucket_pass_returnsNull() { + void checkCustomInflow_clientDualBucket_pass_returnsNull() { DJBRequestProcessor processor = new DJBRequestProcessor(); ClientDualBucket mockBucket = mock(ClientDualBucket.class); when(mockBucket.isClientPassDetail("CLIENT_A")).thenReturn(null); - assertNull(processor.checkClientInflow(mockBucket, "CLIENT_A")); + assertNull(processor.checkCustomInflow(mockBucket, mockEaiMsg("CLIENT_A"), new Properties())); verify(mockBucket).isClientPassDetail("CLIENT_A"); } @Test - void checkClientInflow_clientDualBucket_blocked() { + void checkCustomInflow_clientDualBucket_blocked() { DJBRequestProcessor processor = new DJBRequestProcessor(); ClientDualBucket mockBucket = mock(ClientDualBucket.class); when(mockBucket.isClientPassDetail("CLIENT_A")).thenReturn(DualCustomBucket.RESULT_BLOCKED_THRESHOLD); assertEquals(DualCustomBucket.RESULT_BLOCKED_THRESHOLD, - processor.checkClientInflow(mockBucket, "CLIENT_A")); + processor.checkCustomInflow(mockBucket, mockEaiMsg("CLIENT_A"), new Properties())); } @Test - void checkClientInflow_nonClientDualBucket_returnsNull() { + void checkCustomInflow_nonClientDualBucket_returnsNull() { DJBRequestProcessor processor = new DJBRequestProcessor(); Bucket mockBucket = mock(Bucket.class); - assertNull(processor.checkClientInflow(mockBucket, "CLIENT_A")); + assertNull(processor.checkCustomInflow(mockBucket, mockEaiMsg("CLIENT_A"), new Properties())); } @Test - void checkClientInflow_blankClientId_returnsNull() { + void checkCustomInflow_blankClientId_returnsNull() { DJBRequestProcessor processor = new DJBRequestProcessor(); ClientDualBucket mockBucket = mock(ClientDualBucket.class); - assertNull(processor.checkClientInflow(mockBucket, "")); + assertNull(processor.checkCustomInflow(mockBucket, mockEaiMsg(""), new Properties())); verify(mockBucket, never()).isClientPassDetail(any()); }