package Ġdev . paul shields . assistant view Ċ Ċ import Ġcom . intellij . openapi . file Editor . File Editor Manager Ċ import Ġcom . intellij . openapi . file Editor . File Editor Manager Event Ċ import Ġcom . intellij . openapi . project . D umb Service Ċ import Ġcom . intellij . openapi . project . Project Ċ import Ġcom . intellij . openapi . vfs . Virtual File Ċ import Ġdev . paul shields . assistant view . common . Dispatcher Ċ import Ġdev . paul shields . assistant view . extensions . run On Ui Thread Ċ import Ġdev . paul shields . assistant view . extensions . run With Read Permission Ċ import Ġdev . paul shields . assistant view . services . Assistant View Service Ċ import Ġdev . paul shields . assistant view . services . File Assistant Service Ċ import Ġdev . paul shields . assistant view . services . FileManager Service Ċ import Ġdev . paul shields . assistant view . source files . Assistant View File Ċ import Ġdev . paul shields . assistant view . test common . mock Ċ import Ġdev . paul shields . assistant view . test common . mock K oin Application Ċ import Ġio . mock k . every Ċ import Ġio . mock k . mock k Static Ċ import Ġio . mock k . verify Ċ import Ġorg . jetbrains . kotlin . idea . cache s . resolve . util . isIn D umb Mode Ċ import Ġorg . junit . jupiter . api . BeforeEach Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . extension . Register Extension Ċ import Ġorg . k oin . dsl . module Ċ import Ġorg . k oin . test . K oin Test Ċ Ċ class ĠFile Opened Listener Test Ġ: ĠK oin Test Ġ{ ĊĠĠĠ Ġprivate Ġval Ġassistant View File Ġ= Ġmock < Assistant View File >() ĊĠĠĠ Ġprivate Ġval Ġvirtual File Ġ= Ġmock < Virtual File >() ĊĠĠĠ Ġprivate Ġval Ġd umb Service Ġ= Ġmock < D umb Service >(). apply Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġrun When Smart ( any ()) Ġ} Ġanswers Ġ{ Ġfirst Arg < Runnable >(). run () Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġprivate Ġval Ġproject Ġ= Ġmock < Project >(). apply Ġ{ ĊĠĠĠĠĠĠĠ Ġmock k Static ( Project :: isIn D umb Mode ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĠisIn D umb Mode () Ġ} Ġreturns Ġfalse ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġget Service ( D umb Service :: class . java ) Ġ} Ġreturns Ġd umb Service ĊĠĠĠ Ġ} ĊĠĠĠ Ġprivate Ġval Ġfile Editor Manager Ġ= Ġmock < File Editor Manager >(). apply Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġproject Ġ} Ġreturns Ġthis @ File Opened Listener Test . project ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġselected Editor ?. file Ġ} Ġreturns Ġvirtual File ĊĠĠĠ Ġ} ĊĠĠĠ Ġprivate Ġval Ġfile Editor Manager Event Ġ= Ġmock < File Editor Manager Event >(). apply Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġnew File Ġ} Ġreturns Ġvirtual File ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġmanager Ġ} Ġreturns Ġfile Editor Manager ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġassistant View Service Ġ= Ġmock < Assistant View Service >() ĊĠĠĠ Ġprivate Ġval Ġfile Assistant Service Ġ= Ġmock < File Assistant Service >(). apply Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġget Counter part File ( assistant View File ) Ġ} Ġreturns Ġassistant View File ĊĠĠĠ Ġ} ĊĠĠĠ Ġprivate Ġval Ġfile Manager Service Ġ= Ġmock < FileManager Service >(). apply Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĠgetFile From Virtual File ( virtual File , Ġproject ) Ġ} Ġreturns Ġassistant View File ĊĠĠĠ Ġ} ĊĠĠĠ Ġprivate Ġval Ġdispatcher Ġ= Ġmock < Dispatcher >(). apply Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġrun On Background Thread ( any ()) Ġ} Ġanswers Ġ{ Ġfirst Arg < () Ġ-> ĠUnit >(). invoke () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġ@ Register Extension ĊĠĠĠ Ġval Ġdependency Injector Ġ= Ġmock K oin Application ( ĊĠĠĠĠĠĠĠ Ġmodule Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsingle Ġ{ Ġfile Assistant Service Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsingle Ġ{ Ġfile Manager Service Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsingle Ġ{ Ġassistant View Service Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsingle Ġ{ Ġdispatcher Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġprivate Ġval Ġtarget Ġ= ĠFile Opened Listener () ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun ĠbeforeEach () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Int ellij Thread Control Functions () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġget Ġassistant Ġview Ġfile Ġfor Ġnewly Ġopened Ġfile `() Ġ{ ĊĠĠĠĠĠĠĠ Ġtarget . selection Changed ( file Editor Manager Event ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġfile Manager Service . getFile From Virtual File ( virtual File , Ġproject ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġget Ġassistant Ġview Ġfile Ġon Ġa Ġbackground Ġthread `() Ġ{ ĊĠĠĠĠĠĠĠ Ġtarget . selection Changed ( file Editor Manager Event ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġdispatcher . run On Background Thread ( any ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġhandle Ġif Ġno Ġnewly Ġopened Ġfile Ġis Ġprovided `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġfile Editor Manager Event . new File Ġ} Ġreturns Ġnull ĊĊĠĠĠĠĠĠĠ Ġtarget . selection Changed ( file Editor Manager Event ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 0 ) Ġ{ Ġfile Manager Service . getFile From Virtual File ( any (), Ġany ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġnot Ġinvoke Ġthe Ġdispatch Ġthread Ġif Ġno Ġnewly Ġopened Ġfile Ġis Ġprovided `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġfile Editor Manager Event . new File Ġ} Ġreturns Ġnull ĊĊĠĠĠĠĠĠĠ Ġtarget . selection Changed ( file Editor Manager Event ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 0 ) Ġ{ Ġdispatcher . run On Background Thread ( any ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġget Ġcounter part Ġfile Ġfor Ġnewly Ġopened Ġfile `() Ġ{ ĊĠĠĠĠĠĠĠ Ġtarget . selection Changed ( file Editor Manager Event ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġfile Assistant Service . get Counter part File ( assistant View File ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġhandle Ġif Ġnewly Ġopened Ġfile Ġcan Ġnot Ġbe Ġprocessed `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġfile Manager Service . getFile From Virtual File ( virtual File , Ġproject ) Ġ} Ġreturns Ġnull ĊĊĠĠĠĠĠĠĠ Ġtarget . selection Changed ( file Editor Manager Event ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 0 ) Ġ{ Ġfile Assistant Service . get Counter part File ( any ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġopen Ġcounter part Ġfile `() Ġ{ ĊĠĠĠĠĠĠĠ Ġtarget . selection Changed ( file Editor Manager Event ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġassistant View Service . open File ( assistant View File ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġhandle Ġif Ġcounter part Ġfile Ġdoes Ġnot Ġexist `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġfile Assistant Service . get Counter part File ( assistant View File ) Ġ} Ġreturns Ġnull ĊĊĠĠĠĠĠĠĠ Ġtarget . selection Changed ( file Editor Manager Event ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 0 ) Ġ{ Ġassistant View Service . open File ( any ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġnot Ġwait Ġfor Ġd umb Ġmode Ġto Ġfinish Ġif Ġnot Ġin Ġd umb Ġmode `() Ġ{ ĊĠĠĠĠĠĠĠ Ġtarget . selection Changed ( file Editor Manager Event ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 0 ) Ġ{ Ġd umb Service . run When Smart ( any ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġwait Ġfor Ġd umb Ġmode Ġto Ġfinish Ġbefore Ġopening Ġcounter part Ġfile `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġproject . isIn D umb Mode () Ġ} Ġreturns Ġtrue ĊĊĠĠĠĠĠĠĠ Ġtarget . selection Changed ( file Editor Manager Event ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġd umb Service . run When Smart ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġassistant View Service . open File ( assistant View File ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġnot Ġtry Ġto Ġopen Ġfind Ġor Ġopen Ġcounter part Ġfile Ġuntil Ġd umb Ġmode Ġis Ġfinished `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġproject . isIn D umb Mode () Ġ} Ġreturns Ġtrue ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġd umb Service . run When Smart ( any ()) Ġ} Ġanswers Ġ{ Ġ} ĊĊĠĠĠĠĠĠĠ Ġtarget . selection Changed ( file Editor Manager Event ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 0 ) Ġ{ Ġassistant View Service . open File ( assistant View File ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġnot Ġtry Ġto Ġopen Ġfind Ġor Ġopen Ġcounter part Ġfile Ġwhen Ġd umb Ġmode Ġis Ġfinished Ġif Ġno Ġeditor Ġis Ġcurrently Ġopen `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġproject . isIn D umb Mode () Ġ} Ġreturns Ġtrue ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġfile Editor Manager . selected Editor Ġ} Ġreturns Ġnull ĊĊĠĠĠĠĠĠĠ Ġtarget . selection Changed ( file Editor Manager Event ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 0 ) Ġ{ Ġassistant View Service . open File ( assistant View File ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġmock Int ellij Thread Control Functions () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock k Static (" dev . paul shields . assistant view . extensions . Int ellij Thread Control Extensions Kt ") ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġrun With Read Permission ( any < () Ġ-> ĠAssistant View File ?> ()) Ġ} Ġanswers Ġ{ Ġfirst Arg < () Ġ-> ĠAssistant View File ?> (). invoke () Ġ} ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġrun On Ui Thread ( any ()) Ġ} Ġanswers Ġ{ Ġfirst Arg < () Ġ-> ĠUnit >(). invoke () Ġ} ĊĠĠĠ Ġ} Ċ } Ċ