more `@NotImplementedYet` clean-up
This commit is contained in:
parent
37094e3e80
commit
a7d76b2370
|
@ -9,12 +9,13 @@ package org.hibernate.orm.test.entitygraph.ast;
|
|||
import java.util.List;
|
||||
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.loader.ast.internal.CollectionLoaderSingleKey;
|
||||
import org.hibernate.loader.ast.internal.SingleIdEntityLoaderStandardImpl;
|
||||
import org.hibernate.loader.ast.internal.SingleIdLoadPlan;
|
||||
import org.hibernate.loader.ast.spi.CascadingFetchProfile;
|
||||
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.sql.results.graph.DomainResult;
|
||||
|
@ -24,22 +25,19 @@ import org.hibernate.sql.results.graph.collection.internal.CollectionDomainResul
|
|||
import org.hibernate.sql.results.graph.entity.EntityResult;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.NotImplementedYet;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hibernate.testing.hamcrest.CollectionMatchers.hasSize;
|
||||
import static org.hibernate.testing.hamcrest.CollectionMatchers.isEmpty;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
@ -54,62 +52,75 @@ public class LoadPlanBuilderTest {
|
|||
final SessionFactoryImplementor sessionFactory = scope.getSessionFactory();
|
||||
final EntityPersister entityDescriptor = sessionFactory.getDomainModel().getEntityDescriptor( Message.class );
|
||||
|
||||
final SingleIdEntityLoaderStandardImpl loader = new SingleIdEntityLoaderStandardImpl(
|
||||
entityDescriptor,
|
||||
sessionFactory
|
||||
);
|
||||
final SingleIdEntityLoaderStandardImpl<?> loader = new SingleIdEntityLoaderStandardImpl<>( entityDescriptor, sessionFactory );
|
||||
|
||||
final SingleIdLoadPlan loadPlan = loader.resolveLoadPlan(
|
||||
final SingleIdLoadPlan<?> loadPlan = loader.resolveLoadPlan(
|
||||
LockOptions.READ,
|
||||
LoadQueryInfluencers.NONE,
|
||||
sessionFactory
|
||||
);
|
||||
|
||||
assertThat(
|
||||
loadPlan.getJdbcSelect()
|
||||
.getJdbcValuesMappingProducer()
|
||||
.resolve( null, sessionFactory )
|
||||
.getDomainResults(),
|
||||
hasSize( 1 )
|
||||
|
||||
);
|
||||
final DomainResult domainResult = loadPlan.getJdbcSelect().getJdbcValuesMappingProducer()
|
||||
final List<DomainResult<?>> domainResults = loadPlan.getJdbcSelect()
|
||||
.getJdbcValuesMappingProducer()
|
||||
.resolve( null, sessionFactory )
|
||||
.getDomainResults()
|
||||
.get( 0 );
|
||||
assertThat( domainResult, instanceOf( EntityResult.class ) );
|
||||
.getDomainResults();
|
||||
|
||||
assertThat( domainResults ).hasSize( 1 );
|
||||
final DomainResult<?> domainResult = domainResults.get( 0 );
|
||||
assertThat( domainResult ).isInstanceOf( EntityResult.class );
|
||||
final EntityResult entityResult = (EntityResult) domainResult;
|
||||
assertThat( entityResult.getFetches(), hasSize( 2 ) );
|
||||
assertThat( entityResult.getFetches() ).hasSize( 2 );
|
||||
|
||||
final Fetch txtFetch = entityResult.getFetches().get( 0 );
|
||||
assertThat( txtFetch ).isNotNull();
|
||||
assertThat( txtFetch.getFetchedMapping().getFetchableName() ).isEqualTo( "msgTxt" );
|
||||
assertThat( txtFetch.getTiming() ).isEqualTo( FetchTiming.IMMEDIATE );
|
||||
|
||||
final Fetch posterFetch = entityResult.getFetches().get( 1 );
|
||||
assertThat( posterFetch ).isNotNull();
|
||||
assertThat( posterFetch.getFetchedMapping().getFetchableName() ).isEqualTo( "poster" );
|
||||
assertThat( posterFetch.getTiming() ).isEqualTo( FetchTiming.DELAYED );
|
||||
}
|
||||
|
||||
@Test
|
||||
@NotImplementedYet(reason = "Cascade-driven DomainResult graph building not yet implemented")
|
||||
public void testCascadeBasedBuild() {
|
||||
throw new NotYetImplementedFor6Exception( "Cascade-driven DomainResult graph building not yet implemented" );
|
||||
// EntityPersister ep = (EntityPersister) sessionFactory().getClassMetadata(Message.class);
|
||||
// CascadeStyleLoadPlanBuildingAssociationVisitationStrategy strategy = new CascadeStyleLoadPlanBuildingAssociationVisitationStrategy(
|
||||
// CascadingActions.MERGE,
|
||||
// sessionFactory(),
|
||||
// LoadQueryInfluencers.NONE,
|
||||
// LockMode.NONE
|
||||
// );
|
||||
// LoadPlan plan = MetamodelDrivenLoadPlanBuilder.buildRootEntityLoadPlan( strategy, ep );
|
||||
// assertFalse( plan.hasAnyScalarReturns() );
|
||||
// assertEquals( 1, plan.getReturns().size() );
|
||||
// Return rtn = plan.getReturns().get( 0 );
|
||||
// EntityReturn entityReturn = ExtraAssertions.assertTyping( EntityReturn.class, rtn );
|
||||
// assertNotNull( entityReturn.getFetches() );
|
||||
// assertEquals( 1, entityReturn.getFetches().length );
|
||||
// Fetch fetch = entityReturn.getFetches()[0];
|
||||
// EntityFetch entityFetch = ExtraAssertions.assertTyping( EntityFetch.class, fetch );
|
||||
// assertNotNull( entityFetch.getFetches() );
|
||||
// assertEquals( 0, entityFetch.getFetches().length );
|
||||
//
|
||||
// LoadPlanTreePrinter.INSTANCE.logTree( plan, new AliasResolutionContextImpl( sessionFactory() ) );
|
||||
public void testCascadeBasedBuild(SessionFactoryScope scope) {
|
||||
final SessionFactoryImplementor sessionFactory = scope.getSessionFactory();
|
||||
final EntityPersister entityDescriptor = (EntityPersister) sessionFactory.getRuntimeMetamodels().getEntityMappingType( Message.class );
|
||||
|
||||
final SingleIdEntityLoaderStandardImpl<?> loader = new SingleIdEntityLoaderStandardImpl<>( entityDescriptor, sessionFactory );
|
||||
|
||||
final LoadQueryInfluencers influencers = new LoadQueryInfluencers() {
|
||||
@Override
|
||||
public CascadingFetchProfile getEnabledCascadingFetchProfile() {
|
||||
return CascadingFetchProfile.MERGE;
|
||||
}
|
||||
};
|
||||
|
||||
final SingleIdLoadPlan<?> loadPlan = loader.resolveLoadPlan(
|
||||
LockOptions.READ,
|
||||
influencers,
|
||||
sessionFactory
|
||||
);
|
||||
final List<DomainResult<?>> domainResults = loadPlan.getJdbcSelect()
|
||||
.getJdbcValuesMappingProducer()
|
||||
.resolve( null, sessionFactory )
|
||||
.getDomainResults();
|
||||
|
||||
assertThat( domainResults ).hasSize( 1 );
|
||||
final DomainResult<?> domainResult = domainResults.get( 0 );
|
||||
assertThat( domainResult ).isInstanceOf( EntityResult.class );
|
||||
final EntityResult entityResult = (EntityResult) domainResult;
|
||||
assertThat( entityResult.getFetches() ).hasSize( 2 );
|
||||
|
||||
final Fetch txtFetch = entityResult.getFetches().get( 0 );
|
||||
assertThat( txtFetch ).isNotNull();
|
||||
assertThat( txtFetch.getFetchedMapping().getFetchableName() ).isEqualTo( "msgTxt" );
|
||||
assertThat( txtFetch.getTiming() ).isEqualTo( FetchTiming.IMMEDIATE );
|
||||
|
||||
final Fetch posterFetch = entityResult.getFetches().get( 1 );
|
||||
assertThat( posterFetch ).isNotNull();
|
||||
assertThat( posterFetch.getFetchedMapping().getFetchableName() ).isEqualTo( "poster" );
|
||||
assertThat( posterFetch.getTiming() ).isEqualTo( FetchTiming.IMMEDIATE );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -124,15 +135,15 @@ public class LoadPlanBuilderTest {
|
|||
sessionFactory
|
||||
);
|
||||
|
||||
assertThat( loader.getSqlAst().getDomainResultDescriptors(), hasSize( 1 ) );
|
||||
assertThat( loader.getSqlAst().getDomainResultDescriptors().get( 0 ), instanceOf( CollectionDomainResult.class ) );
|
||||
assertThat( loader.getSqlAst().getDomainResultDescriptors() ).hasSize( 1 );
|
||||
assertThat( loader.getSqlAst().getDomainResultDescriptors().get( 0 ) ).isInstanceOf( CollectionDomainResult.class );
|
||||
final CollectionDomainResult domainResult = (CollectionDomainResult) loader.getSqlAst()
|
||||
.getDomainResultDescriptors()
|
||||
.get( 0 );
|
||||
|
||||
DomainResultGraphPrinter.logDomainResultGraph( loader.getSqlAst().getDomainResultDescriptors() );
|
||||
|
||||
assertThat( domainResult.getFetches(), isEmpty() );
|
||||
assertThat( domainResult.getFetches() ).isEmpty();
|
||||
}
|
||||
|
||||
@Entity( name = "Message" )
|
||||
|
@ -140,7 +151,7 @@ public class LoadPlanBuilderTest {
|
|||
@Id
|
||||
private Integer mid;
|
||||
private String msgTxt;
|
||||
@ManyToOne( cascade = CascadeType.MERGE )
|
||||
@ManyToOne( fetch = FetchType.LAZY, cascade = CascadeType.MERGE )
|
||||
@JoinColumn
|
||||
private Poster poster;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.hibernate.cfg.AvailableSettings;
|
|||
|
||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||
import org.hibernate.testing.orm.junit.Jpa;
|
||||
import org.hibernate.testing.orm.junit.NotImplementedYet;
|
||||
import org.hibernate.testing.orm.junit.Setting;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
@ -22,12 +22,16 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*
|
||||
* @author Bruno P. Kinoshita
|
||||
*/
|
||||
@Jpa
|
||||
@Jpa(
|
||||
integrationSettings = {
|
||||
@Setting( name = AvailableSettings.USER, value = "user" ),
|
||||
@Setting( name = AvailableSettings.PASS, value = "pass" )
|
||||
}
|
||||
)
|
||||
public class MaskSensitiveInformationTest {
|
||||
private static final String EXPECTED_MASKED_VALUE = "****";
|
||||
|
||||
@Test
|
||||
@NotImplementedYet( strict = false, reason = "Setting `" + AvailableSettings.PASS + "` does not propagate to `" + AvailableSettings.JPA_JDBC_PASSWORD + "`" )
|
||||
public void testMaskOutSensitiveInformation(EntityManagerFactoryScope scope) {
|
||||
Map<String, Object> properties = scope.getEntityManagerFactory().getProperties();
|
||||
assertThat( properties.get( AvailableSettings.USER ) ).isEqualTo( EXPECTED_MASKED_VALUE );
|
||||
|
|
|
@ -6,13 +6,16 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.jpa.criteria.basic;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.junit.Test;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.TypedQuery;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
|
@ -22,11 +25,8 @@ import jakarta.persistence.criteria.Predicate;
|
|||
import jakarta.persistence.criteria.Root;
|
||||
import jakarta.persistence.metamodel.SingularAttribute;
|
||||
|
||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.orm.junit.NotImplementedYet;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
@ -67,12 +67,11 @@ public class BasicCriteriaUsageTest extends BaseEntityManagerFunctionalTestCase
|
|||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-8283")
|
||||
@Ignore( "Missing support for composite user types" )
|
||||
@NotImplementedYet
|
||||
public void testDateCompositeCustomType() {
|
||||
Payment payment = new Payment();
|
||||
final Date date = Date.from( Instant.now() );
|
||||
final Payment payment = new Payment();
|
||||
payment.setAmount( new BigDecimal( 1000 ) );
|
||||
payment.setDate( new Date() );
|
||||
payment.setDate( date );
|
||||
|
||||
EntityManager em = getOrCreateEntityManager();
|
||||
em.getTransaction().begin();
|
||||
|
@ -80,7 +79,7 @@ public class BasicCriteriaUsageTest extends BaseEntityManagerFunctionalTestCase
|
|||
|
||||
CriteriaQuery<Payment> criteria = em.getCriteriaBuilder().createQuery( Payment.class );
|
||||
Root<Payment> rp = criteria.from( Payment.class );
|
||||
Predicate predicate = em.getCriteriaBuilder().equal( rp.get( Payment_.date ), new Date() );
|
||||
Predicate predicate = em.getCriteriaBuilder().equal( rp.get( Payment_.date ), date );
|
||||
criteria.where( predicate );
|
||||
|
||||
TypedQuery<Payment> q = em.createQuery( criteria );
|
||||
|
|
Loading…
Reference in New Issue