Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HSEARCH-1442 Adding testcase, something goes wrong when an entity has…
… some @IndexedEmbedded annotations with includePath set and some with depth
- Loading branch information
1 parent
9dbefe1
commit f9ff34a
Showing
2 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
...est/java/org/hibernate/search/test/metadata/DepthAndIncludePathIndexedEmbeddedEntity.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,76 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors | ||
* as indicated by the @authors tag. All rights reserved. | ||
* See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* This copyrighted material is made available to anyone wishing to use, | ||
* modify, copy, or redistribute it subject to the terms and conditions | ||
* of the GNU Lesser General Public License, v. 2.1. | ||
* This program is distributed in the hope that it will be useful, but WITHOUT A | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | ||
* You should have received a copy of the GNU Lesser General Public License, | ||
* v.2.1 along with this distribution; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
* MA 02110-1301, USA. | ||
*/ | ||
package org.hibernate.search.test.metadata; | ||
|
||
import org.hibernate.search.annotations.Analyze; | ||
import org.hibernate.search.annotations.DocumentId; | ||
import org.hibernate.search.annotations.Field; | ||
import org.hibernate.search.annotations.Indexed; | ||
import org.hibernate.search.annotations.IndexedEmbedded; | ||
|
||
@Indexed | ||
public class DepthAndIncludePathIndexedEmbeddedEntity { | ||
|
||
@DocumentId | ||
private Long id; | ||
|
||
@Field(analyze = Analyze.NO) | ||
private String name; | ||
|
||
@IndexedEmbedded(includePaths = "name") | ||
private DepthAndIncludePathIndexedEmbeddedEntity indexedEmbeddedWithIncludePath; | ||
|
||
@IndexedEmbedded(depth = 1) | ||
private DepthAndIncludePathIndexedEmbeddedEntity indexedEmbeddedWithDepth; | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public DepthAndIncludePathIndexedEmbeddedEntity getIndexedEmbeddedWithIncludePath() { | ||
return indexedEmbeddedWithIncludePath; | ||
} | ||
|
||
public void setIndexedEmbeddedWithIncludePath(DepthAndIncludePathIndexedEmbeddedEntity indexedEmbeddedWithIncludePath) { | ||
this.indexedEmbeddedWithIncludePath = indexedEmbeddedWithIncludePath; | ||
} | ||
|
||
public DepthAndIncludePathIndexedEmbeddedEntity getIndexedEmbeddedWithDepth() { | ||
return indexedEmbeddedWithDepth; | ||
} | ||
|
||
public void setIndexedEmbeddedWithDepth(DepthAndIncludePathIndexedEmbeddedEntity indexedEmbeddedWithDepth) { | ||
this.indexedEmbeddedWithDepth = indexedEmbeddedWithDepth; | ||
} | ||
|
||
} |
62 changes: 62 additions & 0 deletions
62
...java/org/hibernate/search/test/metadata/DepthAndIncludePathIndexedEmbeddedEntityTest.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,62 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors | ||
* as indicated by the @authors tag. All rights reserved. | ||
* See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* This copyrighted material is made available to anyone wishing to use, | ||
* modify, copy, or redistribute it subject to the terms and conditions | ||
* of the GNU Lesser General Public License, v. 2.1. | ||
* This program is distributed in the hope that it will be useful, but WITHOUT A | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | ||
* You should have received a copy of the GNU Lesser General Public License, | ||
* v.2.1 along with this distribution; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
* MA 02110-1301, USA. | ||
*/ | ||
package org.hibernate.search.test.metadata; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import org.hibernate.annotations.common.reflection.java.JavaReflectionManager; | ||
import org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider; | ||
import org.hibernate.search.engine.metadata.impl.EmbeddedTypeMetadata; | ||
import org.hibernate.search.engine.metadata.impl.TypeMetadata; | ||
import org.hibernate.search.impl.ConfigContext; | ||
import org.hibernate.search.test.util.ManualConfiguration; | ||
import org.hibernate.search.test.util.TestForIssue; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
@TestForIssue(jiraKey = "HSEARCH-1442") | ||
public class DepthAndIncludePathIndexedEmbeddedEntityTest { | ||
|
||
private AnnotationMetadataProvider metadataProvider; | ||
|
||
@Before | ||
public void setUp() { | ||
ConfigContext configContext = new ConfigContext( new ManualConfiguration() ); | ||
metadataProvider = new AnnotationMetadataProvider( new JavaReflectionManager(), configContext ); | ||
} | ||
|
||
@Test | ||
public void testDepthIsProperlyHandled() { | ||
TypeMetadata rootTypeMetadata = metadataProvider | ||
.getTypeMetadataFor( DepthAndIncludePathIndexedEmbeddedEntity.class ); | ||
|
||
EmbeddedTypeMetadata embeddedWithDepthTypeMetadata = null; | ||
for ( EmbeddedTypeMetadata typeMetadata : rootTypeMetadata.getEmbeddedTypeMetadata() ) { | ||
if ( "indexedEmbeddedWithDepth".equals( typeMetadata.getEmbeddedFieldName() ) ) { | ||
embeddedWithDepthTypeMetadata = typeMetadata; | ||
} | ||
} | ||
|
||
assertNotNull( embeddedWithDepthTypeMetadata ); | ||
assertNotNull( embeddedWithDepthTypeMetadata.getPropertyMetadataForProperty( "name" ) ); | ||
} | ||
|
||
} |