@Test public void testGet() throws WxErrorException { String apiResultJson = "{\"errcode\": 0,\"errmsg\": \"ok\",\"userlist\": [{\"userid\": \"0124035\",\"name\": \"王五\"},{\"userid\": \"0114035\",\"name\": \"梦雪\"}],\"partylist\": [9576,9567,9566],\"tagname\": \"测试标签-001\"}"; WxCpService wxService = mock(WxCpService.class); when(wxService.get("https: when(wxService.getTagService()).thenReturn(new WxCpTagServiceImpl(wxService)); WxCpTagService wxCpTagService = wxService.getTagService(); WxCpTagGetResult wxCpTagGetResult = wxCpTagService.get(String.valueOf(150)); assertEquals(0, wxCpTagGetResult.getErrcode().intValue()); assertEquals(2, wxCpTagGetResult.getUserlist().size()); assertEquals(3, wxCpTagGetResult.getPartylist().size()); assertEquals("测试标签-001", wxCpTagGetResult.getTagname()); }
@Override public WxCpTagGetResult get(String tagId) throws WxErrorException { String url = "https: if (tagId != null) { url += "?tagId=" + tagId; } else { throw new IllegalArgumentException("缺少tagId参数"); } String responseContent = this.mainService.get(url, null); return WxCpTagGetResult.fromJson(responseContent); }
WxCpTagServiceImpl implements WxCpTagService { @Override public WxCpTagGetResult get(String tagId) throws WxErrorException { String url = "https: if (tagId != null) { url += "?tagId=" + tagId; } else { throw new IllegalArgumentException("缺少tagId参数"); } String responseContent = this.mainService.get(url, null); return WxCpTagGetResult.fromJson(responseContent); } }
WxCpTagServiceImpl implements WxCpTagService { @Override public WxCpTagGetResult get(String tagId) throws WxErrorException { String url = "https: if (tagId != null) { url += "?tagId=" + tagId; } else { throw new IllegalArgumentException("缺少tagId参数"); } String responseContent = this.mainService.get(url, null); return WxCpTagGetResult.fromJson(responseContent); } WxCpTagServiceImpl(WxCpService mainService); }
WxCpTagServiceImpl implements WxCpTagService { @Override public WxCpTagGetResult get(String tagId) throws WxErrorException { String url = "https: if (tagId != null) { url += "?tagId=" + tagId; } else { throw new IllegalArgumentException("缺少tagId参数"); } String responseContent = this.mainService.get(url, null); return WxCpTagGetResult.fromJson(responseContent); } WxCpTagServiceImpl(WxCpService mainService); @Override String create(String tagName); @Override void update(String tagId, String tagName); @Override void delete(String tagId); @Override List<WxCpTag> listAll(); @Override List<WxCpUser> listUsersByTagId(String tagId); @Override WxCpTagAddOrRemoveUsersResult addUsers2Tag(String tagId, List<String> userIds, List<String> partyIds); @Override WxCpTagAddOrRemoveUsersResult removeUsersFromTag(String tagId, List<String> userIds, List<String> partyIds); @Override WxCpTagGetResult get(String tagId); }
WxCpTagServiceImpl implements WxCpTagService { @Override public WxCpTagGetResult get(String tagId) throws WxErrorException { String url = "https: if (tagId != null) { url += "?tagId=" + tagId; } else { throw new IllegalArgumentException("缺少tagId参数"); } String responseContent = this.mainService.get(url, null); return WxCpTagGetResult.fromJson(responseContent); } WxCpTagServiceImpl(WxCpService mainService); @Override String create(String tagName); @Override void update(String tagId, String tagName); @Override void delete(String tagId); @Override List<WxCpTag> listAll(); @Override List<WxCpUser> listUsersByTagId(String tagId); @Override WxCpTagAddOrRemoveUsersResult addUsers2Tag(String tagId, List<String> userIds, List<String> partyIds); @Override WxCpTagAddOrRemoveUsersResult removeUsersFromTag(String tagId, List<String> userIds, List<String> partyIds); @Override WxCpTagGetResult get(String tagId);  }