}
req = JexFactory.eINSTANCE.createJavaRequirement();
}
String packagePrefix = packageName != null && packageName.length() > 0 ? packageName + "." : "";
req.setText((req instanceof JUnitTest ? "Test " : "") + packagePrefix + testsAnnotation);
JavaClassTester javaClassTester = (JavaClassTester) ensureJavaClass(packageName, testClassName, JexPackage.eINSTANCE.getJavaClassTester());
String[] superClasses = {}, superInterfaces = {};
int pos = testsAnnotation.indexOf(' ');
if (pos >= 0) {
testedClassName = testsAnnotation.substring(0, pos);
testsAnnotation = testsAnnotation.substring(pos + 1);
String EXTENDS_KEYWORD = "extends ", IMPLEMENTS_KEYWORD = "implements ";
int extendsPos = testsAnnotation.indexOf(EXTENDS_KEYWORD), implementsPos = testsAnnotation.indexOf(IMPLEMENTS_KEYWORD);
if (extendsPos >= 0) {
superClasses = parseTypeList(testsAnnotation.substring(extendsPos + EXTENDS_KEYWORD.length(), implementsPos > extendsPos ? implementsPos : testsAnnotation.length()));
}
if (implementsPos >= 0) {
superInterfaces = parseTypeList(testsAnnotation.substring(implementsPos + IMPLEMENTS_KEYWORD.length(), extendsPos > implementsPos ? extendsPos : testsAnnotation.length()));
}
} else {
testedClassName = testsAnnotation;
}
int pos3 = testedClassName.lastIndexOf('.');
if (pos3 >= 0) {
packageName = testedClassName.substring(0, pos3);
testedClassName = testedClassName.substring(pos3 + 1);
}
JavaClass javaClass = ensureJavaClass(packageName, testedClassName, JexPackage.eINSTANCE.getJavaClass());
addAll(javaClass.getSuperclasses(), superClasses);
addAll(javaClass.getSuperclasses(), superInterfaces);
javaClassTester.getTestedElements().add(javaClass);
ExercisePart part = ensureExercisePart(exercise, packageName);
if (req instanceof JUnitTest) {
((JUnitTest) req).setTestRunnable(javaClassTester);
}
req.setJavaElement(javaClassTester); // redundant?