test: add unit tests for HomeboxSearchProvider and SearchResponse
HomeboxSearchProviderTest verifies that ConnectionNotFoundException is thrown when no matching connection exists in the repository. SearchResponseTest covers the getExtra helper — null extra map, missing key, and a present key. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
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.connection.ConnectionRepository;
|
||||
import com.vaessl.app.exception.ConnectionNotFoundException;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class HomeboxSearchProviderTest {
|
||||
|
||||
@Mock
|
||||
private ConnectionRepository mockRepo;
|
||||
|
||||
@InjectMocks
|
||||
private HomeboxSearchProvider provider;
|
||||
|
||||
@Test
|
||||
void shouldReturnConnectionNotFoundException() {
|
||||
|
||||
when(mockRepo.findByAppUrlAndUsername(MOCK_URL, MOCK_USER)).thenReturn(null);
|
||||
|
||||
SearchRequest request = new SearchRequest(MOCK_URL, MOCK_USER, "test query", "HOMEBOX");
|
||||
Pageable pageable = PageRequest.of(0, 10);
|
||||
assertThrows(ConnectionNotFoundException.class,
|
||||
() -> provider.getSearchResults(request, pageable));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user