added search response into searchmodal ui, restructured folders
This commit is contained in:
@@ -64,10 +64,11 @@ public class HomeboxSearchProvider implements SearchProvider {
|
||||
}
|
||||
|
||||
List<SearchResponse> items = hbResponse.items().stream().map(i -> {
|
||||
String id = i.id();
|
||||
String title = i.name();
|
||||
String description = i.description();
|
||||
Map<String, Object> extraSearchResponseData = Map.of("location", i.parent());
|
||||
return new SearchResponse(title, description, extraSearchResponseData);
|
||||
return new SearchResponse(id, title, description, extraSearchResponseData);
|
||||
}).toList();
|
||||
|
||||
log.info("Search results for query '{}': {}", request.query(), items);
|
||||
@@ -79,7 +80,7 @@ public class HomeboxSearchProvider implements SearchProvider {
|
||||
List<HomeboxItem> items) {
|
||||
}
|
||||
|
||||
private record HomeboxItem(String name, String description, HomeboxLocation parent) {
|
||||
private record HomeboxItem(String id, String name, String description, HomeboxLocation parent) {
|
||||
}
|
||||
|
||||
private record HomeboxLocation(String name, String description) {
|
||||
|
||||
@@ -2,7 +2,8 @@ package com.vaessl.app.search;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public record SearchResponse(String title, String description, Map<String, Object> extraData) {
|
||||
public record SearchResponse(String id, String title, String description,
|
||||
Map<String, Object> extraData) {
|
||||
|
||||
public String getExtra(String key) {
|
||||
if (extraData == null) {
|
||||
|
||||
@@ -8,6 +8,7 @@ public final class Mockdata {
|
||||
public static final String MOCK_SERVICE_TYPE = "SERVICE_TYPE";
|
||||
public static final String MOCK_USER = "user";
|
||||
public static final String MOCK_PASS = "pw";
|
||||
public static final String MOCK_ID = "item-1";
|
||||
public static final String MOCK_TITLE = "title";
|
||||
public static final String MOCK_DESCRIPTION = "desc";
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ class SearchResponseTest {
|
||||
|
||||
@Test
|
||||
void shouldReturnNullWhenExtraDataIsNull() {
|
||||
SearchResponse response = new SearchResponse(MOCK_TITLE, MOCK_DESCRIPTION, null);
|
||||
SearchResponse response = new SearchResponse(MOCK_ID, MOCK_TITLE, MOCK_DESCRIPTION, null);
|
||||
|
||||
assertThat(response.getExtra(null)).isNull();
|
||||
}
|
||||
@@ -17,7 +17,7 @@ class SearchResponseTest {
|
||||
@Test
|
||||
void shouldReturnNullWhenExtraDataKeyIsMissing() {
|
||||
|
||||
SearchResponse response = new SearchResponse(MOCK_TITLE, MOCK_DESCRIPTION, Map.of("key", "value"));
|
||||
SearchResponse response = new SearchResponse(MOCK_ID, MOCK_TITLE, MOCK_DESCRIPTION, Map.of("key", "value"));
|
||||
|
||||
assertThat(response.getExtra("missing")).isNull();
|
||||
}
|
||||
@@ -25,8 +25,9 @@ class SearchResponseTest {
|
||||
@Test
|
||||
void shouldReturnExtraDataValue() {
|
||||
|
||||
SearchResponse response = new SearchResponse(MOCK_TITLE, MOCK_DESCRIPTION, Map.of("key", "value"));
|
||||
SearchResponse response = new SearchResponse(MOCK_ID, MOCK_TITLE, MOCK_DESCRIPTION, Map.of("key", "value"));
|
||||
|
||||
assertThat(response.id()).isEqualTo(MOCK_ID);
|
||||
assertThat(response.getExtra("key")).contains("value");
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user