Skip to content

Commit

Permalink
test: fix integration test at cassandra
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 24e5dd4 commit db8b6c9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.jnosql.databases.cassandra.communication.ColumnDatabase;
import org.eclipse.jnosql.databases.cassandra.mapping.CassandraTemplate;
import org.eclipse.jnosql.mapping.Convert;
import org.eclipse.jnosql.mapping.Converters;
import org.eclipse.jnosql.mapping.column.ColumnEntityConverter;
import org.eclipse.jnosql.mapping.column.spi.ColumnExtension;
import org.eclipse.jnosql.mapping.config.MappingConfigurations;
Expand Down Expand Up @@ -48,6 +49,7 @@
@AddExtensions({EntityMetadataExtension.class,
ColumnExtension.class})
@AddPackages(Reflections.class)
@AddPackages(Converters.class)
@EnabledIfSystemProperty(named = NAMED, matches = MATCHES)
class CassandraTemplateIntegrationTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@

import jakarta.inject.Inject;
import jakarta.nosql.column.ColumnTemplate;
import org.assertj.core.api.SoftAssertions;
import org.eclipse.jnosql.communication.driver.ConfigurationReader;
import org.eclipse.jnosql.databases.cassandra.communication.CassandraConfigurations;
import org.eclipse.jnosql.databases.cassandra.communication.ColumnDatabase;
import org.eclipse.jnosql.mapping.Convert;
import org.eclipse.jnosql.mapping.Converters;
import org.eclipse.jnosql.mapping.column.ColumnEntityConverter;
import org.eclipse.jnosql.mapping.column.spi.ColumnExtension;
import org.eclipse.jnosql.mapping.config.MappingConfigurations;
Expand All @@ -47,6 +49,7 @@
@AddExtensions({EntityMetadataExtension.class,
ColumnExtension.class})
@AddPackages(Reflections.class)
@AddPackages(Converters.class)
@EnabledIfSystemProperty(named = NAMED, matches = MATCHES)
class TemplateIntegrationTest {

Expand All @@ -64,7 +67,7 @@ class TemplateIntegrationTest {
}

@Test
public void shouldInsert() {
void shouldInsert() {
Book book = new Book(randomUUID().toString(), "Effective Java", 1);
template.insert(book);
Optional<Book> optional = template.find(Book.class, book.id());
Expand All @@ -73,7 +76,7 @@ public void shouldInsert() {
}

@Test
public void shouldUpdate() {
void shouldUpdate() {
Book book = new Book(randomUUID().toString(), "Effective Java", 1);
assertThat(template.insert(book))
.isNotNull()
Expand All @@ -91,7 +94,7 @@ public void shouldUpdate() {
}

@Test
public void shouldFindById() {
void shouldFindById() {
Book book = new Book(randomUUID().toString(), "Effective Java", 1);
assertThat(template.insert(book))
.isNotNull()
Expand All @@ -102,7 +105,7 @@ public void shouldFindById() {
}

@Test
public void shouldDelete() {
void shouldDelete() {
Book book = new Book(randomUUID().toString(), "Effective Java", 1);
assertThat(template.insert(book))
.isNotNull()
Expand All @@ -113,5 +116,19 @@ public void shouldDelete() {
.isNotNull().isEmpty();
}

@Test
void shouldUpdateNullValues(){
var book = new Book(randomUUID().toString(), "Effective Java", 1);
template.insert(book);
template.update(new Book(book.id(), null, 2));
Optional<Book> optional = template.select(Book.class).where("id")
.eq(book.id()).singleResult();
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(optional).isPresent();
softly.assertThat(optional).get().extracting(Book::title).isNull();
softly.assertThat(optional).get().extracting(Book::edition).isEqualTo(2);
});
}


}

0 comments on commit db8b6c9

Please sign in to comment.