diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index b49b05b75..ad9926273 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -17,6 +17,7 @@ and this project adheres to https://semver.org/spec/v2.0.0.html[Semantic Version - Update OrientDB driver to 3.2.36 - Update Couchbase client 3.7.6 - Update DynamoDB driver 2.29.45 +- Update ArangoDb driver to 7.17.0 === Fixed diff --git a/jnosql-arangodb/pom.xml b/jnosql-arangodb/pom.xml index d6e4b7e16..1aac16282 100644 --- a/jnosql-arangodb/pom.xml +++ b/jnosql-arangodb/pom.xml @@ -28,7 +28,7 @@ The Eclipse JNoSQL layer to ArangoDB - 7.16.0 + 7.17.0 diff --git a/jnosql-arangodb/src/test/java/org/eclipse/jnosql/databases/arangodb/integration/ArangoDBEnumIntegrationTest.java b/jnosql-arangodb/src/test/java/org/eclipse/jnosql/databases/arangodb/integration/ArangoDBEnumIntegrationTest.java new file mode 100644 index 000000000..e72c96f6b --- /dev/null +++ b/jnosql-arangodb/src/test/java/org/eclipse/jnosql/databases/arangodb/integration/ArangoDBEnumIntegrationTest.java @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2025 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.arangodb.integration; + + +import jakarta.inject.Inject; +import org.assertj.core.api.SoftAssertions; +import org.eclipse.jnosql.databases.arangodb.communication.ArangoDBConfigurations; +import org.eclipse.jnosql.mapping.Database; +import org.eclipse.jnosql.mapping.core.Converters; +import org.eclipse.jnosql.mapping.core.config.MappingConfigurations; +import org.eclipse.jnosql.mapping.core.spi.EntityMetadataExtension; +import org.eclipse.jnosql.mapping.document.DocumentTemplate; +import org.eclipse.jnosql.mapping.document.spi.DocumentExtension; +import org.eclipse.jnosql.mapping.reflection.Reflections; +import org.eclipse.jnosql.mapping.semistructured.EntityConverter; +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 org.junit.jupiter.api.condition.EnabledIfSystemProperty; + +import java.util.List; +import java.util.function.Predicate; + +import static org.eclipse.jnosql.communication.driver.IntegrationTest.MATCHES; +import static org.eclipse.jnosql.communication.driver.IntegrationTest.NAMED; +import static org.eclipse.jnosql.databases.arangodb.communication.DocumentDatabase.INSTANCE; + +@EnableAutoWeld +@AddPackages(value = {Database.class, EntityConverter.class, DocumentTemplate.class}) +@AddPackages(Magazine.class) +@AddExtensions({EntityMetadataExtension.class, + DocumentExtension.class}) +@AddPackages(Reflections.class) +@AddPackages(Converters.class) +@EnabledIfSystemProperty(named = NAMED, matches = MATCHES) +public class ArangoDBEnumIntegrationTest { + + + static { + INSTANCE.get("library"); + System.setProperty(ArangoDBConfigurations.HOST.get() + ".1", INSTANCE.host()); + System.setProperty(MappingConfigurations.DOCUMENT_DATABASE.get(), "library"); + } + + @Inject + private DocumentTemplate template; + + + @Inject + private MailTemplateRepository repository; + + @Test + void shouldCreateAndQueryByEnumAndDefaultTrue() { + template.insert(MailTemplate.builder() + .category(MailCategory.TIMER) + .from("otavio@email.com") + .to("mateusz@email.com") + .isDefault(true) + .build()); + + List result = template.select(MailTemplate.class) .where("category") + .eq(MailCategory.TIMER).result(); + + SoftAssertions.assertSoftly(soft -> { + Predicate isTimer = m -> m.getCategory().equals(MailCategory.TIMER); + Predicate isTrue = m -> m.isDefault(); + soft.assertThat(result).allMatch(isTimer.and(isTrue)); + }); + } + + @Test + void shouldCreateAndQueryByEnumAndDefaultFalse() { + var emailTemplate = MailTemplate.builder() + .category(MailCategory.TRANSITION_ALTERNATIVE) + .from("otavio@email.com") + .to("mateusz@email.com") + .isDefault(false) + .build(); + + template.insert(emailTemplate); + + List result = template.select(MailTemplate.class) + .where("category") + .eq(MailCategory.TRANSITION_ALTERNATIVE) + .and("isDefault") + .eq(false).result(); + + SoftAssertions.assertSoftly(soft -> { + Predicate isAlternative = m -> m.getCategory().equals(MailCategory.TRANSITION_ALTERNATIVE); + Predicate isFalse = m -> !m.isDefault(); + soft.assertThat(result).hasSize(1).allMatch( + isAlternative.and(isFalse)); + }); + } + + @Test + void shouldQueryUsingRepository() { + repository.save(MailTemplate.builder() + .category(MailCategory.TIMER) + .from("otavio@email.com") + .to("mateusz@email.com") + .isDefault(true) + .build()); + + repository.save(MailTemplate.builder() + .category(MailCategory.TRANSITION_ALTERNATIVE) + .from("otavio@email.com") + .to("mateusz@email.com") + .isDefault(true) + .build()); + + List categoryAndIsDefaultTrue = repository.findByCategoryAndIsDefaultTrue(MailCategory.TIMER); + + SoftAssertions.assertSoftly(soft -> { + Predicate isTimer = m -> m.getCategory().equals(MailCategory.TIMER); + Predicate isTrue = m -> m.isDefault(); + soft.assertThat(categoryAndIsDefaultTrue).hasSize(1).allMatch( + isTimer.and(isTrue)); + }); + } +} diff --git a/jnosql-arangodb/src/test/java/org/eclipse/jnosql/databases/arangodb/integration/MailCategory.java b/jnosql-arangodb/src/test/java/org/eclipse/jnosql/databases/arangodb/integration/MailCategory.java new file mode 100644 index 000000000..3d86fa0f7 --- /dev/null +++ b/jnosql-arangodb/src/test/java/org/eclipse/jnosql/databases/arangodb/integration/MailCategory.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2025 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.arangodb.integration; + +public enum MailCategory { + TIMER, + TRANSITION_MAIN, + TRANSITION_ALTERNATIVE, + TRANSITION_FALLBACK +} \ No newline at end of file diff --git a/jnosql-arangodb/src/test/java/org/eclipse/jnosql/databases/arangodb/integration/MailTemplate.java b/jnosql-arangodb/src/test/java/org/eclipse/jnosql/databases/arangodb/integration/MailTemplate.java new file mode 100644 index 000000000..511564b54 --- /dev/null +++ b/jnosql-arangodb/src/test/java/org/eclipse/jnosql/databases/arangodb/integration/MailTemplate.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2025 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.arangodb.integration; + +import jakarta.nosql.Column; +import jakarta.nosql.Entity; +import jakarta.nosql.Id; + +import java.util.Objects; +import java.util.UUID; + +@Entity +public class MailTemplate { + + @Id + private String id; + + @Column + private String to; + + @Column + private String from; + + @Column + private MailCategory category; + + @Column + private boolean isDefault; + + public String getId() { + return id; + } + + public String getTo() { + return to; + } + + public String getFrom() { + return from; + } + + public MailCategory getCategory() { + return category; + } + + public boolean isDefault() { + return isDefault; + } + + @Override + public boolean equals(Object o) { + if (o == null || getClass() != o.getClass()) { + return false; + } + MailTemplate that = (MailTemplate) o; + return Objects.equals(id, that.id); + } + + @Override + public int hashCode() { + return Objects.hashCode(id); + } + + @Override + public String toString() { + return "MailTemplate{" + + "id=" + id + + ", to='" + to + '\'' + + ", from='" + from + '\'' + + ", category=" + category + + ", isDefault=" + isDefault + + '}'; + } + + public static MailTemplateBuilder builder(){ + return new MailTemplateBuilder(); + } + + + public static class MailTemplateBuilder{ + + private String to; + + private String from; + + private MailCategory category; + + private boolean isDefault; + + public MailTemplateBuilder to(String to) { + this.to = to; + return this; + } + + public MailTemplateBuilder from(String from) { + this.from = from; + return this; + } + + public MailTemplateBuilder category(MailCategory category) { + this.category = category; + return this; + } + + public MailTemplateBuilder isDefault(boolean isDefault) { + this.isDefault = isDefault; + return this; + } + + public MailTemplate build(){ + MailTemplate mailTemplate = new MailTemplate(); + mailTemplate.id = UUID.randomUUID().toString(); + mailTemplate.to = this.to; + mailTemplate.from = this.from; + mailTemplate.category = this.category; + mailTemplate.isDefault = this.isDefault; + return mailTemplate; + } + } +} diff --git a/jnosql-arangodb/src/test/java/org/eclipse/jnosql/databases/arangodb/integration/MailTemplateRepository.java b/jnosql-arangodb/src/test/java/org/eclipse/jnosql/databases/arangodb/integration/MailTemplateRepository.java new file mode 100644 index 000000000..d68df6bc6 --- /dev/null +++ b/jnosql-arangodb/src/test/java/org/eclipse/jnosql/databases/arangodb/integration/MailTemplateRepository.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 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.arangodb.integration; + +import jakarta.data.repository.Repository; +import org.eclipse.jnosql.mapping.NoSQLRepository; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +@Repository +public interface MailTemplateRepository extends NoSQLRepository { + + List findByCategoryAndIsDefaultTrue(@NotNull MailCategory mailCategory); +} \ No newline at end of file