DJBRequestProcessor Override 메소드 시그니쳐 변경
This commit is contained in:
@@ -1,11 +1,14 @@
|
|||||||
package com.eactive.eai.custom.inbound.processor;
|
package com.eactive.eai.custom.inbound.processor;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import com.eactive.eai.common.inflow.Bucket;
|
import com.eactive.eai.common.inflow.Bucket;
|
||||||
import com.eactive.eai.common.inflow.InflowTargetVO;
|
import com.eactive.eai.common.inflow.InflowTargetVO;
|
||||||
import com.eactive.eai.common.inflow.dual.DualBucket;
|
import com.eactive.eai.common.inflow.dual.DualBucket;
|
||||||
import com.eactive.eai.common.inflow.dual.DualCustomBucket;
|
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.custom.inflow.ClientDualBucket;
|
||||||
import com.eactive.eai.inbound.processor.RequestProcessor;
|
import com.eactive.eai.inbound.processor.RequestProcessor;
|
||||||
|
|
||||||
@@ -23,7 +26,8 @@ import com.eactive.eai.inbound.processor.RequestProcessor;
|
|||||||
public class DJBRequestProcessor extends RequestProcessor {
|
public class DJBRequestProcessor extends RequestProcessor {
|
||||||
|
|
||||||
@Override
|
@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 (StringUtils.isBlank(clientId)) return null;
|
||||||
if (bucket instanceof ClientDualBucket) {
|
if (bucket instanceof ClientDualBucket) {
|
||||||
return ((ClientDualBucket) bucket).isClientPassDetail(clientId);
|
return ((ClientDualBucket) bucket).isClientPassDetail(clientId);
|
||||||
@@ -32,9 +36,9 @@ public class DJBRequestProcessor extends RequestProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected InflowTargetVO resolveClientInflowThreshold(Bucket bucket, String clientId) {
|
protected InflowTargetVO resolveCustomInflowThreshold(Bucket bucket, EAIMessage eaiMsg, Properties prop) {
|
||||||
if (bucket instanceof ClientDualBucket) {
|
if (bucket instanceof ClientDualBucket) {
|
||||||
return ((ClientDualBucket) bucket).getClientInflowThreshold(clientId);
|
return ((ClientDualBucket) bucket).getClientInflowThreshold(eaiMsg.getClientId());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-9
@@ -8,6 +8,8 @@ import static org.mockito.Mockito.never;
|
|||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.context.ApplicationContext;
|
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.InflowTargetVO;
|
||||||
import com.eactive.eai.common.inflow.dual.DualBucket;
|
import com.eactive.eai.common.inflow.dual.DualBucket;
|
||||||
import com.eactive.eai.common.inflow.dual.DualCustomBucket;
|
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.server.EAIServerManager;
|
||||||
import com.eactive.eai.common.util.ApplicationContextProvider;
|
import com.eactive.eai.common.util.ApplicationContextProvider;
|
||||||
import com.eactive.eai.custom.inflow.ClientDualBucket;
|
import com.eactive.eai.custom.inflow.ClientDualBucket;
|
||||||
@@ -53,6 +56,12 @@ class DJBRequestProcessorTest {
|
|||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private EAIMessage mockEaiMsg(String clientId) {
|
||||||
|
EAIMessage msg = mock(EAIMessage.class);
|
||||||
|
when(msg.getClientId()).thenReturn(clientId);
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// checkAdapterInflow
|
// checkAdapterInflow
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
@@ -148,43 +157,43 @@ class DJBRequestProcessorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// checkClientInflow — ClientDualBucket 기반
|
// checkCustomInflow — ClientDualBucket 기반
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void checkClientInflow_clientDualBucket_pass_returnsNull() {
|
void checkCustomInflow_clientDualBucket_pass_returnsNull() {
|
||||||
DJBRequestProcessor processor = new DJBRequestProcessor();
|
DJBRequestProcessor processor = new DJBRequestProcessor();
|
||||||
ClientDualBucket mockBucket = mock(ClientDualBucket.class);
|
ClientDualBucket mockBucket = mock(ClientDualBucket.class);
|
||||||
when(mockBucket.isClientPassDetail("CLIENT_A")).thenReturn(null);
|
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");
|
verify(mockBucket).isClientPassDetail("CLIENT_A");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void checkClientInflow_clientDualBucket_blocked() {
|
void checkCustomInflow_clientDualBucket_blocked() {
|
||||||
DJBRequestProcessor processor = new DJBRequestProcessor();
|
DJBRequestProcessor processor = new DJBRequestProcessor();
|
||||||
ClientDualBucket mockBucket = mock(ClientDualBucket.class);
|
ClientDualBucket mockBucket = mock(ClientDualBucket.class);
|
||||||
when(mockBucket.isClientPassDetail("CLIENT_A")).thenReturn(DualCustomBucket.RESULT_BLOCKED_THRESHOLD);
|
when(mockBucket.isClientPassDetail("CLIENT_A")).thenReturn(DualCustomBucket.RESULT_BLOCKED_THRESHOLD);
|
||||||
|
|
||||||
assertEquals(DualCustomBucket.RESULT_BLOCKED_THRESHOLD,
|
assertEquals(DualCustomBucket.RESULT_BLOCKED_THRESHOLD,
|
||||||
processor.checkClientInflow(mockBucket, "CLIENT_A"));
|
processor.checkCustomInflow(mockBucket, mockEaiMsg("CLIENT_A"), new Properties()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void checkClientInflow_nonClientDualBucket_returnsNull() {
|
void checkCustomInflow_nonClientDualBucket_returnsNull() {
|
||||||
DJBRequestProcessor processor = new DJBRequestProcessor();
|
DJBRequestProcessor processor = new DJBRequestProcessor();
|
||||||
Bucket mockBucket = mock(Bucket.class);
|
Bucket mockBucket = mock(Bucket.class);
|
||||||
|
|
||||||
assertNull(processor.checkClientInflow(mockBucket, "CLIENT_A"));
|
assertNull(processor.checkCustomInflow(mockBucket, mockEaiMsg("CLIENT_A"), new Properties()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void checkClientInflow_blankClientId_returnsNull() {
|
void checkCustomInflow_blankClientId_returnsNull() {
|
||||||
DJBRequestProcessor processor = new DJBRequestProcessor();
|
DJBRequestProcessor processor = new DJBRequestProcessor();
|
||||||
ClientDualBucket mockBucket = mock(ClientDualBucket.class);
|
ClientDualBucket mockBucket = mock(ClientDualBucket.class);
|
||||||
|
|
||||||
assertNull(processor.checkClientInflow(mockBucket, ""));
|
assertNull(processor.checkCustomInflow(mockBucket, mockEaiMsg(""), new Properties()));
|
||||||
verify(mockBucket, never()).isClientPassDetail(any());
|
verify(mockBucket, never()).isClientPassDetail(any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user