Skip to content

Commit b20b903

Browse files
去除无用的被mock的map
1 parent 201acac commit b20b903

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

core/src/test/java/org/apache/servicecomb/core/TestInvocation.java

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
package org.apache.servicecomb.core;
1818

1919
import java.util.Arrays;
20-
import java.util.Map;
2120

22-
import org.apache.logging.log4j.core.util.internal.InternalLoggerRegistry;
2321
import org.apache.servicecomb.core.definition.InvocationRuntimeType;
2422
import org.apache.servicecomb.core.definition.OperationMeta;
2523
import org.apache.servicecomb.core.event.InvocationBaseEvent;
@@ -40,19 +38,16 @@
4038
import org.junit.BeforeClass;
4139
import org.junit.Test;
4240
import org.junit.jupiter.api.Assertions;
43-
import org.mockito.Mockito;
4441

4542
import com.google.common.eventbus.EventBus;
4643
import com.google.common.eventbus.Subscribe;
4744

48-
import mockit.Deencapsulation;
4945
import mockit.Expectations;
5046
import mockit.Mock;
5147
import mockit.MockUp;
5248
import mockit.Mocked;
5349

5450
public class TestInvocation {
55-
Invocation invocation;
5651

5752
@Mocked
5853
Endpoint endpoint;
@@ -63,9 +58,6 @@ public class TestInvocation {
6358
@Mocked
6459
InvocationRuntimeType invocationRuntimeType;
6560

66-
@Mocked
67-
Map<String, Object> arguments;
68-
6961
static long nanoTime = 123;
7062

7163
@BeforeClass
@@ -98,7 +90,7 @@ public void onStart(InvocationStartEvent event) {
9890
};
9991
EventManager.register(subscriber);
10092

101-
Invocation invocation = new Invocation(endpoint, operationMeta, arguments);
93+
Invocation invocation = new Invocation(endpoint, operationMeta, null);
10294
invocation.onStart();
10395

10496
Assertions.assertSame(invocation, result.value);
@@ -118,7 +110,7 @@ public void onStart(InvocationFinishEvent event) {
118110
};
119111
EventManager.register(subscriber);
120112

121-
Invocation invocation = new Invocation(endpoint, operationMeta, arguments);
113+
Invocation invocation = new Invocation(endpoint, operationMeta, null);
122114
Assertions.assertFalse(invocation.isFinished());
123115
Response response = Response.succResp(null);
124116
invocation.onFinish(response);
@@ -137,19 +129,19 @@ public void onStart(InvocationFinishEvent event) {
137129

138130
@Test
139131
public void isConsumer_yes() {
140-
Invocation invocation = new Invocation(endpoint, operationMeta, arguments);
132+
Invocation invocation = new Invocation(endpoint, operationMeta, null);
141133
Assertions.assertFalse(invocation.isConsumer());
142134
}
143135

144136
@Test
145137
public void isConsumer_no(@Mocked ReferenceConfig referenceConfig) {
146-
Invocation invocation = new Invocation(referenceConfig, operationMeta, invocationRuntimeType, arguments);
138+
Invocation invocation = new Invocation(referenceConfig, operationMeta, invocationRuntimeType, null);
147139
Assertions.assertTrue(invocation.isConsumer());
148140
}
149141

150142
@Test
151143
public void localContext(@Mocked ReferenceConfig referenceConfig) {
152-
Invocation invocation = new Invocation(referenceConfig, operationMeta, invocationRuntimeType, arguments);
144+
Invocation invocation = new Invocation(referenceConfig, operationMeta, invocationRuntimeType, null);
153145

154146
invocation.addLocalContext("k", 1);
155147
Assertions.assertSame(invocation.getHandlerContext(), invocation.getLocalContext());
@@ -158,7 +150,7 @@ public void localContext(@Mocked ReferenceConfig referenceConfig) {
158150

159151
@Test
160152
public void traceId_fromContext(@Mocked ReferenceConfig referenceConfig) {
161-
Invocation invocation = new Invocation(referenceConfig, operationMeta, invocationRuntimeType, arguments);
153+
Invocation invocation = new Invocation(referenceConfig, operationMeta, invocationRuntimeType, null);
162154
invocation.addContext(CoreConst.TRACE_ID_NAME, "abc");
163155

164156
invocation.onStart();
@@ -176,7 +168,7 @@ public void traceId_consumerCreateTraceId(@Mocked ReferenceConfig referenceConfi
176168
result = "abc";
177169
}
178170
};
179-
Invocation invocation = new Invocation(referenceConfig, operationMeta, invocationRuntimeType, arguments);
171+
Invocation invocation = new Invocation(referenceConfig, operationMeta, invocationRuntimeType, null);
180172

181173
invocation.onStart();
182174

@@ -192,7 +184,7 @@ public void traceId_fromRequest(@Mocked Endpoint endpoint, @Mocked HttpServletRe
192184
result = "abc";
193185
}
194186
};
195-
Invocation invocation = new Invocation(endpoint, operationMeta, arguments);
187+
Invocation invocation = new Invocation(endpoint, operationMeta, null);
196188

197189
invocation.onStart(requestEx);
198190

@@ -210,7 +202,7 @@ public void traceId_producerCreateTraceId(@Mocked Endpoint endpoint, @Mocked Htt
210202
result = "abc";
211203
}
212204
};
213-
Invocation invocation = new Invocation(endpoint, operationMeta, arguments);
205+
Invocation invocation = new Invocation(endpoint, operationMeta, null);
214206

215207
invocation.onStart(requestEx);
216208

@@ -254,7 +246,7 @@ public void onBusinessMethodStart(InvocationBusinessMethodStartEvent event) {
254246
}
255247
};
256248
EventManager.getEventBus().register(listener);
257-
Invocation invocation = new Invocation(endpoint, operationMeta, arguments);
249+
Invocation invocation = new Invocation(endpoint, operationMeta, null);
258250
mockNonaTime();
259251
invocation.onBusinessMethodStart();
260252
EventManager.getEventBus().unregister(listener);
@@ -269,12 +261,12 @@ public void onBusinessMethodStart(InvocationBusinessMethodStartEvent event) {
269261
public void marker(@Mocked ReferenceConfig referenceConfig) {
270262
Invocation.INVOCATION_ID.set(0);
271263

272-
Invocation invocation = new Invocation(referenceConfig, operationMeta, invocationRuntimeType, arguments);
264+
Invocation invocation = new Invocation(referenceConfig, operationMeta, invocationRuntimeType, null);
273265
invocation.addContext(CoreConst.TRACE_ID_NAME, "abc");
274266
invocation.onStart();
275267
Assertions.assertEquals("abc", invocation.getTraceIdLogger().getName());
276268

277-
invocation = new Invocation(referenceConfig, operationMeta, invocationRuntimeType, arguments);
269+
invocation = new Invocation(referenceConfig, operationMeta, invocationRuntimeType, null);
278270
invocation.addContext(CoreConst.TRACE_ID_NAME, "abc");
279271
invocation.onStart();
280272
Assertions.assertEquals("abc", invocation.getTraceIdLogger().getName());

0 commit comments

Comments
 (0)