mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-02 20:02:37 +08:00
🐛 #1413 公众号模块优化行业设置接口枚举匹配代码,并增加单元测试
This commit is contained in:
parent
1dba5dba36
commit
4b13a04014
@ -28,7 +28,12 @@ public class WxMpIndustryGsonAdapter implements JsonSerializer<WxMpTemplateIndus
|
||||
}
|
||||
|
||||
private WxMpTemplateIndustryEnum convertFromJson(JsonObject json) {
|
||||
return WxMpTemplateIndustryEnum.findBySecondary(GsonHelper.getString(json, "second_class"));
|
||||
String secondClass = GsonHelper.getString(json, "second_class");
|
||||
if (secondClass.contains("|")) {
|
||||
secondClass = secondClass.split("\\|")[1];
|
||||
}
|
||||
|
||||
return WxMpTemplateIndustryEnum.findBySecondary(secondClass);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package me.chanjar.weixin.mp.bean.template;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
/**
|
||||
* 测试类.
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
* @date 2020-02-29
|
||||
*/
|
||||
public class WxMpTemplateIndustryTest {
|
||||
|
||||
@Test
|
||||
public void testFromJson() {
|
||||
String json="{\"primary_industry\":{\"first_class\":\"IT科技\",\"second_class\":\"IT软件与服务\"},\"secondary_industry\":{\"first_class\":\"房地产\",\"second_class\":\"房地产|建筑\"}}";
|
||||
final WxMpTemplateIndustry industry = WxMpTemplateIndustry.fromJson(json);
|
||||
assertThat(industry).isNotNull();
|
||||
System.out.println(industry);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user