Skip to content

Commit

Permalink
chore: update test at sorl with integration test
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <otaviopolianasantana@gmail.com>
  • Loading branch information
otaviojava committed May 19, 2023
1 parent ee67252 commit 80dcaea
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
import org.eclipse.jnosql.communication.document.Document;
import org.eclipse.jnosql.communication.document.DocumentCondition;
import org.eclipse.jnosql.communication.document.DocumentConfiguration;
import org.eclipse.jnosql.communication.document.DocumentDeleteQuery;
import org.eclipse.jnosql.communication.document.DocumentEntity;
import org.eclipse.jnosql.communication.document.DocumentQuery;
Expand Down Expand Up @@ -106,6 +109,17 @@ public Iterable<DocumentEntity> insert(Iterable<DocumentEntity> entities, Durati

@Override
public DocumentEntity update(DocumentEntity entity) {
Objects.requireNonNull(entity, "entity is required");

Document id = entity.find("_id").orElseThrow(() ->
new IllegalArgumentException("The _id field is required for update"));

DocumentCondition condition = DocumentCondition.eq(id);
DocumentDeleteQuery query = DocumentDeleteQuery.builder()
.from(entity.name())
.where(condition).build();
delete(query);

return insert(entity);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
public class DefaultSolrDocumentManagerTest {

public static final String COLLECTION_NAME = "person";
public static final String ID = "id";
public static final String ID = "_id";
private static SolrDocumentManager entityManager;

@BeforeAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class SolrTemplateIntegrationTest {

static {
DocumentDatabase.INSTANCE.get();
System.setProperty(SolrDocumentConfigurations.HOST.get() + ".1", DocumentDatabase.INSTANCE.host());
System.setProperty(SolrDocumentConfigurations.HOST.get(), DocumentDatabase.INSTANCE.host());
System.setProperty(MappingConfigurations.DOCUMENT_DATABASE.get(), "database");
}

Expand Down

0 comments on commit 80dcaea

Please sign in to comment.