HHH-17882 test for list of warnings in addSuppressWarningsAnnotation
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
16ebcc427b
commit
31b5af94c1
|
@ -204,7 +204,9 @@ public final class ClassWriter {
|
||||||
final StringBuilder annotation = new StringBuilder("@SuppressWarnings({");
|
final StringBuilder annotation = new StringBuilder("@SuppressWarnings({");
|
||||||
final String[] warnings = context.getSuppressedWarnings();
|
final String[] warnings = context.getSuppressedWarnings();
|
||||||
for (int i = 0; i < warnings.length; i++) {
|
for (int i = 0; i < warnings.length; i++) {
|
||||||
if ( i>0 ) annotation.append(", ");
|
if ( i>0 ) {
|
||||||
|
annotation.append(", ");
|
||||||
|
}
|
||||||
annotation.append('"').append(warnings[i]).append('"');
|
annotation.append('"').append(warnings[i]).append('"');
|
||||||
}
|
}
|
||||||
return annotation.append("})").toString();
|
return annotation.append("})").toString();
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/
|
||||||
|
package org.hibernate.processor.test.supresswarnings;
|
||||||
|
|
||||||
|
import org.hibernate.processor.HibernateProcessor;
|
||||||
|
import org.hibernate.processor.test.util.CompilationTest;
|
||||||
|
import org.hibernate.processor.test.util.WithClasses;
|
||||||
|
import org.hibernate.processor.test.util.WithProcessorOption;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
|
||||||
|
import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Hardy Ferentschik
|
||||||
|
*/
|
||||||
|
public class SuppressExplicitWarningsAnnotationGeneratedTest extends CompilationTest {
|
||||||
|
@Test
|
||||||
|
@WithClasses(TestEntity.class)
|
||||||
|
@WithProcessorOption(key = HibernateProcessor.ADD_SUPPRESS_WARNINGS_ANNOTATION, value = "foo, bar")
|
||||||
|
public void testSuppressedWarningsAnnotationGenerated() {
|
||||||
|
assertMetamodelClassGeneratedFor( TestEntity.class );
|
||||||
|
|
||||||
|
// need to check the source because @SuppressWarnings is not a runtime annotation
|
||||||
|
String metaModelSource = getMetaModelSourceAsString( TestEntity.class );
|
||||||
|
assertTrue(
|
||||||
|
"@SuppressWarnings should be added to the metamodel.",
|
||||||
|
metaModelSource.contains( "@SuppressWarnings({\"foo\", \"bar\"})" )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue