package Ġnet . cord a . gradle . jar filter Ċ Ċ import Ġnet . cord a . gradle . jar filter . matcher .* Ċ import Ġnet . cord a . gradle . un wanted .* Ċ import Ġorg . assertj . core . api . Assertions .* Ċ import Ġorg . hamcrest . core . Is Collection Containing .* Ċ import Ġorg . hamcrest . core . IsNot .* Ċ import Ġorg . junit . Assert .* Ċ import Ġorg . junit . Class Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . rules . Rule Chain Ċ import Ġorg . junit . rules . Temporary Folder Ċ import Ġorg . junit . rules . Test Rule Ċ import Ġkotlin . reflect . full . declared Member Functions Ċ import Ġkotlin . reflect . full . declared Member Properties Ċ import Ġkotlin . test . assert Fails With Ċ Ċ class ĠDelete And Stub Tests Ġ{ ĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠVAR _ PROPERTY _ CLASS Ġ= Ġ" net . cord a . gradle . Has Var Property For Delete And Stub " ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠVAL _ PROPERTY _ CLASS Ġ= Ġ" net . cord a . gradle . Has Val Property For Delete And Stub " ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠDE LETED _ FUN _ CLASS Ġ= Ġ" net . cord a . gradle . Deleted Function Inside Stub bed " ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠDE LETED _ VAR _ CLASS Ġ= Ġ" net . cord a . gradle . Deleted Var Inside Stub bed " ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠDE LETED _ VAL _ CLASS Ġ= Ġ" net . cord a . gradle . Deleted Val Inside Stub bed " ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠDE LETED _ PKG _ CLASS Ġ= Ġ" net . cord a . gradle . Delete Package With Stub bed " ĊĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġtest Project Dir Ġ= ĠTemporary Folder () ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġtest Project Ġ= ĠJar Filter Project ( test Project Dir , Ġ" delete - and - stub ") ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġstring Val Ġ= Ġis Property (" string Val ", ĠString :: class ) ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġlong Var Ġ= Ġis Property (" long Var ", ĠLong :: class ) ĊĠĠĠĠĠĠĠ Ġprivate Ġval ĠgetString Val Ġ= Ġis Method (" getString Val ", ĠString :: class . java ) ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġget Long Var Ġ= Ġis Method (" getLong Var ", ĠLong :: class . java ) ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġset Long Var Ġ= Ġis Method (" set Long Var ", ĠVoid . TYPE , ĠLong :: class . java ) ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġstring Data Ġ= Ġis Function (" string Data ", ĠString :: class ) ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġun wanted Fun Ġ= Ġis Function (" un wanted Fun ", ĠString :: class , ĠString :: class ) ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġun wanted Var Ġ= Ġis Property (" un wanted Var ", ĠString :: class ) ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġun wanted Val Ġ= Ġis Property (" un wanted Val ", ĠString :: class ) ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġstring Data Java Ġ= Ġis Method (" string Data ", ĠString :: class . java ) ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġget Un wanted Val Ġ= Ġis Method (" getUn wanted Val ", ĠString :: class . java ) ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġget Un wanted Var Ġ= Ġis Method (" getUn wanted Var ", ĠString :: class . java ) ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġset Un wanted Var Ġ= Ġis Method (" set Un wanted Var ", ĠVoid . TYPE , ĠString :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġ@ Class Rule ĊĠĠĠĠĠĠĠ Ġ@ Jvm Field ĊĠĠĠĠĠĠĠ Ġval Ġrules : ĠTest Rule Ġ= ĠRule Chain ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. outer Rule ( test Project Dir ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. around ( test Project ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdelete Val Property () Ġ{ ĊĠĠĠĠĠĠĠ Ġclass Loader For ( test Project . source Jar ). use Ġ{ Ġcl Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcl . load < Has String Val >( VAL _ PROPERTY _ CLASS ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġget Declared Constructor ( String :: class . java ). newInstance ( MESSAGE ). also Ġ{ Ġobj Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( MESSAGE , Ġobj . string Val ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" string Val Ġnot Ġfound ", Ġkotlin . declared Member Properties , Ġhas Item ( string Val )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" getString Val () Ġnot Ġfound ", Ġkotlin . java Declared Methods , Ġhas Item ( getString Val )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġclass Loader For ( test Project . filtered Jar ). use Ġ{ Ġcl Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcl . load < Has String Val >( VAL _ PROPERTY _ CLASS ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( getDeclared Constructor ( String :: class . java ). newInstance ( MESSAGE )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" string Val Ġstill Ġexists ", Ġkotlin . declared Member Properties , Ġnot ( has Item ( string Val ))) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" getString Val () Ġstill Ġexists ", Ġkotlin . java Declared Methods , Ġnot ( has Item ( getString Val ))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdelete Var Property () Ġ{ ĊĠĠĠĠĠĠĠ Ġclass Loader For ( test Project . source Jar ). use Ġ{ Ġcl Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcl . load < Has Long Var >( VAR _ PROPERTY _ CLASS ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġget Declared Constructor ( Long :: class . java ). newInstance ( BIG _ NUMBER ). also Ġ{ Ġobj Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( BIG _ NUMBER , Ġobj . long Var ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" long Var Ġnot Ġfound ", Ġkotlin . declared Member Properties , Ġhas Item ( long Var )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" getLong Var () Ġnot Ġfound ", Ġkotlin . java Declared Methods , Ġhas Item ( getLong Var )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" set Long Var () Ġnot Ġfound ", Ġkotlin . java Declared Methods , Ġhas Item ( set Long Var )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġclass Loader For ( test Project . filtered Jar ). use Ġ{ Ġcl Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcl . load < Has Long Var >( VAR _ PROPERTY _ CLASS ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( getDeclared Constructor ( Long :: class . java ). newInstance ( BIG _ NUMBER )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" long Var Ġstill Ġexists ", Ġkotlin . declared Member Properties , Ġnot ( has Item ( long Var ))) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" getLong Var () Ġstill Ġexists ", Ġkotlin . java Declared Methods , Ġnot ( has Item ( getLong Var ))) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" set Long Var () Ġstill Ġexists ", Ġkotlin . java Declared Methods , Ġnot ( has Item ( set Long Var ))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdeleted Function Inside Stub bed () Ġ{ ĊĠĠĠĠĠĠĠ Ġclass Loader For ( test Project . source Jar ). use Ġ{ Ġcl Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcl . load < Has String >( DELETED _ FUN _ CLASS ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġget Declared Constructor ( String :: class . java ). newInstance ( DEFAULT _ MESSAGE ). also Ġ{ Ġobj Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( DEFAULT _ MESSAGE , Ġobj . string Data ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( MESSAGE , Ġ( obj Ġas ĠHas Un wanted Fun ). un wanted Fun ( MESSAGE )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" un wanted Fun Ġnot Ġfound ", Ġkotlin . declared Member Functions , Ġhas Item ( un wanted Fun )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" string Data () Ġnot Ġfound ", Ġkotlin . declared Member Functions , Ġhas Item ( string Data )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġclass Loader For ( test Project . filtered Jar ). use Ġ{ Ġcl Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcl . load < Has String >( DELETED _ FUN _ CLASS ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġget Declared Constructor ( String :: class . java ). newInstance ( DEFAULT _ MESSAGE ). also Ġ{ Ġobj Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġassert Fails With < Unsupported OperationException > Ġ{ Ġobj . string Data () Ġ}. also Ġ{ Ġex Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( ex ). has Message (" Method Ġhas Ġbeen Ġdeleted ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġassert Fails With < Abstract Method Error > Ġ{ Ġ( obj Ġas ĠHas Un wanted Fun ). un wanted Fun ( MESSAGE ) Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" un wanted Fun Ġstill Ġexists ", Ġkotlin . declared Member Functions , Ġnot ( has Item ( un wanted Fun ))) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" string Data () Ġnot Ġfound ", Ġkotlin . declared Member Functions , Ġhas Item ( string Data )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdeleted Var Inside Stub bed () Ġ{ ĊĠĠĠĠĠĠĠ Ġclass Loader For ( test Project . source Jar ). use Ġ{ Ġcl Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcl . load < Has String >( DELETED _ VAR _ CLASS ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġget Declared Constructor ( String :: class . java ). newInstance ( DEFAULT _ MESSAGE ). also Ġ{ Ġobj Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( DEFAULT _ MESSAGE , Ġobj . string Data ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ( obj Ġas ĠHas Un wanted Var ). also Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( DEFAULT _ MESSAGE , Ġit . un wanted Var ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġit . un wanted Var Ġ= ĠMESSAGE ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( MESSAGE , Ġit . un wanted Var ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" un wanted Var Ġnot Ġfound ", Ġkotlin . declared Member Properties , Ġhas Item ( un wanted Var )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" string Data () Ġnot Ġfound ", Ġkotlin . declared Member Functions , Ġhas Item ( string Data )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġclass Loader For ( test Project . filtered Jar ). use Ġ{ Ġcl Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcl . load < Has String >( DELETED _ VAR _ CLASS ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( getDeclared Constructor ( String :: class . java ). newInstance ( MESSAGE )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" un wanted Var Ġstill Ġexists ", Ġkotlin . declared Member Properties , Ġnot ( has Item ( un wanted Var ))) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" getUn wanted Var () Ġstill Ġexists ", Ġkotlin . java Declared Methods , Ġnot ( has Item ( getUn wanted Var ))) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" set Un wanted Var () Ġstill Ġexists ", Ġkotlin . java Declared Methods , Ġnot ( has Item ( set Un wanted Var ))) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" string Data () Ġnot Ġfound ", Ġkotlin . declared Member Functions , Ġhas Item ( string Data )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" string Data () Ġnot Ġfound ", Ġkotlin . java Declared Methods , Ġhas Item ( string Data Java )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdeleted Val Inside Stub bed () Ġ{ ĊĠĠĠĠĠĠĠ Ġclass Loader For ( test Project . source Jar ). use Ġ{ Ġcl Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcl . load < Has String >( DELETED _ VAL _ CLASS ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġget Declared Constructor ( String :: class . java ). newInstance ( MESSAGE ). also Ġ{ Ġobj Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( MESSAGE , Ġobj . string Data ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( MESSAGE , Ġ( obj Ġas ĠHas Un wanted Val ). un wanted Val ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" un wanted Val Ġnot Ġfound ", Ġkotlin . declared Member Properties , Ġhas Item ( un wanted Val )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" string Data () Ġnot Ġfound ", Ġkotlin . declared Member Functions , Ġhas Item ( string Data )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġclass Loader For ( test Project . filtered Jar ). use Ġ{ Ġcl Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcl . load < Has String >( DELETED _ VAL _ CLASS ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( getDeclared Constructor ( String :: class . java ). newInstance ( MESSAGE )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" un wanted Val Ġstill Ġexists ", Ġkotlin . declared Member Properties , Ġnot ( has Item ( un wanted Val ))) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" getUn wanted Val () Ġstill Ġexists ", Ġkotlin . java Declared Methods , Ġnot ( has Item ( getUn wanted Val ))) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" string Data () Ġnot Ġfound ", Ġkotlin . declared Member Functions , Ġhas Item ( string Data )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat (" string Data () Ġnot Ġfound ", Ġkotlin . java Declared Methods , Ġhas Item ( string Data Java )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdelete Package With Stub bed () Ġ{ ĊĠĠĠĠĠĠĠ Ġclass Loader For ( test Project . source Jar ). use Ġ{ Ġcl Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcl . load < Any >( DELETED _ PKG _ CLASS ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġget Declared Method (" stub bed ", ĠString :: class . java ). also Ġ{ Ġmethod Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals (" [$ MESSAGE ]", Ġmethod . invoke ( null , ĠMESSAGE )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġclass Loader For ( test Project . filtered Jar ). use Ġ{ Ġcl Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġassert Fails With < Class NotFoundException > Ġ{ Ġcl . load < Any >( DELETED _ PKG _ CLASS ) Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }