55import static org .folio .dataexp .util .Constants .DATE_PATTERN ;
66import static org .junit .jupiter .api .Assertions .assertThrows ;
77import static org .mockito .ArgumentMatchers .isA ;
8+ import static org .mockito .Mockito .never ;
89import static org .mockito .Mockito .verify ;
910import static org .mockito .Mockito .when ;
1011
@@ -67,6 +68,7 @@ void shouldReturnOneRecord() {
6768 .thenReturn (fileDefinition );
6869 when (fileDefinitionsService .uploadFile (isA (UUID .class ), isA (Resource .class )))
6970 .thenReturn (fileDefinition );
71+ when (consortiaService .getCentralTenantId (null )).thenReturn ("central" );
7072 when (consortiaService .isCurrentTenantCentralTenant (null )).thenReturn (true );
7173
7274 var res = marcDeletedIdsService .getFileDefinitionForMarcDeletedIds (null , null );
@@ -86,6 +88,7 @@ void shouldHavePayloadWithDateRangeIfDateRangeIsUsed() {
8688 .thenReturn (fileDefinition );
8789 when (fileDefinitionsService .uploadFile (isA (UUID .class ), isA (Resource .class )))
8890 .thenReturn (fileDefinition );
91+ when (consortiaService .getCentralTenantId (null )).thenReturn ("central" );
8992 when (consortiaService .isCurrentTenantCentralTenant (null )).thenReturn (true );
9093
9194 var date = new SimpleDateFormat (DATE_PATTERN );
@@ -111,6 +114,7 @@ void shouldHavePayloadWithFromDateIfDateFromIsUsed() {
111114 .thenReturn (fileDefinition );
112115 when (fileDefinitionsService .uploadFile (isA (UUID .class ), isA (Resource .class )))
113116 .thenReturn (fileDefinition );
117+ when (consortiaService .getCentralTenantId (null )).thenReturn ("central" );
114118 when (consortiaService .isCurrentTenantCentralTenant (null )).thenReturn (true );
115119
116120 var date = new SimpleDateFormat (DATE_PATTERN );
@@ -135,6 +139,7 @@ void shouldHavePayloadWithToDateIfDateToIsUsed() {
135139 .thenReturn (fileDefinition );
136140 when (fileDefinitionsService .uploadFile (isA (UUID .class ), isA (Resource .class )))
137141 .thenReturn (fileDefinition );
142+ when (consortiaService .getCentralTenantId (null )).thenReturn ("central" );
138143 when (consortiaService .isCurrentTenantCentralTenant (null )).thenReturn (true );
139144
140145 var date = new SimpleDateFormat (DATE_PATTERN );
@@ -158,6 +163,7 @@ void shouldHavePayloadWithPreviousDayIfDateIsNotUsed() {
158163 .thenReturn (fileDefinition );
159164 when (fileDefinitionsService .uploadFile (isA (UUID .class ), isA (Resource .class )))
160165 .thenReturn (fileDefinition );
166+ when (consortiaService .getCentralTenantId (null )).thenReturn ("central" );
161167 when (consortiaService .isCurrentTenantCentralTenant (null )).thenReturn (true );
162168
163169 marcDeletedIdsService .getFileDefinitionForMarcDeletedIds (null , null );
@@ -205,4 +211,26 @@ void shouldExcludeSharedNonDeletedIds() {
205211 verify (fileDefinitionsService ).uploadFile (isA (UUID .class ), resourceArgumentCaptor .capture ());
206212 assertThat (id1 ).isEqualTo (resourceArgumentCaptor .getValue ().getContentAsString (UTF_8 ));
207213 }
214+
215+ @ Test
216+ @ SneakyThrows
217+ void shouldNotCheckCentralTenantWhenNonEcs () {
218+ var id1 = UUID .randomUUID ().toString ();
219+ var id2 = UUID .randomUUID ().toString ();
220+ when (sourceStorageClient .getMarcRecordsIdentifiers (isA (MarcRecordIdentifiersPayload .class )))
221+ .thenReturn (
222+ new MarcRecordsIdentifiersResponse ().withRecords (List .of (id1 , id2 )).withTotalCount (2 ));
223+ when (folioExecutionContext .getTenantId ()).thenReturn ("member" );
224+ when (consortiaService .getCentralTenantId ("member" )).thenReturn ("" );
225+ var fileDefinition = new FileDefinition ().id (UUID .randomUUID ());
226+ when (fileDefinitionsService .postFileDefinition (isA (FileDefinition .class )))
227+ .thenReturn (fileDefinition );
228+
229+ marcDeletedIdsService .getFileDefinitionForMarcDeletedIds (null , null );
230+
231+ verify (consortiaService , never ()).isCurrentTenantCentralTenant ("member" );
232+ verify (fileDefinitionsService ).uploadFile (isA (UUID .class ), resourceArgumentCaptor .capture ());
233+ assertThat (resourceArgumentCaptor .getValue ().getContentAsString (UTF_8 ))
234+ .isEqualTo (String .join (System .lineSeparator (), List .of (id1 , id2 )));
235+ }
208236}
0 commit comments