-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: create ingration test to hazelcast and key-value template
Signed-off-by: Otavio Santana <otaviopolianasantana@gmail.com>
- Loading branch information
1 parent
4f10789
commit a0b9600
Showing
2 changed files
with
87 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...a/org/eclipse/jnosql/databases/hazelcast/integration/KeyValueTemplateIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Apache License v2.0 which accompanies this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. | ||
* | ||
* You may elect to redistribute this code under either of these licenses. | ||
* | ||
* Contributors: | ||
* | ||
* Otavio Santana | ||
*/ | ||
package org.eclipse.jnosql.databases.hazelcast.integration; | ||
|
||
|
||
import jakarta.inject.Inject; | ||
import jakarta.nosql.keyvalue.KeyValueTemplate; | ||
import org.eclipse.jnosql.databases.hazelcast.mapping.HazelcastTemplate; | ||
import org.eclipse.jnosql.mapping.Convert; | ||
import org.eclipse.jnosql.mapping.config.MappingConfigurations; | ||
import org.eclipse.jnosql.mapping.keyvalue.KeyValueEntityConverter; | ||
import org.eclipse.jnosql.mapping.keyvalue.spi.KeyValueExtension; | ||
import org.eclipse.jnosql.mapping.reflection.EntityMetadataExtension; | ||
import org.jboss.weld.junit5.auto.AddExtensions; | ||
import org.jboss.weld.junit5.auto.AddPackages; | ||
import org.jboss.weld.junit5.auto.EnableAutoWeld; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Optional; | ||
|
||
import static java.util.UUID.randomUUID; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@EnableAutoWeld | ||
@AddPackages(value = {Convert.class, KeyValueEntityConverter.class}) | ||
@AddPackages(Book.class) | ||
@AddPackages(HazelcastTemplate.class) | ||
@AddExtensions({EntityMetadataExtension.class, | ||
KeyValueExtension.class}) | ||
class KeyValueTemplateIntegrationTest { | ||
|
||
@Inject | ||
private KeyValueTemplate template; | ||
|
||
static { | ||
System.setProperty(MappingConfigurations.KEY_VALUE_DATABASE.get(), "library"); | ||
} | ||
|
||
@Test | ||
public void shouldPutValue() { | ||
Book book = new Book(randomUUID().toString(), "Effective Java", 1); | ||
template.put(book); | ||
Optional<Book> effective = template.get(book.id(), Book.class); | ||
assertThat(effective) | ||
.isNotNull() | ||
.isPresent() | ||
.get().isEqualTo(book); | ||
} | ||
|
||
@Test | ||
public void shouldGet() { | ||
Book book = new Book(randomUUID().toString(), "Effective Java", 1); | ||
template.put(book); | ||
Optional<Book> effective = template.get(book.id(), Book.class); | ||
assertThat(effective) | ||
.isNotNull() | ||
.isPresent() | ||
.get().isEqualTo(book); | ||
} | ||
|
||
@Test | ||
public void shouldDelete() { | ||
Book book = new Book(randomUUID().toString(), "Effective Java", 1); | ||
template.put(book); | ||
Optional<Book> effective = template.get(book.id(), Book.class); | ||
assertThat(effective) | ||
.isNotNull() | ||
.isPresent() | ||
.get().isEqualTo(book); | ||
template.delete(Book.class, book.id()); | ||
|
||
assertThat(template.get(book.id(), Book.class)) | ||
.isEmpty(); | ||
} | ||
} |