// ĠCopyright Ġ 2 0 0 0 - 2 0 2 1 ĠJetBrains Ġs . r . o . Ġand Ġcontributors . ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense Ġthat Ġcan Ġbe Ġfound Ġin Ġthe ĠLICENSE Ġfile . Ċ package Ġcom . intellij . openapi . application Ċ Ċ import Ġcom . intellij . configuration Store . get Per Os Settings Storage Folder Name Ċ import Ġcom . intellij . diagnostic . VM Options Ċ import Ġcom . intellij . ide . plugins . Plugin Builder Ċ import Ġcom . intellij . ide . startup . Startup Action Script Manager Ċ import Ġcom . intellij . ide . util . Properties Component Ċ import Ġcom . intellij . openapi . components . state Store Ċ import Ġcom . intellij . openapi . diagnostic . logger Ċ import Ġcom . intellij . openapi . extensions . Plugin Id Ċ import Ġcom . intellij . openapi . util . Build Number Ċ import Ġcom . intellij . openapi . util . System Info Ċ import Ġcom . intellij . openapi . util . Throwable NotNull Bi Function Ċ import Ġcom . intellij . openapi . util . registry . Registry Ċ import Ġcom . intellij . test Framework . Platform TestUtil . use AppConfig Dir Ċ import Ġcom . intellij . util . io . create Directories Ċ import Ġcom . intellij . util . io . isDirectory Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . assertj . core . api . Condition Ċ import Ġorg . junit . Ass ume . assume True Ċ import Ġorg . junit . Test Ċ import Ġjava . io . IOException Ċ import Ġjava . nio . charset . StandardCharsets Ċ import Ġjava . nio . file . Files Ċ import Ġjava . nio . file . Path Ċ import Ġjava . util . function . Predicate Ċ Ċ class ĠConfig Import Helper Test Ġ: ĠConfig Import Helper Base Test () Ġ{ ĊĠ Ġprivate Ġval ĠLOG Ġ= Ġlogger < Config Import Helper Test >() ĊĊĠ Ġ@ Test Ġfun Ġ` config Ġdirectory Ġis Ġvalid Ġfor Ġimport `() Ġ{ ĊĠĠĠ ĠProperties Component . getInstance (). setValue (" property . Config Import Helper Test ", Ġtrue ) ĊĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠ Ġuse AppConfig Dir Ġ{ ĊĠĠĠĠĠĠĠ Ġrun Blocking Ġ{ ĠApplication Manager . getApplication (). state Store . save ( force Saving All Settings Ġ= Ġtrue ) Ġ} ĊĊĠĠĠĠĠĠĠ Ġ@ Suppress (" Use Property Access Syntax ") ĊĠĠĠĠĠĠĠ ĠassertThat ( Path Manager . getConfig Dir ()) ĊĠĠĠĠĠĠĠĠĠ Ġ. isNotEmpty Directory () ĊĠĠĠĠĠĠĠĠĠ Ġ. satisf ies ( Condition ( Predicate Ġ{ ĠConfig Import Helper . is Config Directory ( it ) Ġ}, Ġ" A Ġvalid Ġconfig Ġdirectory ")) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġfinally Ġ{ ĊĠĠĠĠĠ ĠProperties Component . getInstance (). un setValue (" property . Config Import Helper Test ") ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` find Ġpre - migration Ġconfig Ġdirectory `() Ġ{ ĊĠĠĠ Ġval Ġcfg 2 0 1 Ġ= Ġcreate Config Dir (" 2 0 2 0 . 1 ", Ġmodern Ġ= Ġfalse ) ĊĠĠĠ Ġval Ġnew ConfigPath Ġ= Ġcreate Config Dir (" 2 0 2 0 . 1 ", Ġmodern Ġ= Ġtrue ) ĊĠĠĠ ĠassertThat ( find Config Directories ( new ConfigPath )). contains Exactly ( cfg 2 0 1 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` find Ġboth Ġh istoric Ġand Ġcurrent Ġconfig Ġdirectories `() Ġ{ ĊĠĠĠ Ġval Ġcfg 1 5 Ġ= Ġcreate Config Dir (" 1 5 ", Ġstorage TS Ġ= Ġ 1 4 4 8 9 2 8 0 0 0 0 0 0 ) ĊĠĠĠ Ġval Ġcfg 1 9 3 Ġ= Ġcreate Config Dir (" 2 0 1 9 . 1 ", Ġstorage TS Ġ= Ġ 1 5 7 4 8 4 5 2 0 0 0 0 0 ) ĊĠĠĠ Ġval Ġcfg 2 0 1 Ġ= Ġcreate Config Dir (" 2 0 2 0 . 1 ", Ġstorage TS Ġ= Ġ 1 5 8 5 7 3 1 6 0 0 0 0 0 ) ĊĊĠĠĠ Ġval Ġnew ConfigPath Ġ= Ġcreate Config Dir (" 2 0 2 0 . 2 ") ĊĠĠĠ ĠassertThat ( find Config Directories ( new ConfigPath )). contains Exactly ( cfg 2 0 1 , Ġcfg 1 9 3 , Ġcfg 1 5 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` find Ġrecent Ġconfig Ġdirectory `() Ġ{ ĊĠĠĠ Ġval Ġcfg 2 0 1 Ġ= Ġcreate Config Dir (" 2 0 2 0 . 1 ", Ġstorage TS Ġ= Ġ 1 0 0 ) ĊĠĠĠ Ġval Ġcfg 2 1 1 Ġ= Ġcreate Config Dir (" 2 0 2 1 . 1 ", Ġstorage TS Ġ= Ġ 2 0 0 ) ĊĠĠĠ Ġval Ġcfg 2 2 1 Ġ= Ġcreate Config Dir (" 2 0 2 2 . 1 ", Ġstorage TS Ġ= Ġ 3 0 0 ) ĊĊĠĠĠ Ġval Ġnew ConfigPath Ġ= Ġcreate Config Dir (" 2 0 2 2 . 3 ") ĊĠĠĠ ĠassertThat ( find Config Directories ( new ConfigPath )). contains Exactly ( cfg 2 2 1 , Ġcfg 2 1 1 , Ġcfg 2 0 1 ) ĊĊĠĠĠ Ġwrite Storage File ( cfg 2 1 1 , Ġ 4 0 0 ) ĊĠĠĠ ĠassertThat ( find Config Directories ( new ConfigPath )). contains Exactly ( cfg 2 1 1 , Ġcfg 2 2 1 , Ġcfg 2 0 1 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` sort Ġif Ġno Ġanchor Ġfiles `() Ġ{ ĊĠĠĠ Ġval Ġcfg 2 0 1 Ġ= Ġcreate Config Dir (" 2 0 2 0 . 1 ") ĊĠĠĠ Ġval Ġcfg 2 1 1 Ġ= Ġcreate Config Dir (" 2 0 2 1 . 1 ") ĊĠĠĠ Ġval Ġcfg 2 2 1 Ġ= Ġcreate Config Dir (" 2 0 2 2 . 1 ") ĊĊĠĠĠ Ġval Ġnew ConfigPath Ġ= Ġcreate Config Dir (" 2 0 2 2 . 3 ") ĊĠĠĠ ĠassertThat ( find Config Directories ( new ConfigPath )). contains Exactly ( cfg 2 2 1 , Ġcfg 2 1 1 , Ġcfg 2 0 1 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` sort Ġsome Ġreal Ġh istoric Ġconfig Ġdirs `() Ġ{ ĊĠĠĠ Ġval Ġcfg 1 0 Ġ= Ġcreate Config Dir (" 1 0 ", Ġproduct Ġ= Ġ" Data G rip ", Ġstorage TS Ġ= Ġ 1 4 5 5 0 3 5 0 9 6 0 0 0 ) ĊĠĠĠ Ġval Ġcfg 1 6 2 Ġ= Ġcreate Config Dir (" 2 0 1 6 . 2 ", Ġproduct Ġ= Ġ" Data G rip ", Ġstorage TS Ġ= Ġ 1 4 6 6 3 4 5 6 6 2 0 0 0 ) ĊĠĠĠ Ġval Ġcfg 1 6 1 Ġ= Ġcreate Config Dir (" 2 0 1 6 . 1 ", Ġproduct Ġ= Ġ" Data G rip ", Ġstorage TS Ġ= Ġ 1 4 8 5 4 6 0 7 1 9 0 0 0 ) ĊĠĠĠ Ġval Ġcfg 1 7 1 Ġ= Ġcreate Config Dir (" 2 0 1 7 . 1 ", Ġproduct Ġ= Ġ" Data G rip ", Ġstorage TS Ġ= Ġ 1 5 0 3 0 0 6 7 6 3 0 0 0 ) ĊĠĠĠ Ġval Ġcfg 1 7 2 Ġ= Ġcreate Config Dir (" 2 0 1 7 . 2 ", Ġproduct Ġ= Ġ" Data G rip ", Ġstorage TS Ġ= Ġ 1 5 1 0 8 6 6 4 9 2 0 0 0 ) ĊĠĠĠ Ġval Ġcfg 1 6 3 Ġ= Ġcreate Config Dir (" 2 0 1 6 . 3 ", Ġproduct Ġ= Ġ" Data G rip ", Ġstorage TS Ġ= Ġ 1 5 2 0 8 6 9 0 0 9 0 0 0 ) ĊĠĠĠ Ġval Ġcfg 1 8 1 Ġ= Ġcreate Config Dir (" 2 0 1 8 . 1 ", Ġproduct Ġ= Ġ" Data G rip ", Ġstorage TS Ġ= Ġ 1 5 3 1 2 3 8 0 4 4 0 0 0 ) ĊĠĠĠ Ġval Ġcfg 1 8 3 Ġ= Ġcreate Config Dir (" 2 0 1 8 . 3 ", Ġproduct Ġ= Ġ" Data G rip ", Ġstorage TS Ġ= Ġ 1 5 4 5 8 4 4 5 2 3 0 0 0 ) ĊĠĠĠ Ġval Ġcfg 1 8 2 Ġ= Ġcreate Config Dir (" 2 0 1 8 . 2 ", Ġproduct Ġ= Ġ" Data G rip ", Ġstorage TS Ġ= Ġ 1 5 4 8 0 7 6 6 3 5 0 0 0 ) ĊĠĠĠ Ġval Ġcfg 1 9 1 Ġ= Ġcreate Config Dir (" 2 0 1 9 . 1 ", Ġproduct Ġ= Ġ" Data G rip ", Ġstorage TS Ġ= Ġ 1 5 4 8 2 2 5 5 0 5 0 0 0 ) ĊĠĠĠ Ġval Ġcfg 1 7 3 Ġ= Ġcreate Config Dir (" 2 0 1 7 . 3 ", Ġproduct Ġ= Ġ" Data G rip ", Ġstorage TS Ġ= Ġ 1 5 4 9 0 9 2 3 2 2 0 0 0 ) ĊĊĠĠĠ Ġval Ġnew ConfigPath Ġ= Ġcreate Config Dir (" 2 0 2 0 . 1 ", Ġproduct Ġ= Ġ" Data G rip ") ĊĠĠĠ ĠassertThat ( find Config Directories ( new ConfigPath )). contains Exactly ( ĊĠĠĠĠĠ Ġcfg 1 7 3 , Ġcfg 1 9 1 , Ġcfg 1 8 2 , Ġcfg 1 8 3 , Ġcfg 1 8 1 , Ġcfg 1 6 3 , Ġcfg 1 7 2 , Ġcfg 1 7 1 , Ġcfg 1 6 1 , Ġcfg 1 6 2 , Ġcfg 1 0 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` set Ġkey map Ġ- Ġold Ġversion `() Ġ{ ĊĠĠĠ Ġdo Key Map Test (" 2 0 1 6 . 4 ", Ġis Migration Expected Ġ= Ġtrue ) ĊĠĠĠ Ġdo Key Map Test (" 2 0 1 9 . 1 ", Ġis Migration Expected Ġ= Ġtrue ) ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` set Ġkey map Ġ- Ġnew Ġversion `() Ġ{ ĊĠĠĠ Ġdo Key Map Test (" 2 0 1 9 . 2 ", Ġis Migration Expected Ġ= Ġfalse ) ĊĠĠĠ Ġdo Key Map Test (" 2 0 1 9 . 3 ", Ġis Migration Expected Ġ= Ġfalse ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġdo Key Map Test ( version : ĠString , Ġis Migration Expected : ĠBoolean ) Ġ{ ĊĠĠĠ Ġassume True (" macOS - only ", ĠSystem Info . is Mac ) ĊĊĠĠĠ Ġval Ġold Config Dir Ġ= Ġcreate Config Dir ( version , Ġproduct Ġ= Ġ" Data G rip ") ĊĠĠĠ Ġval Ġnew Config Dir Ġ= Ġcreate Config Dir (" 2 0 1 9 . 2 ", Ġproduct Ġ= Ġ" Data G rip ") ĊĠĠĠ ĠConfig Import Helper . set Key map IfNeeded ( old Config Dir , Ġnew Config Dir , ĠLOG ) ĊĊĠĠĠ Ġval Ġoption File Ġ= Ġnew Config Dir . resolve ("${ Path Manager . OPTIONS _ DIRECTORY }/${ get Per Os Settings Storage Folder Name () }/ keymap . xml ") ĊĠĠĠ Ġif Ġ( is Migration Expected ) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( option File ). using Charset ( StandardCharsets . UTF _ 8 ). has Content (""" ĊĠĠĠĠĠĠĠ Ġ< application > ĊĠĠĠĠĠĠĠĠĠ Ġ< component Ġname =" Key map Manager "> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ< active _ keymap Ġname =" Mac ĠOS ĠX " Ġ/> ĊĠĠĠĠĠĠĠĠĠ Ġ</ component > ĊĠĠĠĠĠĠĠ Ġ</ application > ĊĠĠĠĠĠ Ġ""" . trim Indent ()) ĊĠĠĠ Ġ} ĊĠĠĠ Ġelse Ġ{ ĊĠĠĠĠĠ ĠassertThat ( option File ). does NotExist () ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` migrate Ġplugins Ġto Ġempty Ġdirectory `() Ġ{ ĊĠĠĠ Ġval Ġold Config Dir Ġ= Ġlocal TempDir . new Directory (" old Config "). to Path () ĊĠĠĠ Ġval Ġold Plugins Dir Ġ= ĠFiles . create Directories ( old Config Dir . resolve (" plugins ")) ĊĠĠĠ ĠPlugin Builder (). depends (" com . intellij . modules . lang "). build Jar ( old Plugins Dir . resolve (" my - plugin . jar ")) ĊĊĠĠĠ Ġval Ġnew Config Dir Ġ= Ġlocal TempDir . new Directory (" new Config "). to Path () ĊĠĠĠ Ġval Ġnew Plugins Dir Ġ= Ġnew Config Dir . resolve (" plugins ") ĊĊĠĠĠ Ġval Ġoptions Ġ= ĠConfig Import Helper . Config Import Options ( LOG ) ĊĠĠĠ Ġoptions . headless Ġ= Ġtrue ĊĠĠĠ ĠConfig Import Helper . do Import ( old Config Dir , Ġnew Config Dir , Ġnull , Ġold Plugins Dir , Ġnew Plugins Dir , Ġoptions ) ĊĠĠĠ ĠassertThat ( new Plugins Dir ). isDirectory Containing Ġ{ Ġit . fileName . toString () Ġ== Ġ" my - plugin . jar " Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` download Ġincompatible Ġplugin `() Ġ{ ĊĠĠĠ Ġval Ġold Config Dir Ġ= Ġlocal TempDir . new Directory (" old Config "). to Path () ĊĠĠĠ Ġval Ġold Plugins Dir Ġ= ĠFiles . create Directories ( old Config Dir . resolve (" plugins ")) ĊĠĠĠ Ġval Ġold Builder Ġ= ĠPlugin Builder () ĊĠĠĠĠĠ Ġ. depends (" com . intellij . modules . lang ") ĊĠĠĠĠĠ Ġ. until Build (" 1 9 3 . 1 ") ĊĠĠĠĠĠ Ġ. build Jar ( old Plugins Dir . resolve (" my - plugin . jar ")) ĊĊĠĠĠ Ġval Ġnew Config Dir Ġ= Ġlocal TempDir . new Directory (" new Config "). to Path () ĊĠĠĠ Ġval Ġnew Plugins Dir Ġ= Ġnew Config Dir . resolve (" plugins ") ĊĠĠĠ ĠRegistry . get (" marketplace . certificate . signature . check "). setValue ( false , Ġtest Root Disposable ) Ġ// Ġskip Ġverify ing Ġplugin Ġcertificates ĊĠĠĠ Ġval Ġoptions Ġ= ĠConfig Import Helper . Config Import Options ( LOG ) ĊĠĠĠ Ġoptions . headless Ġ= Ġtrue ĊĠĠĠ Ġoptions . compatible Build Number Ġ= ĠBuild Number . fromString (" 2 0 1 . 1 ") ĊĠĠĠ Ġoptions . download Function Ġ= ĠThrowable NotNull Bi Function Ġ{ Ġ_, Ġ_ Ġ-> ĊĠĠĠĠĠ Ġval Ġpath Ġ= Ġlocal TempDir . new Directory (" plugin Temp ") ĊĠĠĠĠĠĠĠ Ġ. to Path () ĊĠĠĠĠĠĠĠ Ġ. resolve (" my - plugin - new . jar ") ĊĠĠĠĠĠ ĠPlugin Builder () ĊĠĠĠĠĠĠĠ Ġ. id ( old Builder . id ) ĊĠĠĠĠĠĠĠ Ġ. build Jar ( path ) ĊĠĠĠĠĠ Ġpath . to File () ĊĠĠĠ Ġ} ĊĠĠĠ ĠConfig Import Helper . do Import ( old Config Dir , Ġnew Config Dir , Ġnull , Ġold Plugins Dir , Ġnew Plugins Dir , Ġoptions ) ĊĠĠĠ ĠassertThat ( new Plugins Dir ). isDirectory Containing Ġ{ Ġit . fileName . toString () Ġ== Ġ" my - plugin - new . jar " Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` keep Ġincompatible Ġplugin Ġif Ġcan 't Ġdownload Ġcompatible `() Ġ{ ĊĠĠĠ Ġval Ġold Config Dir Ġ= Ġlocal TempDir . new Directory (" old Config "). to Path () ĊĠĠĠ Ġval Ġold Plugins Dir Ġ= ĠFiles . create Directories ( old Config Dir . resolve (" plugins ")) ĊĠĠĠ ĠPlugin Builder () ĊĠĠĠĠĠ Ġ. until Build (" 1 9 3 . 1 ") ĊĠĠĠĠĠ Ġ. build Jar ( old Plugins Dir . resolve (" my - plugin . jar ")) ĊĊĠĠĠ Ġval Ġnew Config Dir Ġ= Ġlocal TempDir . new Directory (" new Config "). to Path () ĊĠĠĠ Ġval Ġnew Plugins Dir Ġ= Ġnew Config Dir . resolve (" plugins ") ĊĊĠĠĠ Ġval Ġoptions Ġ= ĠConfig Import Helper . Config Import Options ( LOG ) ĊĠĠĠ Ġoptions . headless Ġ= Ġtrue ĊĠĠĠ Ġoptions . compatible Build Number Ġ= ĠBuild Number . fromString (" 2 0 1 . 1 ") ĊĠĠĠ Ġoptions . download Function Ġ= ĠThrowable NotNull Bi Function Ġ{ Ġ_, Ġ_ Ġ-> Ġthrow ĠIOException (" 4 0 4 ") Ġ} ĊĠĠĠ ĠConfig Import Helper . do Import ( old Config Dir , Ġnew Config Dir , Ġnull , Ġold Plugins Dir , Ġnew Plugins Dir , Ġoptions ) ĊĠĠĠ ĠassertThat ( new Plugins Dir ). isDirectory Containing Ġ{ Ġit . fileName . toString () Ġ== Ġ" my - plugin . jar " Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` skip Ġbundled Ġplugins `() Ġ{ ĊĠĠĠ Ġval Ġold Config Dir Ġ= Ġlocal TempDir . new Directory (" old Config "). to Path () ĊĠĠĠ Ġval Ġold Plugins Dir Ġ= ĠFiles . create Directories ( old Config Dir . resolve (" plugins ")) ĊĠĠĠ Ġval Ġold Bund led Plugins Dir Ġ= Ġlocal TempDir . new Directory (" old Bund led "). to Path () ĊĠĠĠ Ġval Ġbundled Builder Ġ= ĠPlugin Builder (). version (" 1 . 1 "). build Jar ( old Bund led Plugins Dir . resolve (" my - plugin - bund led . jar ")) ĊĠĠĠ ĠPlugin Builder () ĊĠĠĠĠĠ Ġ. id ( bund led Builder . id ) ĊĠĠĠĠĠ Ġ. version (" 1 . 0 ") ĊĠĠĠĠĠ Ġ. build Jar ( old Plugins Dir . resolve (" my - plugin . jar ")) ĊĊĠĠĠ Ġval Ġnew Config Dir Ġ= Ġlocal TempDir . new Directory (" new Config "). to Path () ĊĠĠĠ Ġval Ġnew Plugins Dir Ġ= Ġnew Config Dir . resolve (" plugins ") ĊĊĠĠĠ Ġval Ġoptions Ġ= ĠConfig Import Helper . Config Import Options ( LOG ) ĊĠĠĠ Ġoptions . headless Ġ= Ġtrue ĊĠĠĠ Ġoptions . bund led Plugin Path Ġ= Ġold Bund led Plugins Dir ĊĠĠĠ ĠConfig Import Helper . do Import ( old Config Dir , Ġnew Config Dir , Ġnull , Ġold Plugins Dir , Ġnew Plugins Dir , Ġoptions ) ĊĠĠĠ ĠassertThat ( new Plugins Dir ). does NotExist () ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` skip Ġbroken Ġplugins `() Ġ{ ĊĠĠĠ Ġval Ġold Config Dir Ġ= Ġlocal TempDir . new Directory (" old Config "). to Path () ĊĠĠĠ Ġval Ġold Plugins Dir Ġ= ĠFiles . create Directories ( old Config Dir . resolve (" plugins ")) ĊĠĠĠ Ġval Ġbuilder Ġ= ĠPlugin Builder () ĊĠĠĠĠĠ Ġ. version (" 1 . 0 ") ĊĠĠĠĠĠ Ġ. build Jar ( old Plugins Dir . resolve (" my - plugin . jar ")) ĊĊĠĠĠ Ġval Ġnew Config Dir Ġ= Ġlocal TempDir . new Directory (" new Config "). to Path () ĊĠĠĠ Ġval Ġnew Plugins Dir Ġ= Ġnew Config Dir . resolve (" plugins ") ĊĊĠĠĠ Ġval Ġoptions Ġ= ĠConfig Import Helper . Config Import Options ( LOG ) ĊĠĠĠ Ġoptions . headless Ġ= Ġtrue ĊĠĠĠ Ġoptions . broken Plugin Versions Ġ= Ġmap Of ( Plugin Id . getId ( builder . id ) Ġto Ġset Of (" 1 . 0 ")) ĊĊĠĠĠ ĠConfig Import Helper . do Import ( old Config Dir , Ġnew Config Dir , Ġnull , Ġold Plugins Dir , Ġnew Plugins Dir , Ġoptions ) ĊĠĠĠ ĠassertThat ( new Plugins Dir ). does NotExist () ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` skip Ġpending Ġupgrades `() Ġ{ ĊĠĠĠ Ġval Ġold Config Dir Ġ= Ġlocal TempDir . new Directory (" old / config "). to Path () ĊĠĠĠ Ġval Ġold Plugins Dir Ġ= ĠFiles . create Directories ( old Config Dir . resolve (" plugins ")) ĊĠĠĠ Ġval Ġold Plugins TempDir Ġ= Ġlocal TempDir . new Directory (" old / system / plugins "). to Path () ĊĊĠĠĠ Ġval Ġtemp Path Ġ= Ġold Plugins TempDir . resolve (" my - plugin . jar ") ĊĠĠĠ Ġval Ġtemp Builder Ġ= ĠPlugin Builder () ĊĠĠĠĠĠ Ġ. version (" 1 . 1 ") ĊĠĠĠĠĠ Ġ. build Jar ( temp Path ) ĊĊĠĠĠ Ġval Ġcommands Ġ= ĠlistOf ( Startup Action Script Manager . Copy Command ( temp Path , Ġold Plugins Dir . resolve (" my - plugin - 1 . 1 . jar "))) ĊĠĠĠ ĠStartup Action Script Manager . save Action Script ( commands , Ġold Plugins TempDir . resolve ( Startup Action Script Manager . ACTION _ SCRIPT _ FILE )) ĊĊĠĠĠ ĠPlugin Builder () ĊĠĠĠĠĠ Ġ. id ( temp Builder . id ) ĊĠĠĠĠĠ Ġ. version (" 1 . 0 ") ĊĠĠĠĠĠ Ġ. build Jar ( old Plugins Dir . resolve (" my - plugin - 1 . 0 . jar ")) ĊĊĠĠĠ Ġval Ġnew Config Dir Ġ= Ġlocal TempDir . new Directory (" new Config "). to Path () ĊĠĠĠ Ġval Ġnew Plugins Dir Ġ= Ġnew Config Dir . resolve (" plugins ") ĊĊĠĠĠ Ġval Ġoptions Ġ= ĠConfig Import Helper . Config Import Options ( LOG ) ĊĠĠĠ Ġoptions . headless Ġ= Ġtrue ĊĠĠĠ ĠConfig Import Helper . do Import ( old Config Dir , Ġnew Config Dir , Ġnull , Ġold Plugins Dir , Ġnew Plugins Dir , Ġoptions ) ĊĠĠĠ ĠassertThat ( new Plugins Dir ) ĊĠĠĠĠĠ Ġ. isDirectory Containing Ġ{ Ġit . fileName . toString () Ġ== Ġ" my - plugin - 1 . 1 . jar " Ġ} ĊĠĠĠĠĠ Ġ. isDirectory Not Containing Ġ{ Ġit . fileName . toString () Ġ== Ġ" my - plugin - 1 . 0 . jar " Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` do Ġnot Ġdownload Ġupdates Ġfor Ġplugins Ġwith Ġpending Ġupdates `() Ġ{ ĊĠĠĠ Ġval Ġold Config Dir Ġ= Ġlocal TempDir . new Directory (" old / config "). to Path () ĊĠĠĠ Ġval Ġold Plugins Dir Ġ= ĠFiles . create Directories ( old Config Dir . resolve (" plugins ")) ĊĠĠĠ Ġval Ġold Plugins TempDir Ġ= Ġlocal TempDir . new Directory (" old / system / plugins "). to Path () ĊĊĠĠĠ Ġval Ġtemp Path Ġ= Ġold Plugins TempDir . resolve (" my - plugin . jar ") ĊĠĠĠ Ġval Ġtemp Builder Ġ= ĠPlugin Builder () ĊĠĠĠĠĠ Ġ. version (" 1 . 1 ") ĊĠĠĠĠĠ Ġ. build Jar ( temp Path ) ĊĊĠĠĠ Ġval Ġcommands Ġ= ĠlistOf ( Startup Action Script Manager . Copy Command ( temp Path , Ġold Plugins Dir . resolve (" my - plugin - 1 . 1 . jar "))) ĊĠĠĠ ĠStartup Action Script Manager . save Action Script ( commands , Ġold Plugins TempDir . resolve ( Startup Action Script Manager . ACTION _ SCRIPT _ FILE )) ĊĊĠĠĠ ĠPlugin Builder () ĊĠĠĠĠĠ Ġ. id ( temp Builder . id ) ĊĠĠĠĠĠ Ġ. version (" 1 . 0 ") ĊĠĠĠĠĠ Ġ. until Build (" 1 9 3 . 1 ") ĊĠĠĠĠĠ Ġ. build Jar ( old Plugins Dir . resolve (" my - plugin - 1 . 0 . jar ")) ĊĊĠĠĠ Ġval Ġnew Config Dir Ġ= Ġlocal TempDir . new Directory (" new Config "). to Path () ĊĠĠĠ Ġval Ġnew Plugins Dir Ġ= Ġnew Config Dir . resolve (" plugins ") ĊĊĠĠĠ Ġval Ġoptions Ġ= ĠConfig Import Helper . Config Import Options ( LOG ) ĊĠĠĠ Ġoptions . headless Ġ= Ġtrue ĊĠĠĠ Ġoptions . compatible Build Number Ġ= ĠBuild Number . fromString (" 2 0 1 . 1 ") ĊĠĠĠ Ġoptions . download Function Ġ= ĠThrowable NotNull Bi Function Ġ{ Ġ_, Ġ_ Ġ-> Ġthrow ĠAssertionError (" No Ġfile Ġdownload Ġshould Ġbe Ġrequested ") Ġ} ĊĠĠĠ ĠConfig Import Helper . do Import ( old Config Dir , Ġnew Config Dir , Ġnull , Ġold Plugins Dir , Ġnew Plugins Dir , Ġoptions ) ĊĠĠĠ ĠassertThat ( new Plugins Dir ) ĊĠĠĠĠĠ Ġ. isDirectory Containing Ġ{ Ġit . fileName . toString () Ġ== Ġ" my - plugin - 1 . 1 . jar " Ġ} ĊĠĠĠĠĠ Ġ. isDirectory Not Containing Ġ{ Ġit . fileName . toString () Ġ== Ġ" my - plugin - 1 . 0 . jar " Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` skip Ġpending Ġupgrades Ġfor Ġplugin Ġzip s `() Ġ{ ĊĠĠĠ Ġval Ġold Config Dir Ġ= Ġlocal TempDir . new Directory (" old / config "). to Path () ĊĠĠĠ Ġval Ġold Plugins Dir Ġ= ĠFiles . create Directories ( old Config Dir . resolve (" plugins ")) ĊĠĠĠ Ġval Ġold Plugins TempDir Ġ= Ġlocal TempDir . new Directory (" old / system / plugins "). to Path () ĊĊĠĠĠ Ġval Ġtemp Path Ġ= Ġold Plugins TempDir . resolve (" my - plugin . zip ") ĊĠĠĠ Ġval Ġtemp Builder Ġ= ĠPlugin Builder () ĊĠĠĠĠĠ Ġ. version (" 1 . 1 ") ĊĠĠĠĠĠ Ġ. build Zip ( temp Path ) ĊĊĠĠĠ Ġval Ġcommands Ġ= ĠlistOf ( Startup Action Script Manager . Un zip Command ( temp Path , Ġold Plugins Dir )) ĊĠĠĠ ĠStartup Action Script Manager . save Action Script ( commands , Ġold Plugins TempDir . resolve ( Startup Action Script Manager . ACTION _ SCRIPT _ FILE )) ĊĊĠĠĠ ĠPlugin Builder () ĊĠĠĠĠĠ Ġ. id ( temp Builder . id ) ĊĠĠĠĠĠ Ġ. version (" 1 . 0 ") ĊĠĠĠĠĠ Ġ. build Jar ( old Plugins Dir . resolve (" my - plugin - 1 . 0 . jar ")) ĊĊĠĠĠ Ġval Ġnew Config Dir Ġ= Ġlocal TempDir . new Directory (" new Config "). to Path () ĊĠĠĠ Ġval Ġnew Plugins Dir Ġ= Ġnew Config Dir . resolve (" plugins ") ĊĊĠĠĠ Ġval Ġoptions Ġ= ĠConfig Import Helper . Config Import Options ( LOG ) ĊĠĠĠ Ġoptions . headless Ġ= Ġtrue ĊĠĠĠ ĠConfig Import Helper . do Import ( old Config Dir , Ġnew Config Dir , Ġnull , Ġold Plugins Dir , Ġnew Plugins Dir , Ġoptions ) ĊĠĠĠ ĠassertThat ( new Plugins Dir ) ĊĠĠĠĠĠ Ġ. isDirectory Containing Ġ{ Ġit . fileName . toString () Ġ== Ġtemp Builder . id Ġ&& Ġit . isDirectory () Ġ} ĊĠĠĠĠĠ Ġ. isDirectory Not Containing Ġ{ Ġit . fileName . toString () Ġ== Ġ" my - plugin - 1 . 0 . jar " Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` do Ġnot Ġmigrate Ġplugins Ġto Ġexisting Ġdirectory `() Ġ{ ĊĠĠĠ Ġval Ġold Config Dir Ġ= Ġlocal TempDir . new Directory (" old Config "). to Path () ĊĠĠĠ Ġval Ġold Plugins Dir Ġ= ĠFiles . create Directories ( old Config Dir . resolve (" plugins ")) ĊĠĠĠ Ġval Ġold Plugin Zip Ġ= ĠFiles . create File ( old Plugins Dir . resolve (" old - plugin . zip ")) ĊĊĠĠĠ Ġval Ġnew Config Dir Ġ= Ġlocal TempDir . new Directory (" new Config "). to Path () ĊĠĠĠ Ġval Ġnew Plugins Dir Ġ= ĠFiles . create Directories ( new Config Dir . resolve (" plugins ")) ĊĠĠĠ Ġval Ġnew Plugin Zip Ġ= ĠFiles . create File ( new Plugins Dir . resolve (" new - plugin . zip ")) ĊĊĠĠĠ Ġval Ġoptions Ġ= ĠConfig Import Helper . Config Import Options ( LOG ) ĊĠĠĠ Ġoptions . headless Ġ= Ġtrue ĊĠĠĠ ĠConfig Import Helper . do Import ( old Config Dir , Ġnew Config Dir , Ġnull , Ġold Plugins Dir , Ġnew Plugins Dir , Ġoptions ) ĊĊĠĠĠ ĠassertThat ( new Plugins Dir ) ĊĠĠĠĠĠ Ġ. isDirectory Containing Ġ{ Ġit . fileName Ġ== Ġnew Plugin Zip . fileName Ġ} ĊĠĠĠĠĠ Ġ. isDirectory Not Containing Ġ{ Ġit . fileName Ġ== Ġold Plugin Zip . fileName Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` filtering Ġcustom ĠVM Ġoptions `() Ġ{ ĊĠĠĠ Ġval Ġold Config Dir Ġ= Ġlocal TempDir . new Directory (" old Config "). to Path () ĊĠĠĠ Ġ@ Suppress (" Spell Checking Inspection ") Ġval Ġout l aws Ġ= ĠlistOf ( ĊĠĠĠĠĠ Ġ"- XX : Max Java StackTrace Depth =- 1 ", Ġ"- X verify : none ", Ġ"- no verify ", Ġ"- agent lib : y jp agent = opts ", Ġ"- agent path :/ path / to / lib - y jp agent . so = opts ") ĊĠĠĠ ĠFiles . write ( old Config Dir . resolve ( VM Options . get Custom VM Options FileName ()), Ġout l aws ) ĊĠĠĠ Ġval Ġnew Config Dir Ġ= Ġlocal TempDir . new Directory (" new Config "). to Path () ĊĊĠĠĠ Ġval Ġoptions Ġ= ĠConfig Import Helper . Config Import Options ( LOG ) ĊĠĠĠ Ġoptions . headless Ġ= Ġtrue ĊĠĠĠ ĠConfig Import Helper . do Import ( old Config Dir , Ġnew Config Dir , Ġnull , Ġold Config Dir . resolve (" plugins "), Ġnew Config Dir . resolve (" plugins "), Ġoptions ) ĊĊĠĠĠ ĠassertThat ( new Config Dir . resolve ( VM Options . get Custom VM Options FileName ())). has Content ("- XX : Max Java StackTrace Depth = 1 0 0 0 0 ") ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` finding Ġrelated Ġdirectories `() Ġ{ ĊĠĠĠ Ġfun Ġpopulate ( config : ĠPath , Ġplugins : ĠPath ?, Ġsystem : ĠPath ?, Ġlogs : ĠPath ?) Ġ{ ĊĠĠĠĠĠ Ġwrite Storage File ( config , ĠSystem . currentTimeMillis ()) ĊĠĠĠĠĠ Ġplugins ?. create Directories () ĊĠĠĠĠĠ Ġsystem ?. create Directories () ĊĠĠĠĠĠ Ġlogs ?. create Directories () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġcfg 1 9 1 Ġ= Ġcreate Config Dir (" 2 0 1 9 . 1 ") ĊĠĠĠ Ġpopulate ( cfg 1 9 1 , Ġnull , Ġnull , Ġnull ) ĊĠĠĠ Ġif Ġ(! System Info . is Mac ) Ġ{ ĊĠĠĠĠĠ ĠFiles . writeString ( cfg 1 9 1 . parent . resolve (" some _ file . txt "), Ġ"... ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġcfg 1 9 2 Ġ= Ġcreate Config Dir (" 2 0 1 9 . 2 ") ĊĠĠĠ Ġpopulate ( cfg 1 9 2 , Ġnull , Ġnull , Ġnull ) ĊĠĠĠ Ġval Ġexpected 1 9 2 Ġ= Ġwhen Ġ{ ĊĠĠĠĠĠ ĠSystem Info . is Mac Ġ-> ĠlistOf ( cfg 1 9 2 ) ĊĠĠĠĠĠ Ġelse Ġ-> ĠlistOf ( cfg 1 9 2 . parent ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġcfg 1 9 3 Ġ= Ġcreate Config Dir (" 2 0 1 9 . 3 ") ĊĠĠĠ Ġval Ġplugins 1 9 3 Ġ= Ġwhen Ġ{ ĊĠĠĠĠĠ ĠSystem Info . is Mac Ġ-> Ġcfg 1 9 3 . parent . parent . resolve (" Application ĠSupport "). resolve ( cfg 1 9 3 . fileName ) ĊĠĠĠĠĠ Ġelse Ġ-> Ġcfg 1 9 3 . resolve (" plugins ") ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġsys 1 9 3 Ġ= Ġwhen Ġ{ ĊĠĠĠĠĠ ĠSystem Info . is Mac Ġ-> Ġcfg 1 9 3 . parent . parent . resolve (" Caches "). resolve ( cfg 1 9 3 . fileName ) ĊĠĠĠĠĠ Ġelse Ġ-> Ġcfg 1 9 3 . parent . resolve (" system ") ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġlogs 1 9 3 Ġ= Ġwhen Ġ{ ĊĠĠĠĠĠ ĠSystem Info . is Mac Ġ-> Ġcfg 1 9 3 . parent . parent . resolve (" Logs "). resolve ( cfg 1 9 3 . fileName ) ĊĠĠĠĠĠ Ġelse Ġ-> Ġsys 1 9 3 . resolve (" logs ") ĊĠĠĠ Ġ} ĊĠĠĠ Ġpopulate ( cfg 1 9 3 , Ġplugins 1 9 3 , Ġsys 1 9 3 , Ġlogs 1 9 3 ) ĊĠĠĠ Ġval Ġexpected 1 9 3 Ġ= Ġwhen Ġ{ ĊĠĠĠĠĠ ĠSystem Info . is Mac Ġ-> ĠlistOf ( cfg 1 9 3 , Ġsys 1 9 3 , Ġplugins 1 9 3 , Ġlogs 1 9 3 ) ĊĠĠĠĠĠ Ġelse Ġ-> ĠlistOf ( cfg 1 9 3 . parent ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġcaches And Logs 1 9 3 Ġ= Ġwhen Ġ{ ĊĠĠĠĠĠ ĠSystem Info . is Mac Ġ-> ĠlistOf ( sys 1 9 3 , Ġlogs 1 9 3 ) ĊĠĠĠĠĠ Ġelse Ġ-> ĠlistOf ( sys 1 9 3 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġcfg 2 0 1 Ġ= Ġcreate Config Dir (" 2 0 2 0 . 1 ") ĊĠĠĠ Ġpopulate ( cfg 2 0 1 , Ġnull , Ġnull , Ġnull ) ĊĊĠĠĠ Ġval Ġcfg 2 0 2 Ġ= Ġcreate Config Dir (" 2 0 2 0 . 2 ") ĊĠĠĠ Ġval Ġsys 2 0 2 Ġ= Ġcfg 2 0 2 . file System . getPath ( Path Manager . getDefault System Path For ( cfg 2 0 2 . fileName . toString ())) ĊĠĠĠ Ġpopulate ( cfg 2 0 2 , Ġnull , Ġsys 2 0 2 , Ġnull ) ĊĊĠĠĠ Ġval Ġcfg 2 0 3 Ġ= Ġcreate Config Dir (" 2 0 2 0 . 3 ") ĊĠĠĠ Ġval Ġsys 2 0 3 Ġ= Ġcfg 2 0 3 . file System . getPath ( Path Manager . getDefault System Path For ( cfg 2 0 3 . fileName . toString ())) ĊĠĠĠ Ġval Ġplugins 2 0 3 Ġ= Ġcfg 2 0 3 . file System . getPath ( Path Manager . getDefault Plugin Path For ( cfg 2 0 3 . fileName . toString ())) ĊĠĠĠ Ġval Ġlogs 2 0 3 Ġ= Ġcfg 2 0 3 . file System . getPath ( Path Manager . getDefault Log Path For ( cfg 2 0 3 . fileName . toString ())) ĊĠĠĠ Ġpopulate ( cfg 2 0 3 , Ġplugins 2 0 3 , Ġsys 2 0 3 , Ġlogs 2 0 3 ) ĊĠĠĠ Ġval Ġexpected 2 0 3 Ġ= Ġwhen Ġ{ ĊĠĠĠĠĠ ĠSystem Info . is Windows Ġ-> ĠlistOf ( cfg 2 0 3 , Ġsys 2 0 3 ) ĊĠĠĠĠĠ ĠSystem Info . is Mac Ġ-> ĠlistOf ( cfg 2 0 3 , Ġsys 2 0 3 , Ġlogs 2 0 3 ) ĊĠĠĠĠĠ Ġelse Ġ-> ĠlistOf ( cfg 2 0 3 , Ġsys 2 0 3 , Ġplugins 2 0 3 ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġcaches And Logs 2 0 3 Ġ= Ġwhen Ġ{ ĊĠĠĠĠĠ ĠSystem Info . is Mac Ġ-> ĠlistOf ( sys 2 0 3 , Ġlogs 2 0 3 ) ĊĠĠĠĠĠ Ġelse Ġ-> ĠlistOf ( sys 2 0 3 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġcurrent Ġ= Ġcreate Config Dir (" 2 0 2 1 . 2 ") ĊĠĠĠ Ġval Ġresult Ġ= ĠConfig Import Helper . find Config Directories ( current ) ĊĠĠĠ ĠassertThat ( result . paths ). contains Exactly In Any Order ( cfg 1 9 1 , Ġcfg 1 9 2 , Ġcfg 1 9 3 , Ġcfg 2 0 1 , Ġcfg 2 0 2 , Ġcfg 2 0 3 ) ĊĊĠĠĠ Ġval Ġrelated Ġ= Ġresult . paths . map Ġ{ Ġresult . find Related Directories ( it , Ġfalse ) Ġ} ĊĠĠĠ ĠassertThat ( related ). contains Exactly In Any Order ( ĊĠĠĠĠĠ ĠlistOf ( cfg 1 9 1 ), Ġexpected 1 9 2 , Ġexpected 1 9 3 , ĠlistOf ( cfg 2 0 1 ), ĠlistOf ( cfg 2 0 2 , Ġsys 2 0 2 ), Ġexpected 2 0 3 ) ĊĊĠĠĠ Ġval Ġcaches And Logs Ġ= Ġresult . paths . map Ġ{ Ġresult . find Related Directories ( it , Ġtrue ) Ġ}. filter Ġ{ Ġit . isNotEmpty () Ġ} ĊĠĠĠ ĠassertThat ( cache s And Logs ). contains Exactly In Any Order ( ĊĠĠĠĠĠ Ġcaches And Logs 1 9 3 , ĠlistOf ( sys 2 0 2 ), Ġcaches And Logs 2 0 3 ) ĊĠ Ġ} Ċ } Ċ