@Test(expected = PatentServiceException.class) public void testGetPatentMetadataForHttp500() throws Exception { ImportedPatent.Builder patentBuilder = initializeWithDummyValues(); OpenPatentWebServiceFacade service = prepareValidService(); CloseableHttpResponse authnHttpResponse = mock(CloseableHttpResponse.class); StatusLine authnStatusLine = mock(StatusLine.class); HttpEntity authnHttpEntity = mock(HttpEntity.class); String accessToken = "someAccessToken"; when(authnHttpResponse.getStatusLine()).thenReturn(authnStatusLine); when(authnStatusLine.getStatusCode()).thenReturn(200); when(authnHttpResponse.getEntity()).thenReturn(authnHttpEntity); Gson gson = new Gson(); String pageContents = gson.toJson(new AuthenticationResponse(accessToken)); InputStream pageInputStream = new ByteArrayInputStream(pageContents.getBytes()); when(authnHttpEntity.getContent()).thenReturn(pageInputStream); CloseableHttpResponse getPatentHttpResponse = mock(CloseableHttpResponse.class); StatusLine getPatentStatusLine = mock(StatusLine.class); HttpEntity getPatentHttpEntity = mock(HttpEntity.class); when(getPatentHttpResponse.getStatusLine()).thenReturn(getPatentStatusLine); when(getPatentStatusLine.getStatusCode()).thenReturn(500); when(getPatentHttpResponse.getEntity()).thenReturn(getPatentHttpEntity); when(httpClient.execute(any(HttpHost.class),any(HttpGet.class))).thenReturn(authnHttpResponse, getPatentHttpResponse); service.getPatentMetadata(patentBuilder.build()); }
@Override public String getPatentMetadata(ImportedPatent patent) throws Exception { return getPatentMetadata(patent, getSecurityToken(), 0); }
OpenPatentWebServiceFacade implements PatentServiceFacade { @Override public String getPatentMetadata(ImportedPatent patent) throws Exception { return getPatentMetadata(patent, getSecurityToken(), 0); } }
OpenPatentWebServiceFacade implements PatentServiceFacade { @Override public String getPatentMetadata(ImportedPatent patent) throws Exception { return getPatentMetadata(patent, getSecurityToken(), 0); } OpenPatentWebServiceFacade(ConnectionDetails connDetails); protected  OpenPatentWebServiceFacade(CloseableHttpClient httpClient, HttpHost authHost, String authUriRoot, HttpHost opsHost,
            String opsUriRoot, String consumerCredential, long throttleSleepTime, int maxRetriesCount,
            JsonParser jsonParser); }
OpenPatentWebServiceFacade implements PatentServiceFacade { @Override public String getPatentMetadata(ImportedPatent patent) throws Exception { return getPatentMetadata(patent, getSecurityToken(), 0); } OpenPatentWebServiceFacade(ConnectionDetails connDetails); protected  OpenPatentWebServiceFacade(CloseableHttpClient httpClient, HttpHost authHost, String authUriRoot, HttpHost opsHost,
            String opsUriRoot, String consumerCredential, long throttleSleepTime, int maxRetriesCount,
            JsonParser jsonParser); @Override String getPatentMetadata(ImportedPatent patent); }
OpenPatentWebServiceFacade implements PatentServiceFacade { @Override public String getPatentMetadata(ImportedPatent patent) throws Exception { return getPatentMetadata(patent, getSecurityToken(), 0); } OpenPatentWebServiceFacade(ConnectionDetails connDetails); protected  OpenPatentWebServiceFacade(CloseableHttpClient httpClient, HttpHost authHost, String authUriRoot, HttpHost opsHost,
            String opsUriRoot, String consumerCredential, long throttleSleepTime, int maxRetriesCount,
            JsonParser jsonParser); @Override String getPatentMetadata(ImportedPatent patent);  }