use of de.strullerbaumann.visualee.source.entity.JavaSource in project visualee by Thomas-S-B.
the class ExaminerTest method testJumpOverJavaToken.
@Test
public void testJumpOverJavaToken() {
JavaSource javaSource;
String sourceCode;
String actual;
String expected;
Scanner scanner;
String currentToken;
javaSource = JavaSourceFactory.getInstance().newJavaSource("TestClass");
sourceCode = "@NotNull(groups = PersistenceConstraint.class)\n" + "private Album album;\n";
javaSource.setSourceCode(sourceCode);
scanner = Examiner.getSourceCodeScanner(javaSource.getSourceCode());
// now @NotNull((groups
currentToken = scanner.next();
expected = "Album";
actual = ExaminerImpl.jumpOverJavaToken(currentToken, scanner);
assertEquals(expected, actual);
javaSource = JavaSourceFactory.getInstance().newJavaSource("TestClass");
sourceCode = "@NotNull((groups = PersistenceConstraint.class) saddas)\n" + "protected Album2 album;\n";
javaSource.setSourceCode(sourceCode);
scanner = Examiner.getSourceCodeScanner(javaSource.getSourceCode());
// now @NotNull((groups
currentToken = scanner.next();
expected = "Album2";
actual = ExaminerImpl.jumpOverJavaToken(currentToken, scanner);
assertEquals(expected, actual);
}
use of de.strullerbaumann.visualee.source.entity.JavaSource in project visualee by Thomas-S-B.
the class ExaminerTest method testJumpOverTokenInsufficientTokens.
@Test(expected = IllegalArgumentException.class)
public void testJumpOverTokenInsufficientTokens() {
JavaSource javaSource;
String sourceCode;
Scanner scanner;
String currentToken;
javaSource = JavaSourceFactory.getInstance().newJavaSource("TestClass");
sourceCode = "public";
javaSource.setSourceCode(sourceCode);
scanner = Examiner.getSourceCodeScanner(javaSource.getSourceCode());
// now public
currentToken = scanner.next();
ExaminerImpl.jumpOverJavaToken(currentToken, scanner);
}
use of de.strullerbaumann.visualee.source.entity.JavaSource in project visualee by Thomas-S-B.
the class ExaminerTest method testGetClassBody.
@Test
public void testGetClassBody() {
JavaSource javaSource = JavaSourceFactory.getInstance().newJavaSource("TestClass");
javaSource.setSourceCode(TestDataProvider.getTestSourceCode());
String expected = TestDataProvider.getTestSourceCodeBody();
String actual = ExaminerImpl.getClassBody(javaSource.getSourceCode());
assertEquals(expected, actual);
}
use of de.strullerbaumann.visualee.source.entity.JavaSource in project visualee by Thomas-S-B.
the class ExaminerTest method testScanAfterQuote.
@Test
public void testScanAfterQuote() {
JavaSource javaSource;
String sourceCode;
String actual;
String expected;
Scanner scanner;
String currentToken;
javaSource = JavaSourceFactory.getInstance().newJavaSource("TestClass");
sourceCode = "out.println(\"<h1>UserTransaction obtained using @Inject</h1>\");\n" + "mytoken";
javaSource.setSourceCode(sourceCode);
scanner = Examiner.getSourceCodeScanner(javaSource.getSourceCode());
// now out.println(\"<h1>UserTransaction
currentToken = scanner.next();
ExaminerImpl.scanAfterQuote(currentToken, scanner);
expected = "mytoken";
actual = scanner.next();
assertEquals(expected, actual);
javaSource = JavaSourceFactory.getInstance().newJavaSource("TestClass");
sourceCode = "out.println(\"<title>UserTransaction obtained using @Inject</title>\");\n" + "out.println(\"<h1>UserTransaction obtained using @Inject</h1>);\n" + "mytoken";
javaSource.setSourceCode(sourceCode);
scanner = Examiner.getSourceCodeScanner(javaSource.getSourceCode());
// now out.println(\"<h1>UserTransaction\"
currentToken = scanner.next();
ExaminerImpl.scanAfterQuote(currentToken, scanner);
expected = "out.println(\"<h1>UserTransaction";
actual = scanner.next();
assertEquals(expected, actual);
javaSource = JavaSourceFactory.getInstance().newJavaSource("TestClass");
sourceCode = "@NotNull((groups = PersistenceConstraint.class) saddas)\n" + "private Album2 album;\n";
javaSource.setSourceCode(sourceCode);
scanner = Examiner.getSourceCodeScanner(javaSource.getSourceCode());
// now @NotNull((groups
currentToken = scanner.next();
ExaminerImpl.scanAfterQuote(currentToken, scanner);
expected = "=";
actual = scanner.next();
assertEquals(expected, actual);
javaSource = JavaSourceFactory.getInstance().newJavaSource("TestClass");
sourceCode = "LOG.log(Level.FINE, \"Added {0} to watch channel {1}\", new Object[]{browserWindow.hashCode(), browserWindow.getChannel()});";
javaSource.setSourceCode(sourceCode);
scanner = Examiner.getSourceCodeScanner(javaSource.getSourceCode());
// LOG.log(Level.FINE,
scanner.next();
// "Added...
currentToken = scanner.next();
ExaminerImpl.scanAfterQuote(currentToken, scanner);
expected = "new";
actual = scanner.next();
assertEquals(expected, actual);
}
use of de.strullerbaumann.visualee.source.entity.JavaSource in project visualee by Thomas-S-B.
the class ExaminerTest method testScanAfterClosedParenthesisInsufficientTokens.
@Test(expected = IllegalArgumentException.class)
public void testScanAfterClosedParenthesisInsufficientTokens() {
JavaSource javaSource;
String sourceCode;
Scanner scanner;
String currentToken;
javaSource = JavaSourceFactory.getInstance().newJavaSource("TestClass");
sourceCode = "@NotNull(groups";
javaSource.setSourceCode(sourceCode);
scanner = Examiner.getSourceCodeScanner(javaSource.getSourceCode());
// now @NotNull((groups
currentToken = scanner.next();
ExaminerImpl.scanAfterClosedParenthesis(currentToken, scanner);
}
Aggregations