HomeboxSearchProvider used to own the RestClient call and item mapping directly; pulling it into a shared HomeboxItemClient lets the upcoming sync pipeline page through the same Homebox items without duplicating the fetch/mapping logic. ConnectionIdentifiable lets both SearchRequest and SyncRequest be resolved to a connection by the same client.
39 lines
1.2 KiB
Java
39 lines
1.2 KiB
Java
package com.vaessl.app.search;
|
|
|
|
import static com.vaessl.app.Mockdata.*;
|
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
import static org.mockito.Mockito.when;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.junit.jupiter.api.extension.ExtendWith;
|
|
import org.mockito.InjectMocks;
|
|
import org.mockito.Mock;
|
|
import org.mockito.junit.jupiter.MockitoExtension;
|
|
import org.springframework.data.domain.PageRequest;
|
|
import org.springframework.data.domain.Pageable;
|
|
import com.vaessl.app.exception.ConnectionNotFoundException;
|
|
import com.vaessl.app.homebox.HomeboxItemClient;
|
|
import static com.vaessl.app.shared.ServiceType.HOMEBOX;
|
|
|
|
|
|
@ExtendWith(MockitoExtension.class)
|
|
class HomeboxSearchProviderTest {
|
|
|
|
@Mock
|
|
private HomeboxItemClient client;
|
|
|
|
@InjectMocks
|
|
private HomeboxSearchProvider provider;
|
|
|
|
@Test
|
|
void shouldReturnConnectionNotFoundException() {
|
|
|
|
Pageable pageable = PageRequest.of(0, 10);
|
|
SearchRequest request = new SearchRequest(MOCK_URL, MOCK_USER, "", HOMEBOX, false);
|
|
|
|
when(client.hbResponse(request, "", pageable)).thenThrow(new ConnectionNotFoundException());
|
|
|
|
assertThrows(ConnectionNotFoundException.class,
|
|
() -> provider.getSearchResults(request, pageable));
|
|
}
|
|
}
|