[ISSUE Fix gson toJson is null question
@@ -51,27 +51,23 @@ public final class RegisterUtilsTest {
@Before
public void setUp() {
okHttpTools = mock(OkHttpTools.class);
- Map<String, Object> jsonMap = new HashMap<String, Object>() {
- {
- put("appName", "dubbo");
- put("contextPath", "/dubbo");
- put("path", "/dubbo/findByArrayIdsAndName");
- put("pathDesc", "");
- put("serviceName", "org.apache.shenyu.examples.dubbo.api.service.DubboMultiParamService");
- put("ruleName", "/dubbo/findByArrayIdsAndName");
- put("parameterTypes", "[Ljava.lang.Integer;,java.lang.String");
- put("rpcExt", "{\"group\":\"\",\"version\":\"\",\"loadbalance\":\"random\",\"retries\":2,\"timeout\":10000,\"url\":\"\"}");
- put("enabled", true);
- }
- };
-
+ Map<String, Object> jsonMap = new HashMap<>();
+ jsonMap.put("appName", "dubbo");
+ jsonMap.put("contextPath", "/dubbo");
+ jsonMap.put("path", "/dubbo/findByArrayIdsAndName");
+ jsonMap.put("pathDesc", "");
+ jsonMap.put("serviceName", "org.apache.shenyu.examples.dubbo.api.service.DubboMultiParamService");
+ jsonMap.put("ruleName", "/dubbo/findByArrayIdsAndName");
+ jsonMap.put("parameterTypes", "[Ljava.lang.Integer;,java.lang.String");
+ jsonMap.put("rpcExt", "{\"group\":\"\",\"version\":\"\",\"loadbalance\":\"random\",\"retries\":2,\"timeout\":10000,\"url\":\"\"}");
+ jsonMap.put("enabled", true);
json = gson.toJson(jsonMap);
url = "http://localhost:9095/shenyu-client/dubbo-register";
}
@Test
public void testDoRegisterWhenSuccess() throws IOException {
- when(okHttpTools.post(url, json)).thenReturn("SUCCESS");
+ when(okHttpTools.post(url, json)).thenReturn("success");
try (MockedStatic<OkHttpTools> okHttpToolsMockedStatic = mockStatic(OkHttpTools.class)) {
okHttpToolsMockedStatic.when(OkHttpTools::getInstance).thenReturn(okHttpTools);
