Search in sources :

Example 6 with AutocompleteResult

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

the class GroovyEvaluatorAutocompleteTest method autocompleteMapAfterDot.

@Test
public void autocompleteMapAfterDot() throws Exception {
    String code = "Map myMap = new HashMap<>();\n" + "myMap.";
    // when
    AutocompleteResult autocomplete = groovyEvaluator.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 : AfterClass(org.junit.AfterClass) BaseEvaluator(com.twosigma.beakerx.evaluator.BaseEvaluator) BeforeClass(org.junit.BeforeClass) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.Test) TestGroovyEvaluator(com.twosigma.beakerx.groovy.TestGroovyEvaluator) Collectors(java.util.stream.Collectors) AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test)

Example 7 with AutocompleteResult

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

the class GroovyEvaluatorAutocompleteTest method autocompleteToMethodsForImportedClassesSeparatedBySemicolon.

@Test
public void autocompleteToMethodsForImportedClassesSeparatedBySemicolon() throws Exception {
    String code = "import com.twosigma.beakerx.mimetype.MIMEContainer;" + "import groovy.json.JsonSlurper\n" + "def jsonSlurper = new JsonSlurper()\n" + "def json = jsonSlurper.";
    // when
    AutocompleteResult autocomplete = groovyEvaluator.autocomplete(code, code.length());
    // then
    assertThat(autocomplete.getMatches()).isNotEmpty();
    assertThat(autocomplete.getStartIndex()).isEqualTo(code.length());
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test)

Example 8 with AutocompleteResult

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

the class GroovyEvaluatorAutocompleteTest method shouldReturnAutocompleteForPrintlnWithComment.

@Test
public void shouldReturnAutocompleteForPrintlnWithComment() throws Exception {
    // when
    AutocompleteResult autocomplete = groovyEvaluator.autocomplete("//comment\n" + "System.out.printl\n" + "System.out.printl", 27);
    // then
    assertThat(autocomplete.getMatches()).isNotEmpty();
    assertThat(autocomplete.getStartIndex()).isEqualTo(21);
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test)

Example 9 with AutocompleteResult

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

the class GroovyEvaluatorAutocompleteTest method shouldReturnResultEqualToParamMap.

@Test
public void shouldReturnResultEqualToParamMap() throws Exception {
    String code = "def paramMap = ['abc':1, 'def':2, 'xyz':3]\n" + "println par";
    // when
    AutocompleteResult autocomplete = groovyEvaluator.autocomplete(code, code.length());
    // then
    assertThat(autocomplete.getMatches().get(0)).isEqualToIgnoringCase("paramMap");
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test)

Example 10 with AutocompleteResult

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

the class GroovyEvaluatorAutocompleteTest method shouldReturnResultEqualToPackage.

@Test
public void shouldReturnResultEqualToPackage() throws Exception {
    String code = "pack";
    // when
    AutocompleteResult autocomplete = groovyEvaluator.autocomplete(code, code.length());
    // then
    assertThat(autocomplete.getMatches()).isNotEmpty();
    assertThat(autocomplete.getStartIndex()).isEqualTo(0);
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test)

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