blob: 5edb7733acc4c0afb191edabb33474329ace3629 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2007, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0, which accompanies this distribution
* and is available at https://www.eclipse.org/legal/epl-2.0/.
*
* Contributors:
* Oracle - initial API and implementation
******************************************************************************/
package org.eclipse.jpt.jpa.core.tests.internal.resource.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.common.core.resource.java.JavaResourceField;
import org.eclipse.jpt.common.core.resource.java.JavaResourceModel;
import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
import org.eclipse.jpt.common.utility.internal.iterator.IteratorTools;
import org.eclipse.jpt.jpa.core.resource.java.JPA;
import org.eclipse.jpt.jpa.core.resource.java.TransientAnnotation;
@SuppressWarnings("nls")
public class TransientTests extends JpaJavaResourceModelTestCase {
public TransientTests(String name) {
super(name);
}
private ICompilationUnit createTestTransient() throws Exception {
return this.createTestType(new DefaultAnnotationWriter() {
@Override
public Iterator<String> imports() {
return IteratorTools.iterator(JPA.TRANSIENT);
}
@Override
public void appendIdFieldAnnotationTo(StringBuilder sb) {
sb.append("@Transient");
}
});
}
public void testTransient() throws Exception {
ICompilationUnit cu = this.createTestTransient();
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceField = IterableTools.get(resourceType.getFields(), 0);
JavaResourceModel mappingAnnotation = resourceField.getAnnotation(TransientAnnotation.ANNOTATION_NAME);
assertTrue(mappingAnnotation instanceof TransientAnnotation);
}
}