Skip to content

Commit

Permalink
fix build: action and dirty_values import parameters (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
phiHero authored Oct 11, 2024
1 parent e4094b6 commit 733b5e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/typesense/api/Documents.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import org.typesense.model.DeleteDocumentsParameters;
import org.typesense.model.ExportDocumentsParameters;
import org.typesense.model.ImportDocumentsParameters;
import org.typesense.model.IndexAction;
import org.typesense.model.SearchParameters;
import org.typesense.model.SearchResult;
import org.typesense.model.UpdateDocumentsParameters;
import org.typesense.model.ImportDocumentsParameters.ActionEnum;

public class Documents {

Expand Down Expand Up @@ -43,7 +43,7 @@ public String create(Map<String, Object> document, ImportDocumentsParameters que

public Map<String, Object> upsert(Map<String, Object> document) throws Exception {
ImportDocumentsParameters queryParameters = new ImportDocumentsParameters();
queryParameters.action(ImportDocumentsParameters.ActionEnum.UPSERT);
queryParameters.action(IndexAction.UPSERT);

return this.apiCall.post(getEndPoint("/"), document, queryParameters, Map.class);
}
Expand Down
13 changes: 7 additions & 6 deletions src/test/java/org/typesense/api/DocumentsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
import org.typesense.api.exceptions.ObjectNotFound;
import org.typesense.model.CollectionSchema;
import org.typesense.model.DeleteDocumentsParameters;
import org.typesense.model.DirtyValues;
import org.typesense.model.ExportDocumentsParameters;
import org.typesense.model.Field;
import org.typesense.model.ImportDocumentsParameters;
import org.typesense.model.IndexAction;
import org.typesense.model.SearchParameters;
import org.typesense.model.SearchResult;
import org.typesense.model.UpdateDocumentsParameters;
import org.typesense.model.ImportDocumentsParameters.ActionEnum;

class DocumentsTest {

Expand Down Expand Up @@ -183,7 +184,7 @@ void testImport() throws Exception {

documentList.add(document1);
documentList.add(document2);
queryParameters.action(ImportDocumentsParameters.ActionEnum.CREATE);
queryParameters.action(IndexAction.CREATE);

String countriesImport = this.client.collections("books").documents()
.import_(documentList, queryParameters);
Expand All @@ -193,7 +194,7 @@ void testImport() throws Exception {
@Test
void testImportAsString() throws Exception {
ImportDocumentsParameters queryParameters = new ImportDocumentsParameters();
queryParameters.action(ImportDocumentsParameters.ActionEnum.CREATE);
queryParameters.action(IndexAction.CREATE);
String documentList = "{\"countryName\": \"India\", \"capital\": \"Washington\", \"gdp\": 5215}\n" +
"{\"countryName\": \"Iran\", \"capital\": \"London\", \"gdp\": 5215}";
String booksImport = this.client.collections("books").documents().import_(documentList,
Expand All @@ -216,8 +217,8 @@ void testDirtyCreate() throws Exception {
helper.createTestDocument();

ImportDocumentsParameters queryParameters = new ImportDocumentsParameters();
queryParameters.dirtyValues(ImportDocumentsParameters.DirtyValuesEnum.COERCE_OR_REJECT);
queryParameters.action(ImportDocumentsParameters.ActionEnum.UPSERT);
queryParameters.dirtyValues(DirtyValues.COERCE_OR_REJECT);
queryParameters.action(IndexAction.UPSERT);

String[] authors = { "shakspeare", "william" };
HashMap<String, Object> hmap = new HashMap<>();
Expand Down Expand Up @@ -247,7 +248,7 @@ void testNestedObjectImport() throws Exception {
client.collections().create(collectionSchema);

ImportDocumentsParameters queryParameters = new ImportDocumentsParameters();
queryParameters.action(ImportDocumentsParameters.ActionEnum.CREATE);
queryParameters.action(IndexAction.CREATE);

List<NestedDocument> docs = new ArrayList<>();
NestedDocument doc = new NestedDocument("LA", "CA", "USA")
Expand Down

0 comments on commit 733b5e4

Please sign in to comment.