Search in sources :

Example 21 with JavaSource

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);
}
Also used : Scanner(java.util.Scanner) JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Test(org.junit.Test)

Example 22 with JavaSource

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);
}
Also used : Scanner(java.util.Scanner) JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Test(org.junit.Test)

Example 23 with JavaSource

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);
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Test(org.junit.Test)

Example 24 with JavaSource

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);
}
Also used : Scanner(java.util.Scanner) JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Test(org.junit.Test)

Example 25 with JavaSource

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);
}
Also used : Scanner(java.util.Scanner) JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Test(org.junit.Test)

Aggregations

JavaSource (de.strullerbaumann.visualee.source.entity.JavaSource)50 Test (org.junit.Test)44 Dependency (de.strullerbaumann.visualee.dependency.entity.Dependency)31 Scanner (java.util.Scanner)5 DependencyType (de.strullerbaumann.visualee.dependency.entity.DependencyType)3 ArrayList (java.util.ArrayList)3 JsonArrayBuilder (javax.json.JsonArrayBuilder)2 JsonObjectBuilder (javax.json.JsonObjectBuilder)2 ExaminerInject (de.strullerbaumann.visualee.examiner.cdi.ExaminerInject)1 ExaminerProduces (de.strullerbaumann.visualee.examiner.cdi.ExaminerProduces)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 JsonArray (javax.json.JsonArray)1 JsonObject (javax.json.JsonObject)1 Ignore (org.junit.Ignore)1