Search in sources :

Example 76 with AutocompleteResult

use of com.twosigma.beakerx.autocomplete.AutocompleteResult in project beakerx by twosigma.

the class JavaEvaluatorAutocompleteTest method shouldAutocompleteToB.

@Test
public void shouldAutocompleteToB() throws Exception {
    String code = "import java.awt.Color;\n" + "System.out.println( Color.B";
    // when
    AutocompleteResult autocomplete = evaluator().autocomplete(code, code.length());
    // then
    assertThat(autocomplete.getMatches()).isNotEmpty();
    assertThat(autocomplete.getStartIndex()).isEqualTo(code.length() - 1);
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test)

Example 77 with AutocompleteResult

use of com.twosigma.beakerx.autocomplete.AutocompleteResult in project beakerx by twosigma.

the class JavaEvaluatorAutocompleteTest method autocompleteMapAfterDot.

@Test
public void autocompleteMapAfterDot() throws Exception {
    String code = "Map myMap = new HashMap<>();\n" + "myMap.";
    // when
    AutocompleteResult autocomplete = evaluator().autocomplete(code, code.length());
    // then
    assertThat(autocomplete.getMatches()).isNotEmpty();
    assertThat(autocomplete.getMatches().stream().filter(x -> x.contains("put")).collect(Collectors.toList())).isNotEmpty();
    assertThat(autocomplete.getStartIndex()).isEqualTo(code.length());
}
Also used : JavaEvaluator(com.twosigma.beakerx.javash.evaluator.JavaEvaluator) AfterClass(org.junit.AfterClass) BaseEvaluator(com.twosigma.beakerx.evaluator.BaseEvaluator) EvaluatorTest.getTestTempFolderFactory(com.twosigma.beakerx.evaluator.EvaluatorTest.getTestTempFolderFactory) BeforeClass(org.junit.BeforeClass) Ignore(org.junit.Ignore) KERNEL_PARAMETERS(com.twosigma.beakerx.evaluator.EvaluatorTest.KERNEL_PARAMETERS) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) TestBeakerCellExecutor.cellExecutor(com.twosigma.beakerx.evaluator.TestBeakerCellExecutor.cellExecutor) Test(org.junit.Test) Collectors(java.util.stream.Collectors) AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test)

Example 78 with AutocompleteResult

use of com.twosigma.beakerx.autocomplete.AutocompleteResult in project beakerx by twosigma.

the class SQLAutocompleteTest method shouldAutocompleteToValues.

@Test
public void shouldAutocompleteToValues() throws Exception {
    // given
    givenColorTable();
    // when
    String code = "INSERT INTO color (id, name, code) VALU";
    AutocompleteResult autocomplete = sqlEvaluator.autocomplete(code, code.length());
    // then
    assertThat(autocomplete.getMatches()).isNotEmpty();
    assertThat(autocomplete.getStartIndex()).isEqualTo(35);
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 79 with AutocompleteResult

use of com.twosigma.beakerx.autocomplete.AutocompleteResult in project beakerx by twosigma.

the class SQLAutocompleteTest method shouldAutocompleteTo_s.

@Test
public void shouldAutocompleteTo_s() throws Exception {
    // when
    AutocompleteResult autocomplete = sqlEvaluator.autocomplete("s", 1);
    // then
    assertThat(autocomplete.getMatches()).isNotEmpty();
    assertThat(autocomplete.getStartIndex()).isEqualTo(0);
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 80 with AutocompleteResult

use of com.twosigma.beakerx.autocomplete.AutocompleteResult in project beakerx by twosigma.

the class ScalaAutocompleteTest method autocomplete_autocompleteResultNotEmpty.

@Test
public void autocomplete_autocompleteResultNotEmpty() throws Exception {
    // when
    AutocompleteResult autocomplete = scalaEvaluator.autocomplete("val numbers = Li", 16);
    // then
    Assertions.assertThat(autocomplete.getMatches()).isNotEmpty();
    Assertions.assertThat(autocomplete.getStartIndex()).isEqualTo(14);
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest)

Aggregations

AutocompleteResult (com.twosigma.beakerx.autocomplete.AutocompleteResult)107 Test (org.junit.Test)102 Ignore (org.junit.Ignore)20 BaseEvaluator (com.twosigma.beakerx.evaluator.BaseEvaluator)10 Collectors (java.util.stream.Collectors)10 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)10 AfterClass (org.junit.AfterClass)10 BeforeClass (org.junit.BeforeClass)10 EvaluatorTest (com.twosigma.beakerx.evaluator.EvaluatorTest)6 KERNEL_PARAMETERS (com.twosigma.beakerx.evaluator.EvaluatorTest.KERNEL_PARAMETERS)6 EvaluatorTest.getTestTempFolderFactory (com.twosigma.beakerx.evaluator.EvaluatorTest.getTestTempFolderFactory)6 TestBeakerCellExecutor.cellExecutor (com.twosigma.beakerx.evaluator.TestBeakerCellExecutor.cellExecutor)6 JavaEvaluator (com.twosigma.beakerx.javash.evaluator.JavaEvaluator)6 KernelTest (com.twosigma.beakerx.KernelTest)4 AutocompleteCandidate (com.twosigma.beakerx.autocomplete.AutocompleteCandidate)4 TestGroovyEvaluator (com.twosigma.beakerx.groovy.TestGroovyEvaluator)4 ArrayList (java.util.ArrayList)4 ANTLRInputStream (org.antlr.v4.runtime.ANTLRInputStream)2 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)2 Lexer (org.antlr.v4.runtime.Lexer)2