Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@
import lombok.Getter;

/**
* Search parameters for models.
* Search for models within the organization linked to the API key.
* All search filters are optional.
* If no search filters are given, all models belonging to the organization are returned.
* Results are paginated.
*/
@Getter
@EqualsAndHashCode(callSuper = true)
public class ModelSearchParameters extends BaseSearchParameters<ModelSearchResponse> {
/**
* Case-insensitive search term for the model name
* Filter models by partial name match, case-insensitive.
*/
private final String name;

/**
* Case-insensitive search term for the model type
* Filter by an exact model type.
*/
private final String modelType;

Expand Down Expand Up @@ -72,15 +75,15 @@ public static final class Builder extends BaseSearchParameters.BaseBuilder<Build
}

/**
* Case-insensitive search term for the model name
* Filter models by partial name match, case-insensitive.
*/
public Builder name(String name) {
this.name = name;
return this;
}

/**
* Case-insensitive search term for the model type
* Filter by an exact model type.
*/
public Builder modelType(String modelType) {
this.modelType = modelType;
Expand Down
11 changes: 8 additions & 3 deletions src/test/java/com/mindee/v2/search/ModelSearchIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,24 @@ void setUp() {
}

@Test
public void ModelSearch_mustHaveResults() throws Exception {
public void ModelSearch_mustHaveResults() {
ModelSearchResponse response = client.search(ModelSearchParameters.builder().build());

assertNotNull(response);
assertNotNull(response.getModels());
assertFalse(response.getModels().isEmpty());
for (var model : response.getModels()) {
assertFalse(model.getId().isBlank());
assertFalse(model.getName().isBlank());
assertFalse(model.getModelType().isBlank());
}
assertNotNull(response.getPagination());
assertTrue(response.getPagination().getTotalItems() > 1);
assertEquals(1, response.getPagination().getPage());
}

@Test
public void ModelSearch_mustReturnEmpty() throws Exception {
public void ModelSearch_mustReturnEmpty() {
ModelSearchResponse response = client
.search(ModelSearchParameters.builder().name("je n'existe pas tralala").build());

Expand All @@ -53,7 +58,7 @@ public void ModelSearch_mustReturnEmpty() throws Exception {

@Test
@SuppressWarnings("deprecation")
public void ModelSearch_mustReturnEmptyObsolete() throws Exception {
public void ModelSearch_mustReturnEmptyObsolete() {
SearchResponse response = client.searchModels("je n'existe pas tralala");

assertNotNull(response);
Expand Down
Loading