// Ġ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 Ġorg . jetbrains . kotlin . idea . script ing . gradle Ċ Ċ import Ġorg . jetbrains . kotlin . idea . gradle . script ing . LastModified Files Ċ import Ġorg . junit . Test Ċ import Ġjava . io . ByteArray InputStream Ċ import Ġjava . io . ByteArray OutputStream Ċ import Ġjava . io . Data InputStream Ċ import Ġjava . io . Data OutputStream Ċ import Ġkotlin . test . assertEquals Ċ Ċ class ĠLast Modified Files Test Ġ{ ĊĠĠĠ Ġval Ġfiles Ġ= ĠLast Modified Files () ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Simple 0 () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals ( Long . MIN _ VALUE , Ġfiles . lastModified TimeStamp Except (" x ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Simple 1 () Ġ{ ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 1 , Ġ" x ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( Long . MIN _ VALUE , Ġfiles . lastModified TimeStamp Except (" x ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġfiles . lastModified TimeStamp Except (" y ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Simple 2 () Ġ{ ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 1 , Ġ" x ") ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 2 , Ġ" y ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġfiles . lastModified TimeStamp Except (" x ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġfiles . lastModified TimeStamp Except (" y ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Simple 3 () Ġ{ ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 1 , Ġ" x ") ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 2 , Ġ" y ") ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 3 , Ġ" z ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġfiles . lastModified TimeStamp Except (" x ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġfiles . lastModified TimeStamp Except (" y ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġfiles . lastModified TimeStamp Except (" z ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Same 2 () Ġ{ ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 1 , Ġ" x ") ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 1 , Ġ" y ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġfiles . lastModified TimeStamp Except (" x ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġfiles . lastModified TimeStamp Except (" y ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Same 3 () Ġ{ ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 1 , Ġ" x ") ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 1 , Ġ" y ") ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 2 , Ġ" z ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġfiles . lastModified TimeStamp Except (" x ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġfiles . lastModified TimeStamp Except (" y ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġfiles . lastModified TimeStamp Except (" z ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Same 4 () Ġ{ ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 1 , Ġ" x ") ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 1 , Ġ" y ") ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 2 , Ġ" z ") ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 3 , Ġ" a ") ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 3 , Ġ" b ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġfiles . lastModified TimeStamp Except (" x ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġfiles . lastModified TimeStamp Except (" y ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġfiles . lastModified TimeStamp Except (" z ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġfiles . lastModified TimeStamp Except (" a ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġfiles . lastModified TimeStamp Except (" b ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Same File () Ġ{ ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 1 , Ġ" x ") ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 2 , Ġ" x ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( Long . MIN _ VALUE , Ġfiles . lastModified TimeStamp Except (" x ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Same File 1 () Ġ{ ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 1 , Ġ" z ") ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 2 , Ġ" x ") ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 3 , Ġ" x ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġfiles . lastModified TimeStamp Except (" x ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġfiles . lastModified TimeStamp Except (" z ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Same File 2 () Ġ{ ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 1 , Ġ" z ") ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 1 , Ġ" x ") ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 2 , Ġ" x ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġfiles . lastModified TimeStamp Except (" x ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġfiles . lastModified TimeStamp Except (" z ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Same File 3 () Ġ{ ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 1 , Ġ" x ") ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 1 , Ġ" y ") ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 2 , Ġ" x ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġfiles . lastModified TimeStamp Except (" x ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġfiles . lastModified TimeStamp Except (" y ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Same File 4 () Ġ{ ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 1 , Ġ" z ") ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 2 , Ġ" x ") ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 2 , Ġ" y ") ĊĠĠĠĠĠĠĠ Ġfiles . file Changed ( 3 , Ġ" x ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġfiles . lastModified TimeStamp Except (" x ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġfiles . lastModified TimeStamp Except (" y ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġfiles . lastModified TimeStamp Except (" z ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Loading After Same File Bug () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġrestored Ġ= ĠLast Modified Files ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLast Modified Files . Sim ultaneous ly Changed Files ( 2 , Ġmutable Set Of (" x ")), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLast Modified Files . Sim ultaneous ly Changed Files ( 1 , Ġmutable Set Of (" x ")) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Long . MIN _ VALUE , Ġrestored . lastModified TimeStamp Except (" x ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Loading After Same File Bug 2 () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġrestored Ġ= ĠLast Modified Files ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLast Modified Files . Sim ultaneous ly Changed Files ( 2 , Ġmutable Set Of (" x ", Ġ" y ")), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLast Modified Files . Sim ultaneous ly Changed Files ( 1 , Ġmutable Set Of (" x ")) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġrestored . lastModified TimeStamp Except (" x ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġrestored . lastModified TimeStamp Except (" y ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Loading After Same File Bug 3 () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġrestored Ġ= ĠLast Modified Files ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLast Modified Files . Sim ultaneous ly Changed Files ( 2 , Ġmutable Set Of (" x ", Ġ" y ")), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLast Modified Files . Sim ultaneous ly Changed Files ( 1 , Ġmutable Set Of (" x ", Ġ" z ")) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġrestored . lastModified TimeStamp Except (" x ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġrestored . lastModified TimeStamp Except (" y ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest File Attributes () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= ĠLast Modified Files ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLast Modified Files . Sim ultaneous ly Changed Files ( System . currentTimeMillis (), Ġmutable Set Of (" C : file / s ld kf jl sdk jf ")), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLast Modified Files . Sim ultaneous ly Changed Files ( System . currentTimeMillis (), Ġmutable Set Of (" C :/ file / foo / d / ")) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcheck File Attributes Save ( expected ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest File Attributes Nullable () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexpected : ĠLast Modified Files ? Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcheck File Attributes Save ( expected ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Default File Attributes () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= ĠLast Modified Files () ĊĠĠĠĠĠĠĠ Ġcheck File Attributes Save ( expected ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcheck File Attributes Save ( expected : ĠLast Modified Files ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbuffer Ġ= ĠByteArrayOutputStream () ĊĠĠĠĠĠĠĠ ĠLast Modified Files . write LastModified Files ( Data OutputStream ( buffer ), Ġexpected ) ĊĊĠĠĠĠĠĠĠ Ġval Ġactual Ġ= ĠLast Modified Files . read LastModified Files ( Data InputStream ( ByteArray InputStream ( buffer . toByteArray ()))) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( expected . toString (), Ġactual . toString ()) ĊĠĠĠ Ġ} Ċ }