@Test public void findJudgmentIds() { DateTime publicationDateFrom = new DateTime(2012, 04, 11, 12, 00); int pageNo = 2; int pageSize = 10; String responseMessage = "<id>111</id><id>222</id>"; String url = "http: Mockito.when(urlFactory.createSourceJudgmentsUrl(Mockito.eq(pageNo), Mockito.eq(pageSize), Mockito.eq(publicationDateFrom))).thenReturn(url); mockServerSuccessResponse(url, responseMessage, MediaType.APPLICATION_XML); List<String> result = Lists.newArrayList("111", "222"); Mockito.when(xmlTagContentExtractor.extractTagContents(Mockito.anyString(), Mockito.eq("id"))).thenReturn(result); List<String> realResult = sourceCcjExternalRepository.findJudgmentIds(pageNo, pageSize, publicationDateFrom); Assert.assertEquals(result, realResult); mockServer.verify(); Mockito.verify(xmlTagContentExtractor).extractTagContents(Mockito.eq(responseMessage), Mockito.eq("id")); }
public List<String> findJudgmentIds(int pageNo, int pageSize, DateTime publicationDateFrom) { Preconditions.checkArgument(pageNo >= 0, "pageNo must be greater or equal to zero"); Preconditions.checkArgument(pageSize >= 1 && pageSize <= 5000, "pageSize must be between 1 and 5000"); String url = sourceCcJudgmentUrlFactory.createSourceJudgmentsUrl(pageNo, pageSize, publicationDateFrom); HttpHeaders headers = createHttpHeaders(MediaType.TEXT_XML); ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<String>(headers), String.class); validateJudgmentIdsResponse(response); return xmlTagContentExtractor.extractTagContents(response.getBody(), "id"); }
SourceCcjExternalRepository { public List<String> findJudgmentIds(int pageNo, int pageSize, DateTime publicationDateFrom) { Preconditions.checkArgument(pageNo >= 0, "pageNo must be greater or equal to zero"); Preconditions.checkArgument(pageSize >= 1 && pageSize <= 5000, "pageSize must be between 1 and 5000"); String url = sourceCcJudgmentUrlFactory.createSourceJudgmentsUrl(pageNo, pageSize, publicationDateFrom); HttpHeaders headers = createHttpHeaders(MediaType.TEXT_XML); ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<String>(headers), String.class); validateJudgmentIdsResponse(response); return xmlTagContentExtractor.extractTagContents(response.getBody(), "id"); } }
SourceCcjExternalRepository { public List<String> findJudgmentIds(int pageNo, int pageSize, DateTime publicationDateFrom) { Preconditions.checkArgument(pageNo >= 0, "pageNo must be greater or equal to zero"); Preconditions.checkArgument(pageSize >= 1 && pageSize <= 5000, "pageSize must be between 1 and 5000"); String url = sourceCcJudgmentUrlFactory.createSourceJudgmentsUrl(pageNo, pageSize, publicationDateFrom); HttpHeaders headers = createHttpHeaders(MediaType.TEXT_XML); ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<String>(headers), String.class); validateJudgmentIdsResponse(response); return xmlTagContentExtractor.extractTagContents(response.getBody(), "id"); }  }
SourceCcjExternalRepository { public List<String> findJudgmentIds(int pageNo, int pageSize, DateTime publicationDateFrom) { Preconditions.checkArgument(pageNo >= 0, "pageNo must be greater or equal to zero"); Preconditions.checkArgument(pageSize >= 1 && pageSize <= 5000, "pageSize must be between 1 and 5000"); String url = sourceCcJudgmentUrlFactory.createSourceJudgmentsUrl(pageNo, pageSize, publicationDateFrom); HttpHeaders headers = createHttpHeaders(MediaType.TEXT_XML); ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<String>(headers), String.class); validateJudgmentIdsResponse(response); return xmlTagContentExtractor.extractTagContents(response.getBody(), "id"); }  List<String> findJudgmentIds(int pageNo, int pageSize, DateTime publicationDateFrom); SourceCcJudgmentTextData findJudgment(String judgmentId); @Autowired void setXmlTagContentExtractor(XmlTagContentExtractor xmlTagContentExtractor); @Autowired void setRestTemplate(RestTemplate restTemplate); @Autowired void setSourceCcJudgmentUrlFactory(SourceCcJudgmentUrlFactory sourceCcJudgmentUrlFactory); }
SourceCcjExternalRepository { public List<String> findJudgmentIds(int pageNo, int pageSize, DateTime publicationDateFrom) { Preconditions.checkArgument(pageNo >= 0, "pageNo must be greater or equal to zero"); Preconditions.checkArgument(pageSize >= 1 && pageSize <= 5000, "pageSize must be between 1 and 5000"); String url = sourceCcJudgmentUrlFactory.createSourceJudgmentsUrl(pageNo, pageSize, publicationDateFrom); HttpHeaders headers = createHttpHeaders(MediaType.TEXT_XML); ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<String>(headers), String.class); validateJudgmentIdsResponse(response); return xmlTagContentExtractor.extractTagContents(response.getBody(), "id"); }  List<String> findJudgmentIds(int pageNo, int pageSize, DateTime publicationDateFrom); SourceCcJudgmentTextData findJudgment(String judgmentId); @Autowired void setXmlTagContentExtractor(XmlTagContentExtractor xmlTagContentExtractor); @Autowired void setRestTemplate(RestTemplate restTemplate); @Autowired void setSourceCcJudgmentUrlFactory(SourceCcJudgmentUrlFactory sourceCcJudgmentUrlFactory);  }