@Test public void testGet() throws Exception { String returnJson = "{\"errcode\": 0,\"errmsg\": \"ok\",\"agentid\": 9,\"name\": \"测试应用\",\"square_logo_url\": \"http: when(wxService.get("https: when(wxService.getAgentService()).thenReturn(new WxCpAgentServiceImpl(wxService)); WxCpAgentService wxAgentService = this.wxService.getAgentService(); WxCpAgent wxCpAgent = wxAgentService.get(9); Assert.assertEquals(9, wxCpAgent.getAgentid().intValue()); Assert.assertEquals(new Integer[]{42762742}, wxCpAgent.getAllowPartys().getPartyids().toArray()); Assert.assertEquals(new Integer[]{23, 22, 35, 19, 32, 125, 133, 46, 150, 38, 183, 9, 7}, wxCpAgent.getAllowTags().getTagids().toArray()); }
@Override public WxCpAgent get(Integer agentId) throws WxErrorException { String url = "https: if (agentId != null) { url += "?agentid=" + agentId; } else { throw new IllegalArgumentException("缺少agentid参数"); } String responseContent = this.mainService.get(url, null); return WxCpAgent.fromJson(responseContent); }
WxCpAgentServiceImpl implements WxCpAgentService { @Override public WxCpAgent get(Integer agentId) throws WxErrorException { String url = "https: if (agentId != null) { url += "?agentid=" + agentId; } else { throw new IllegalArgumentException("缺少agentid参数"); } String responseContent = this.mainService.get(url, null); return WxCpAgent.fromJson(responseContent); } }
WxCpAgentServiceImpl implements WxCpAgentService { @Override public WxCpAgent get(Integer agentId) throws WxErrorException { String url = "https: if (agentId != null) { url += "?agentid=" + agentId; } else { throw new IllegalArgumentException("缺少agentid参数"); } String responseContent = this.mainService.get(url, null); return WxCpAgent.fromJson(responseContent); } WxCpAgentServiceImpl(WxCpService mainService); }
WxCpAgentServiceImpl implements WxCpAgentService { @Override public WxCpAgent get(Integer agentId) throws WxErrorException { String url = "https: if (agentId != null) { url += "?agentid=" + agentId; } else { throw new IllegalArgumentException("缺少agentid参数"); } String responseContent = this.mainService.get(url, null); return WxCpAgent.fromJson(responseContent); } WxCpAgentServiceImpl(WxCpService mainService); @Override WxCpAgent get(Integer agentId); }
WxCpAgentServiceImpl implements WxCpAgentService { @Override public WxCpAgent get(Integer agentId) throws WxErrorException { String url = "https: if (agentId != null) { url += "?agentid=" + agentId; } else { throw new IllegalArgumentException("缺少agentid参数"); } String responseContent = this.mainService.get(url, null); return WxCpAgent.fromJson(responseContent); } WxCpAgentServiceImpl(WxCpService mainService); @Override WxCpAgent get(Integer agentId);  }