-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#49 - Add returnType and argumentTypes to MethodDetails
- Loading branch information
Showing
12 changed files
with
339 additions
and
11 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
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
16 changes: 16 additions & 0 deletions
16
hibernate-models-orm/src/main/java/org/hibernate/models/orm/xml/package-info.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,16 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright: Red Hat Inc. and Hibernate Authors | ||
*/ | ||
|
||
/** | ||
* Support for processing mapping XML files, ultimately creating/updating | ||
* {@linkplain org.hibernate.models.source.spi.AnnotationUsage annotation} references | ||
* on the model's {@linkplain org.hibernate.models.source.spi.AnnotationTarget targets} | ||
* based on the XML. | ||
* | ||
* @author Steve Ebersole | ||
*/ | ||
package org.hibernate.models.orm.xml; |
75 changes: 75 additions & 0 deletions
75
...te-models-orm/src/test/java/org/hibernate/models/orm/xml/globals/EntityListenerTests.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,75 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright: Red Hat Inc. and Hibernate Authors | ||
*/ | ||
package org.hibernate.models.orm.xml.globals; | ||
|
||
import java.util.List; | ||
|
||
import org.hibernate.models.orm.internal.ManagedResourcesImpl; | ||
import org.hibernate.models.orm.spi.EntityListenerRegistration; | ||
import org.hibernate.models.orm.spi.ManagedResources; | ||
import org.hibernate.models.orm.spi.ProcessResult; | ||
import org.hibernate.models.orm.spi.Processor; | ||
import org.hibernate.models.orm.xml.SimpleEntity; | ||
import org.hibernate.models.source.SourceModelTestHelper; | ||
import org.hibernate.models.source.internal.SourceModelBuildingContextImpl; | ||
import org.hibernate.models.source.spi.MethodDetails; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import org.jboss.jandex.Index; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.hibernate.models.internal.SimpleClassLoading.SIMPLE_CLASS_LOADING; | ||
|
||
/** | ||
* @author Steve Ebersole | ||
*/ | ||
public class EntityListenerTests { | ||
@Test | ||
void testGlobalRegistration() { | ||
final ManagedResources managedResources = new ManagedResourcesImpl.Builder() | ||
.addXmlMappings( "mappings/globals.xml" ) | ||
.build(); | ||
|
||
final Index jandexIndex = SourceModelTestHelper.buildJandexIndex( | ||
SIMPLE_CLASS_LOADING, | ||
SimpleEntity.class | ||
); | ||
final SourceModelBuildingContextImpl buildingContext = SourceModelTestHelper.createBuildingContext( | ||
jandexIndex, | ||
SIMPLE_CLASS_LOADING | ||
); | ||
|
||
final ProcessResult processResult = Processor.process( | ||
managedResources, | ||
null, | ||
new Processor.Options() { | ||
@Override | ||
public boolean areGeneratorsGlobal() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean shouldIgnoreUnlistedClasses() { | ||
return false; | ||
} | ||
}, | ||
buildingContext | ||
); | ||
|
||
final List<EntityListenerRegistration> registrations = processResult | ||
.getGlobalRegistrations() | ||
.getEntityListenerRegistrations(); | ||
assertThat( registrations ).hasSize( 1 ); | ||
final EntityListenerRegistration registration = registrations.get( 0 ); | ||
final MethodDetails postPersistMethod = registration.getPostPersistMethod(); | ||
assertThat( postPersistMethod ).isNotNull(); | ||
assertThat( postPersistMethod.getReturnType() ).isNull(); | ||
assertThat( postPersistMethod.getArgumentTypes() ).hasSize( 1 ); | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
...e-models-orm/src/test/java/org/hibernate/models/orm/xml/globals/GlobalEntityListener.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,26 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright: Red Hat Inc. and Hibernate Authors | ||
*/ | ||
package org.hibernate.models.orm.xml.globals; | ||
|
||
/** | ||
* JPA entity listener | ||
* | ||
* @author Steve Ebersole | ||
*/ | ||
public class GlobalEntityListener { | ||
public void entityCreated(Object entity) { | ||
System.out.println( "Entity was created - " + entity ); | ||
} | ||
|
||
public Object entityCreated() { | ||
throw new RuntimeException( "Should not be called" ); | ||
} | ||
|
||
public void entityCreated(Object e1, Object e2) { | ||
throw new RuntimeException( "Should not be called" ); | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.