Skip to content

Commit

Permalink
fix(mod-search): fix export of cql files
Browse files Browse the repository at this point in the history
- Add test to tests coverage

Closes: MSEARCH-762
  • Loading branch information
viacheslavpoliakov committed Jun 11, 2024
1 parent 4084ded commit c2d2721
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/test/java/org/folio/search/service/ResourceIdServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static org.folio.search.utils.TestUtils.OBJECT_MAPPER;
import static org.folio.search.utils.TestUtils.randomId;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doThrow;
Expand Down Expand Up @@ -164,6 +165,25 @@ void streamResourceIds_positive_emptyCollectionProvided() throws IOException {
assertThat(actual).isEqualTo(new ResourceIds().ids(emptyList()).totalRecords(0));
}

@Test
void streamResourceIds_positive_NotSharedActiveAffiliation() throws IOException {
String query = "shared==\"false\"";
CqlResourceIdsRequest request = CqlResourceIdsRequest.of(RESOURCE_NAME, TENANT_ID, query, INSTANCE_ID_PATH);
var expectedSearchSource = searchSource().size(QUERY_SIZE).sort("_doc");
doAnswer(invocation -> {
invocation.<Consumer<List<String>>>getArgument(2).accept(emptyList());
return null;
}).when(searchRepository).streamResourceIds(eq(request), eq(expectedSearchSource), any());
when(queryConverter.convertNotSharedActiveAffiliation(query, RESOURCE_NAME, TENANT_ID)).thenReturn(searchSource());
when(properties.getScrollQuerySize()).thenReturn(QUERY_SIZE);

var outputStream = new ByteArrayOutputStream();
resourceIdService.streamResourceIdsAsJson(request, outputStream);

var actual = objectMapper.readValue(outputStream.toByteArray(), ResourceIds.class);
assertThat(actual).isEqualTo(new ResourceIds().ids(emptyList()).totalRecords(0));
}

@Test
void streamResourceIdsInTextTextType_positive_emptyCollectionProvided() {
mockSearchRepositoryCall(emptyList());
Expand Down

0 comments on commit c2d2721

Please sign in to comment.