### Question:
SourceCcjExternalRepository { public SourceCcJudgmentTextData findJudgment(String judgmentId) { SourceCcJudgmentTextData sourceCcJudgmentTextData = new SourceCcJudgmentTextData(); sourceCcJudgmentTextData.setMetadata(findJudgmentDetails(judgmentId)); sourceCcJudgmentTextData.setMetadataSourceUrl(sourceCcJudgmentUrlFactory.createSourceJudgmentDetailsUrl(judgmentId)); sourceCcJudgmentTextData.setContent(findJudgmentContent(judgmentId)); sourceCcJudgmentTextData.setContentSourceUrl(sourceCcJudgmentUrlFactory.createSourceJudgmentContentUrl(judgmentId)); return sourceCcJudgmentTextData; }  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);  }### Answer:
@Test public void findJudgment() { String judgmentId = "XXX-111223"; String responseMetadata = "<id>111</id><id>222</id>"; String responseContent = "W imieniu Rzeczypospolitej..."; String metadataUrl = "http: String contentUrl = "http: Mockito.when(urlFactory.createSourceJudgmentDetailsUrl(Mockito.eq(judgmentId))).thenReturn(metadataUrl); Mockito.when(urlFactory.createSourceJudgmentContentUrl(Mockito.eq(judgmentId))).thenReturn(contentUrl); mockServerSuccessResponse(metadataUrl, responseMetadata, MediaType.TEXT_XML); mockServerSuccessResponse(contentUrl, responseContent, MediaType.TEXT_XML); SourceCcJudgmentTextData ccJudgmentTextData = sourceCcjExternalRepository.findJudgment(judgmentId); assertEquals(responseMetadata, ccJudgmentTextData.getMetadata()); assertEquals(responseContent, ccJudgmentTextData.getContent()); assertEquals(metadataUrl, ccJudgmentTextData.getMetadataSourceUrl()); assertEquals(contentUrl, ccJudgmentTextData.getContentSourceUrl()); mockServer.verify(); }
@Test public void findJudgment_metadataError() { String judgmentId = "4214"; String errorResponseMetadata = "<?xml version=\"1.0\"?><error>Judgement with specified id (152500000000503_I_ACa_001011_2013_Uz_2014-02-05_0012) not found.</error>"; String metadataUrl = "http: Mockito.when(urlFactory.createSourceJudgmentDetailsUrl(Mockito.eq(judgmentId))).thenReturn(metadataUrl); mockServerSuccessResponse(metadataUrl, errorResponseMetadata, MediaType.TEXT_HTML); CatchExceptionAssertJ.when(sourceCcjExternalRepository).findJudgment(judgmentId); CatchExceptionAssertJ.then(CatchException.caughtException()) .isExactlyInstanceOf(SourceCcJudgmentDownloadErrorException.class) .hasMessageContaining(errorResponseMetadata); }