Skip to content

Commit

Permalink
test: create test for null values
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <otaviopolianasantana@gmail.com>
  • Loading branch information
otaviojava committed Nov 19, 2023
1 parent c09af2c commit 8467d87
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

package org.eclipse.jnosql.databases.solr.communication;

import org.assertj.core.api.SoftAssertions;
import org.eclipse.jnosql.communication.document.Document;
import org.eclipse.jnosql.communication.document.DocumentDeleteQuery;
import org.eclipse.jnosql.communication.document.DocumentEntity;
Expand Down Expand Up @@ -447,6 +448,32 @@ void shouldCount() {
assertTrue(entityManager.count(COLLECTION_NAME) > 0);
}

@Test
void shouldInsertNull() {
DocumentEntity entity = getEntity();
entity.add(Document.of("name", null));
DocumentEntity documentEntity = entityManager.insert(entity);
Optional<Document> name = documentEntity.find("name");
SoftAssertions.assertSoftly(soft -> {
soft.assertThat(name).isPresent();
soft.assertThat(name).get().extracting(Document::name).isEqualTo("name");
soft.assertThat(name).get().extracting(Document::get).isNull();
});
}

@Test
void shouldUpdateNull(){
var entity = entityManager.insert(getEntity());
entity.add(Document.of("name", null));
var documentEntity = entityManager.update(entity);
Optional<Document> name = documentEntity.find("name");
SoftAssertions.assertSoftly(soft -> {
soft.assertThat(name).isPresent();
soft.assertThat(name).get().extracting(Document::name).isEqualTo("name");
soft.assertThat(name).get().extracting(Document::get).isNull();
});
}

private DocumentEntity createSubdocumentList() {
DocumentEntity entity = DocumentEntity.of("AppointmentBook");
entity.add(Document.of(ID, new Random().nextInt()));
Expand Down

0 comments on commit 8467d87

Please sign in to comment.