/* Ċ * ĠCopyright Ġ 2 0 2 1 ĠSpotify ĠAB Ċ * Ċ * ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ * Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ * ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ * Ċ * ĠĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ * Ċ * ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ * Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ * ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ * ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ * Ġlimitations Ġunder Ġthe ĠLicense . Ċ */ Ċ Ċ package Ġcom . spotify . r uler . plugin . dependency Ċ Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġcom . spotify . r uler . models . ComponentType Ċ import Ġcom . spotify . r uler . plugin . common . ClassName Sanit izer Ċ import Ġorg . junit . jupiter . api . Test Ċ Ċ class ĠDependency Sanit izer Test Ġ{ ĊĠĠĠ Ġprivate Ġval Ġsanit izer Ġ= ĠDependency Sanit izer ( ClassName Sanit izer ( null )) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Prefix Ġis Ġremoved Ġfrom ĠGradle Ġmodule Ġidentifiers `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdirty Ġ= ĠDependency Entry . Default (" licenses . html ", Ġ" project Ġ: lib ") ĊĠĠĠĠĠĠĠ Ġval Ġclean Ġ= Ġsanit izer . sanitize ( listOf ( dirty )) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( clean ). contains Entry (" licenses . html ", ĠlistOf ( Dependency Component (": lib ", ĠComponent Type . INTERNAL ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Class Ġnames Ġare Ġsanitized `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdirty Ġ= ĠDependency Entry . Class (" com / spotify / MainActivity . class ", Ġ" com . spotify : main : 1 . 0 . 0 ") ĊĠĠĠĠĠĠĠ Ġval Ġclean Ġ= Ġsanit izer . sanitize ( listOf ( dirty )) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( clean ). contains Entry (" com . spotify . MainActivity ", ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠDependency Component (" com . spotify : main : 1 . 0 . 0 ", ĠComponent Type . EXTERNAL ), ĊĠĠĠĠĠĠĠ Ġ)) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Component Ġtypes Ġare Ġrecognized `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdirty Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠDependency Entry . Default (" foo . txt ", Ġ": foo "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠDependency Entry . Default (" bar . txt ", Ġ" org . bar : bar : 1 . 0 . 0 "), ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġclean Ġ= Ġsanit izer . sanitize ( dirty ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( clean ). contains Entry (" foo . txt ", ĠlistOf ( Dependency Component (": foo ", ĠComponent Type . INTERNAL ))) ĊĠĠĠĠĠĠĠ ĠassertThat ( clean ). contains Entry (" bar . txt ", ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠDependency Component (" org . bar : bar : 1 . 0 . 0 ", ĠComponent Type . EXTERNAL ), ĊĠĠĠĠĠĠĠ Ġ)) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Files Ġare Ġmapped Ġto Ġtheir Ġcomponents `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdirty Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠDependency Entry . Default (" foo . txt ", Ġ": foo "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠDependency Entry . Default (" bar . txt ", Ġ": bar "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠDependency Entry . Default (" baz . txt ", Ġ": baz "), ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġclean Ġ= Ġsanit izer . sanitize ( dirty ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( clean ). contains Entry (" foo . txt ", ĠlistOf ( Dependency Component (": foo ", ĠComponent Type . INTERNAL ))) ĊĠĠĠĠĠĠĠ ĠassertThat ( clean ). contains Entry (" bar . txt ", ĠlistOf ( Dependency Component (": bar ", ĠComponent Type . INTERNAL ))) ĊĠĠĠĠĠĠĠ ĠassertThat ( clean ). contains Entry (" baz . txt ", ĠlistOf ( Dependency Component (": baz ", ĠComponent Type . INTERNAL ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Files Ġcan Ġappear Ġin Ġmultiple Ġcomponents `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdirty Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠDependency Entry . Default (" test . txt ", Ġ": foo "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠDependency Entry . Default (" test . txt ", Ġ": bar "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠDependency Entry . Default (" test . txt ", Ġ": baz "), ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġclean Ġ= Ġsanit izer . sanitize ( dirty ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( clean ). contains Entry (" test . txt ", ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠDependency Component (": foo ", ĠComponent Type . INTERNAL ), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠDependency Component (": bar ", ĠComponent Type . INTERNAL ), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠDependency Component (": baz ", ĠComponent Type . INTERNAL ), ĊĠĠĠĠĠĠĠ Ġ)) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Windows - style Ġpaths Ġare Ġconverted Ġto ĠUNIX - style Ġpaths `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdirty Ġ= ĠDependency Entry . Default ("\\ windows \\ path \\ test . txt ", Ġ": test ") ĊĠĠĠĠĠĠĠ Ġval Ġclean Ġ= Ġsanit izer . sanitize ( listOf ( dirty )) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( clean ). contains Entry ("/ windows / path / test . txt ", ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠDependency Component (": test ", ĠComponent Type . INTERNAL ), ĊĠĠĠĠĠĠĠ Ġ)) ĊĠĠĠ Ġ} Ċ } Ċ