Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sdhzwc committed Nov 4, 2024
1 parent 6c513dc commit 78910f6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public String getMsg() {
}

public static Map<String, String> getAllMsg(AlertInputTips alertInputTips) {
HashMap<String, String> allMsgMap = new HashMap<>(16);
Map<String, String> allMsgMap = new HashMap<>();
allMsgMap.put("zhMsg", alertInputTips.zhMsg);
allMsgMap.put("enMsg", alertInputTips.enMsg);
return allMsgMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.impl.UiPluginServiceImpl;
import org.apache.dolphinscheduler.common.enums.PluginType;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.dao.entity.PluginDefine;
import org.apache.dolphinscheduler.dao.mapper.PluginDefineMapper;

Expand All @@ -35,6 +36,8 @@
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;

import com.fasterxml.jackson.databind.node.ArrayNode;

/**
* ui plugin service test
*/
Expand All @@ -51,7 +54,8 @@ public class UiPluginServiceTest {

@BeforeEach
public void before() {
String pluginParams = "[{\"field\":\"receivers\",\"props\":null,\"type\"}]";
String pluginParams =
"[{\"field\":\"receivers\",\"props\":{\"placeholder\":\"{\\\"zhMsg\\\": \\\"请输入收件人\\\",\\\"enMsg\\\": \\\"pleaseinputreceivers\\\"}\"},\"type\":\"input\"}]";
pluginDefine = new PluginDefine("email-alert", "alert", pluginParams);
}

Expand Down Expand Up @@ -82,6 +86,12 @@ public void testQueryPluginDetailById() {
Mockito.when(pluginDefineMapper.queryDetailById(1)).thenReturn(pluginDefine);
result = uiPluginService.queryUiPluginDetailById(1);
Assertions.assertEquals(Status.SUCCESS, result.get("status"));

PluginDefine data = (PluginDefine) result.get("data");
String pluginParams = data.getPluginParams();
ArrayNode arrayNode = JSONUtils.parseArray(pluginParams);
String placeholder = arrayNode.path(0).path("props").path("placeholder").asText();
Assertions.assertEquals(2, JSONUtils.toMap(placeholder).size());
}

}

0 comments on commit 78910f6

Please sign in to comment.