package io.quarkus.hibernate.reactive.singlepersistenceunit;

import static org.assertj.core.api.Assertions.assertThat;

import javax.enterprise.context.control.ActivateRequestContext;
import javax.inject.Inject;

import org.hibernate.reactive.stage.Stage;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;

public class SinglePersistenceUnitCdiStageSessionTest {

    @RegisterExtension
    static QuarkusUnitTest runner = new QuarkusUnitTest()
            .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
                    .addClass(DefaultEntity.class)
                    .addAsResource("application.properties"));

    @Inject
    Stage.Session session;

    @Test
    @Disabled("#14812: We're getting a ContextNotActiveException for some (unknown) reason")
    @ActivateRequestContext
    public void test() {
        DefaultEntity entity = new DefaultEntity("default");

        DefaultEntity retrievedEntity = session.withTransaction(tx -> session.persist(entity))
                .thenCompose($ -> session.withTransaction(tx -> session.clear().find(DefaultEntity.class, entity.getId())))
                .toCompletableFuture().join();

        assertThat(retrievedEntity)
                .isNotSameAs(entity)
                .returns(entity.getName(), DefaultEntity::getName);
    }

}

@@ -886,16 +886,639 @@
 ssion;%0A%0A
+    @Inject%0A    Stage.SessionFactory sessionFactory;%0A%0A    @Test%0A    @ActivateRequestContext%0A    public void testWithFactory() %7B%0A        DefaultEntity entity = new DefaultEntity(%22default%22);%0A%0A        DefaultEntity retrievedEntity = sessionFactory.withTransaction((session, tx) -%3E session.persist(entity))%0A                .thenCompose(v -%3E sessionFactory.withSession(session -%3E session.find(DefaultEntity.class, entity.getId())))%0A                .toCompletableFuture().join();%0A%0A        assertThat(retrievedEntity)%0A                .isNotSameAs(entity)%0A                .returns(entity.getName(), DefaultEntity::getName);%0A    %7D%0A%0A
     @Tes

Update test with Stage for Hibrnate Reactive