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());
}
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());
}
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);
}
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");
}
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);
}
Aggregations