【发布时间】:2020-02-21 16:30:45
【问题描述】:
我需要将 String 转换为 List<Map<String, String>>> 以通过 JUnit 测试。我有这个:
String userAttributes = "[{name=test, cp=458999, lastname=test2}]";
我想要的是在测试 (Mockito) 中更改对具有此值的服务器的调用,如下所示:
Mockito.when(template.search(Mockito.anyString, new AttributesMapper()).thenReturn(attributes);
我需要 List<Map<String, String>>> 来执行此操作:
user.setUserName(attributes.get("name"));
【问题讨论】:
-
提供答案而不是编辑您的问题以添加解决方案部分。
-
你能说如果给定的答案解决了你的问题,或者说他们有什么问题吗?对答案作出回应有助于将来准确回答。
标签: java spring-boot junit mockito