|
| 1 | +/* |
| 2 | + * Copyright (c) 2025 Contributors to the Eclipse Foundation |
| 3 | + * All rights reserved. This program and the accompanying materials |
| 4 | + * are made available under the terms of the Eclipse Public License v1.0 |
| 5 | + * and Apache License v2.0 which accompanies this distribution. |
| 6 | + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html |
| 7 | + * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. |
| 8 | + * |
| 9 | + * You may elect to redistribute this code under either of these licenses. |
| 10 | + * |
| 11 | + * Contributors: |
| 12 | + * |
| 13 | + * Otavio Santana |
| 14 | + */ |
| 15 | +package org.eclipse.jnosql.databases.tinkerpop.mapping; |
| 16 | + |
| 17 | + |
| 18 | +import jakarta.inject.Inject; |
| 19 | +import org.assertj.core.api.SoftAssertions; |
| 20 | +import org.eclipse.jnosql.databases.tinkerpop.mapping.entities.Human; |
| 21 | +import org.eclipse.jnosql.databases.tinkerpop.mapping.spi.TinkerpopExtension; |
| 22 | +import org.eclipse.jnosql.mapping.core.Converters; |
| 23 | +import org.eclipse.jnosql.mapping.graph.GraphTemplate; |
| 24 | +import org.eclipse.jnosql.mapping.graph.spi.GraphExtension; |
| 25 | +import org.eclipse.jnosql.mapping.reflection.Reflections; |
| 26 | +import org.eclipse.jnosql.mapping.reflection.spi.ReflectionEntityMetadataExtension; |
| 27 | +import org.eclipse.jnosql.mapping.semistructured.EntityConverter; |
| 28 | +import org.jboss.weld.junit5.auto.AddExtensions; |
| 29 | +import org.jboss.weld.junit5.auto.AddPackages; |
| 30 | +import org.jboss.weld.junit5.auto.EnableAutoWeld; |
| 31 | +import org.junit.jupiter.api.BeforeEach; |
| 32 | +import org.junit.jupiter.api.Test; |
| 33 | + |
| 34 | +@EnableAutoWeld |
| 35 | +@AddPackages(value = {Converters.class, EntityConverter.class, TinkerpopTemplate.class, GraphTemplate.class}) |
| 36 | +@AddPackages(GraphProducer.class) |
| 37 | +@AddPackages(Reflections.class) |
| 38 | +@AddExtensions({ReflectionEntityMetadataExtension.class, TinkerpopExtension.class, GraphExtension.class}) |
| 39 | +public class PopulationTest { |
| 40 | + |
| 41 | + @Inject |
| 42 | + private Population population; |
| 43 | + |
| 44 | + @BeforeEach |
| 45 | + void setUp() { |
| 46 | + this.population.deleteAll(); |
| 47 | + } |
| 48 | + |
| 49 | + @Test |
| 50 | + void shouldSave() { |
| 51 | + var human = Human.builder().withAge().withName("Otavio").build(); |
| 52 | + Human saved = population.save(human); |
| 53 | + |
| 54 | + SoftAssertions.assertSoftly(soft ->{ |
| 55 | + soft.assertThat(saved).isNotNull(); |
| 56 | + soft.assertThat(saved.getId()).isNotNull(); |
| 57 | + soft.assertThat(saved.getName()).isEqualTo(human.getName()); |
| 58 | + soft.assertThat(saved.getAge()).isEqualTo(human.getAge()); |
| 59 | + }); |
| 60 | + |
| 61 | + } |
| 62 | + |
| 63 | + @Test |
| 64 | + void shouldFindByQuery() { |
| 65 | + |
| 66 | + } |
| 67 | +} |
0 commit comments