Skip to content

Commit

Permalink
ALS-8239: Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ramari16 committed Jan 31, 2025
1 parent a25e4f9 commit 65fa296
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -139,7 +138,7 @@ void testQueryResult() throws Exception {
when(httpResponse.getStatusLine()).thenReturn(statusLine);
when(httpResponse.getEntity()).thenReturn(httpResponseEntity);
when(httpClient.retrievePostResponse(anyString(), any(Header[].class), anyString())).thenReturn(httpResponse);
when(httpClient.readObjectFromResponse(any(HttpResponse.class), StandardCharsets.ISO_8859_1)).thenReturn("4");
when(httpClient.readObjectFromResponse(any(HttpResponse.class), eq(StandardCharsets.UTF_8))).thenReturn("4");

assertThrows(ProtocolException.class, () -> {
resource.queryResult("", null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public void testQuery() throws JsonProcessingException {
@Test
public void testQueryResult() throws JsonProcessingException {
String testId = "230048";
String mockResult = "{}";
byte[] mockResult = new byte[] {};



Expand Down Expand Up @@ -341,8 +341,8 @@ public void testQueryResult() throws JsonProcessingException {
Response result = cut.queryResult(testURL, testId, queryRequest);
assertNotNull("Result should not be null", result);
// String resultContent = IOUtils.toString((InputStream) result.getEntity(), "UTF-8");
String resultContent = (String) result.getEntity();
assertEquals("Result should match " + mockResult, mockResult, resultContent);
byte[] resultContent = (byte[]) result.getEntity();
assertArrayEquals("Result should match " + mockResult, mockResult, resultContent);

// What if the resource has a problem?
wireMockRule.stubFor(any(urlMatching("/query/.*/result")).willReturn(aResponse().withStatus(500)));
Expand Down

0 comments on commit 65fa296

Please sign in to comment.