blob: 3443cb6ac67e99fa79d6882e3db35716fb1fad65 [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.VersionAnnotation;
@SuppressWarnings("nls")
public class VersionTests extends JpaJavaResourceModelTestCase {
public VersionTests(String name) {
super(name);
}
private ICompilationUnit createTestVersion() throws Exception {
return this.createTestType(new DefaultAnnotationWriter() {
@Override
public Iterator<String> imports() {
return IteratorTools.iterator(JPA.VERSION);
}
@Override
public void appendIdFieldAnnotationTo(StringBuilder sb) {
sb.append("@Version");
}
});
}
public void testVersion() throws Exception {
ICompilationUnit cu = this.createTestVersion();
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceField = IterableTools.get(resourceType.getFields(), 0);
JavaResourceModel mappingAnnotation = resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME);
assertTrue(mappingAnnotation instanceof VersionAnnotation);
}
}