use of org.eclipse.n4js.ide.tests.helper.server.AbstractOrganizeImportsTest.TestOrganizeImportsConfiguration in project n4js by eclipse.
the class AbstractOrganizeImportsTest method performTest.
@Override
protected void performTest(Project project, String moduleName, TestOrganizeImportsConfiguration config) throws Exception {
FileURI uri = getFileURIFromModuleName(moduleName);
if (config.expectedIssues.isEmpty()) {
assertNoIssues();
} else {
assertIssues(Collections.singletonMap(uri, config.expectedIssues));
}
TextDocumentIdentifier id = new TextDocumentIdentifier(uri.toString());
Range range = new Range(new Position(0, 0), new Position(0, 0));
CodeActionContext context = new CodeActionContext();
CodeActionParams params = new CodeActionParams(id, range, context);
CompletableFuture<List<Either<Command, CodeAction>>> codeActionFuture = languageServer.codeAction(params);
List<Either<Command, CodeAction>> result = codeActionFuture.join();
Command organizeImportsCommand = result.stream().map(e -> e.isLeft() ? e.getLeft() : e.getRight().getCommand()).filter(cmd -> cmd != null && Objects.equals(cmd.getCommand(), N4JSCommandService.N4JS_ORGANIZE_IMPORTS)).findFirst().orElse(null);
Assert.assertNotNull("code action for organize imports not found", organizeImportsCommand);
ExecuteCommandParams execParams = new ExecuteCommandParams(organizeImportsCommand.getCommand(), organizeImportsCommand.getArguments());
CompletableFuture<Object> execFuture = languageServer.executeCommand(execParams);
execFuture.join();
joinServerRequests();
assertContentOfFileOnDisk(uri, config.expectedCode);
}
Aggregations