### Question:
Statistics implements Serializable { @Override public String toString() { return url.toString(); } Statistics(URL url); URL getUrl(); void setUrl(URL url); String getApplication(); Statistics setApplication(String application); String getService(); Statistics setService(String service); String getGroup(); void setGroup(String group); String getVersion(); void setVersion(String version); String getMethod(); Statistics setMethod(String method); String getClient(); Statistics setClient(String client); String getServer(); Statistics setServer(String server); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }### Answer:
@Test public void testToString() { Statistics statistics = new Statistics(new URL("dubbo", "10.20.153.10", 0)); statistics.setApplication("demo"); statistics.setMethod("findPerson"); statistics.setServer("10.20.153.10"); statistics.setGroup("unit-test"); statistics.setService("MemberService"); assertThat(statistics.toString(), is("dubbo: Statistics statisticsWithDetailInfo = new Statistics(new URL("dubbo", "10.20.153.10", 0) .addParameter(MonitorService.APPLICATION, "morgan") .addParameter(MonitorService.INTERFACE, "MemberService") .addParameter(MonitorService.METHOD, "findPerson") .addParameter(MonitorService.CONSUMER, "10.20.153.11") .addParameter(MonitorService.GROUP, "unit-test") .addParameter(MonitorService.SUCCESS, 1) .addParameter(MonitorService.FAILURE, 0) .addParameter(MonitorService.ELAPSED, 3) .addParameter(MonitorService.MAX_ELAPSED, 3) .addParameter(MonitorService.CONCURRENT, 1) .addParameter(MonitorService.MAX_CONCURRENT, 1)); MatcherAssert.assertThat(statisticsWithDetailInfo.getServer(), equalTo(statistics.getServer())); MatcherAssert.assertThat(statisticsWithDetailInfo.getService(), equalTo(statistics.getService())); MatcherAssert.assertThat(statisticsWithDetailInfo.getMethod(), equalTo(statistics.getMethod())); MatcherAssert.assertThat(statisticsWithDetailInfo.getGroup(), equalTo(statistics.getGroup())); MatcherAssert.assertThat(statisticsWithDetailInfo, not(equalTo(statistics))); }
@Test public void testToString() { Statistics statistics = new Statistics(new URL("dubbo", "10.20.153.10", 0)); statistics.setApplication("demo"); statistics.setMethod("findPerson"); statistics.setServer("10.20.153.10"); statistics.setGroup("unit-test"); statistics.setService("MemberService"); assertThat(statistics.toString(), is("dubbo: Statistics statisticsWithDetailInfo = new Statistics(new URLBuilder(Constants.DUBBO_PROTOCOL, "10.20.153.10", 0) .addParameter(MonitorService.APPLICATION, "morgan") .addParameter(MonitorService.INTERFACE, "MemberService") .addParameter(MonitorService.METHOD, "findPerson") .addParameter(MonitorService.CONSUMER, "10.20.153.11") .addParameter(MonitorService.GROUP, "unit-test") .addParameter(MonitorService.SUCCESS, 1) .addParameter(MonitorService.FAILURE, 0) .addParameter(MonitorService.ELAPSED, 3) .addParameter(MonitorService.MAX_ELAPSED, 3) .addParameter(MonitorService.CONCURRENT, 1) .addParameter(MonitorService.MAX_CONCURRENT, 1) .build()); MatcherAssert.assertThat(statisticsWithDetailInfo.getServer(), equalTo(statistics.getServer())); MatcherAssert.assertThat(statisticsWithDetailInfo.getService(), equalTo(statistics.getService())); MatcherAssert.assertThat(statisticsWithDetailInfo.getMethod(), equalTo(statistics.getMethod())); MatcherAssert.assertThat(statisticsWithDetailInfo.getGroup(), equalTo(statistics.getGroup())); MatcherAssert.assertThat(statisticsWithDetailInfo, not(equalTo(statistics))); }