/*********************************************************************
 * Copyright (c) 2020 Red Hat, Inc.
 *
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 **********************************************************************/ import 'reflect-metadata' ; import { CLASSES } from '../../inversify.types' ; import { LanguageServerTests } from '../../testsLibrary/LanguageServerTests' ; import { e2eContainer } from '../../inversify.config' ; import { CodeExecutionTests } from '../../testsLibrary/CodeExecutionTests' ; import { ProjectAndFileTests } from '../../testsLibrary/ProjectAndFileTests' ; import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests' ; import CheReporter from '../../driver/CheReporter' ; const workspaceHandlingTests = e2eContainer . get ( CLASSES . WorkspaceHandlingTests ) ; const projectAndFileTests = e2eContainer . get ( CLASSES . ProjectAndFileTests ) ; const commonLanguageServerTests = e2eContainer . get ( CLASSES . LanguageServerTests ) ; const codeExecutionTests = e2eContainer . get ( CLASSES . CodeExecutionTests ) ; const stack = 'Java Spring Boot' ; const workspaceSampleName = 'java-web-spring' ; const workspaceRootFolderName = 'src' ; const fileFolderPath = `${ workspaceSampleName }/${ workspaceRootFolderName }/main/java/org/springframework/samples/petclinic` ; const tabTitle = 'PetClinicApplication.java' ; const codeNavigationClassName = 'SpringApplication.class' ; const buildTaskName = 'maven build' ; const runTaskName = 'run webapp' ; const runTaskExpectedDialogue = 'Process 8080-tcp is now listening on port 8080. Open it ?' ; let workspaceName ; suite ( `${ stack } test` , async ( ) => { suite ( `Create ${ stack } workspace` , async ( ) => { workspaceHandlingTests . createAndOpenWorkspace ( stack ) ; test ( 'Register running workspace' , async ( ) => { workspaceName = WorkspaceHandlingTests . getWorkspaceName ( ) ; CheReporter . registerRunningWorkspace ( workspaceName ) ; } ) ; projectAndFileTests . waitWorkspaceReadiness ( workspaceSampleName , workspaceRootFolderName , false ) ; } ) ; suite ( 'Test opening file' , async ( ) => { projectAndFileTests . openFile ( fileFolderPath , tabTitle ) ; } ) ; suite ( 'Validation of workspace build' , async ( ) => { codeExecutionTests . runTask ( buildTaskName , 720000 ) ; codeExecutionTests . closeTerminal ( buildTaskName ) ; } ) ; suite ( 'Validation of workspace execution' , async ( ) => { codeExecutionTests . runTaskWithNotification ( runTaskName , runTaskExpectedDialogue , 120000 ) ; codeExecutionTests . closeTerminal ( runTaskName ) ; } ) ; suite ( 'Language server validation' , async ( ) => { commonLanguageServerTests . autocomplete ( tabTitle , 32 , 56 , 'args : String[]' ) ; commonLanguageServerTests . errorHighlighting ( tabTitle , 'error_text' , 30 ) ; commonLanguageServerTests . goToImplementations ( tabTitle , 32 , 23 , codeNavigationClassName ) ; commonLanguageServerTests . suggestionInvoking ( tabTitle , 32 , 23 , 'run(Class<?>' ) ; } ) ; suite ( 'Stopping and deleting the workspace' , async ( ) => { test ( `Stop and remowe workspace` , async ( ) => { await workspaceHandlingTests . stopAndRemoveWorkspace ( workspaceName ) ; } ) ; } ) ; } ) ;