package Ġcom . github . kor ni lo va 2 0 3 . fl ame viewer Ċ Ċ import Ġcom . github . kor ni lo va 2 0 3 . fl ame viewer . Upload File Util . send File Ċ import Ġcom . github . kor ni lo va 2 0 3 . fl ame viewer . server . FILE Ċ import Ġcom . github . kor ni lo va 2 0 3 . fl ame viewer . server . UN DO _ DELETE _ FILE Ċ import Ġcom . intellij . test Framework . fixtures . Base Platform TestCase Ċ import Ġio . netty . handler . codec . http . HttpResponse Status Ċ import Ġorg . jetbrains . ide . BuiltIn Server Manager Ċ import Ġjava . io . File Ċ import Ġjava . net . Http URLConnection Ċ import Ġjava . net . URL Ċ import Ġjava . nio . file . Paths ĊĊ Ċ class ĠDelete File Test Ġ: ĠBase Platform TestCase () Ġ{ ĊĊĠĠĠ Ġoverride Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . setUp () ĊĠĠĠĠĠĠĠ ĠBuilt In Server Manager . getInstance (). waitFor Start () ĊĠĠĠĠĠĠĠ ĠPlugin FileManager . delete All Uploaded Files () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġtest Delete Ser File () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// Ġtest Ġlegacy Ġfunctionality ĊĠĠĠĠĠĠĠ ĠPlugin FileManager . delete All Uploaded Files () ĊĠĠĠĠĠĠĠ Ġval ĠprojectName Ġ= Ġ" my - project " ĊĠĠĠĠĠĠĠ Ġval ĠfileName Ġ= Ġ" file . ser " ĊĠĠĠĠĠĠĠ Ġval Ġfile Ġ= Ġcreate File ( projectName , ĠfileName ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( file . exists ()) ĊĠĠĠĠĠĠĠ ĠassertTrue ( file . isFile ) ĊĊĠĠĠĠĠĠĠ Ġval Ġnew File Ġ= ĠPaths . get ( file . parent File . parent File . toString (), Ġ" uploaded - files ", Ġ" f ier ix ", Ġfile . name ). to File () ĊĊĠĠĠĠĠĠĠ Ġdo Test Delete ( file , ĠfileName ) ĊĊĠĠĠĠĠĠĠ Ġdo Test Undo Delete ( new File , ĠfileName ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġtest Delete Uploaded File () Ġ{ ĊĠĠĠĠĠĠĠ ĠPlugin FileManager . delete All Uploaded Files () ĊĠĠĠĠĠĠĠ Ġval ĠfileName Ġ= Ġ" my - fl ame graph . fl ame graph " ĊĠĠĠĠĠĠĠ Ġsend File ( fileName , Ġ" fun 1 ; fun 2 Ġ 1 ". toByteArray ()) ĊĊĠĠĠĠĠĠĠ Ġval Ġfile Ġ= ĠPlugin FileManager . get LogFile ( fileName ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( file ) Ġ// Ġfile Ġwas Ġsent ĊĠĠĠĠĠĠĠ ĠassertTrue ( file !!. exists ()) ĊĊĠĠĠĠĠĠĠ Ġdo Test Delete ( file , ĠfileName , Ġ" c fl ame graph ") ĊĊĠĠĠĠĠĠĠ Ġdo Test Undo Delete ( file , ĠfileName ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġdo Test Delete ( file : ĠFile , ĠfileName : ĠString , Ġconverter Id : ĠString ? Ġ= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals ( HttpResponse Status . OK . code (), Ġsend Delete File Request ( fileName )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( file . exists ()) ĊĊĠĠĠĠĠĠĠ Ġ/* Ġcheck Ġthat Ġfile Ġwas Ġmode Ġto Ġtemp Ġdirectory Ġfor Ġdeleted Ġfiles Ġ*/ ĊĠĠĠĠĠĠĠ Ġval Ġfile In Deleted Dir Ġ= Ġif Ġ( converter Id Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠPaths . get ( Plugin FileManager . log DirPath . toString (), Ġ" deleted ", Ġconverter Id , ĠfileName ). to File () ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠPaths . get ( Plugin FileManager . log DirPath . toString (), Ġ" deleted ", ĠfileName ). to File () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertTrue ( file In Deleted Dir . exists ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġdo Test Undo Delete ( deleted File : ĠFile , ĠfileName : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġsend Undo Delete Request ( fileName ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( HttpResponse Status . OK . code (), Ġresponse ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( deleted File . exists ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġsend Undo Delete Request ( fileName : ĠString ): ĠInt Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġurl Ġ= ĠURL (" http :// localhost :${ BuiltIn Server Manager . getInstance (). port }$ UN DO _ DELETE _ FILE ") ĊĠĠĠĠĠĠĠ Ġval Ġconnection Ġ= Ġurl . open Connection () Ġas ĠHttp URLConnection ĊĠĠĠĠĠĠĠ Ġconnection . request Method Ġ= Ġ" POST " ĊĊĠĠĠĠĠĠĠ Ġconnection . setRequest Property (" File - Name ", ĠfileName ) ĊĊĠĠĠĠĠĠĠ Ġreturn Ġconnection . response Code ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġsend Delete File Request ( fileName : ĠString ): ĠInt Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġurl Ġ= ĠURL (" http :// localhost :${ BuiltIn Server Manager . getInstance (). port }$ FILE ") ĊĠĠĠĠĠĠĠ Ġval Ġconnection Ġ= Ġurl . open Connection () Ġas ĠHttp URLConnection ĊĠĠĠĠĠĠĠ Ġconnection . request Method Ġ= Ġ" DELETE " ĊĊĠĠĠĠĠĠĠ Ġconnection . setRequest Property (" File - Name ", ĠfileName ) ĊĊĠĠĠĠĠĠĠ Ġreturn Ġconnection . response Code ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠCreates Ġfile Ġas Ġif Ġit Ġwas Ġgenerated Ġduring Ġprofiling ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġprivate Ġfun Ġcreate File ( projectName : ĠString , ĠfileName : ĠString ): ĠFile Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġplugin FileManager Ġ= ĠPlugin FileManager ĊĠĠĠĠĠĠĠ Ġplugin FileManager . delete All Uploaded Files () ĊĊĠĠĠĠĠĠĠ Ġval Ġproject Dir Ġ= ĠPaths . get ( plugin FileManager . log DirPath . toString (), ĠprojectName ). to File () ĊĠĠĠĠĠĠĠ Ġproject Dir . mkdir () ĊĊĠĠĠĠĠĠĠ Ġval Ġfile Ġ= ĠPaths . get ( project Dir . toString (), ĠfileName ). to File () ĊĠĠĠĠĠĠĠ Ġfile . output Stream (). use Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . write (" Some Ġtext ". toByteArray ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġfile ĊĠĠĠ Ġ} Ċ }