/* Ċ Ġ* ĠCopyright Ġ( C ) Ġ 2 0 1 9 ĠThe ĠAndroid ĠOpen ĠSource ĠProject Ċ Ġ* Ċ Ġ* Ġ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 . android . tools . idea . np w . module Ċ Ċ import Ġcom . android . tools . idea . np w . benchmark . New Benchmark Module Description Provider Ċ import Ġcom . android . tools . idea . np w . dynamic app . New Dynamic App Module Description Provider Ċ import Ġcom . android . tools . idea . np w . import ing . Import Module Gallery Entry Provider Ċ import Ġcom . android . tools . idea . np w . java . New Library Module Description Provider Ċ import Ġcom . android . tools . idea . testing . Android Gradle TestCase Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġorg . jetbrains . android . util . Android Bundle . message Ċ import Ġorg . mockito . Mockito Ċ import Ġorg . mockito . Mockito .` when ` Ċ Ċ class ĠChoose Module Type Step Test Ġ: ĠAndroid Gradle TestCase () Ġ{ ĊĠ Ġfun Ġtest Sort Single Module Entries () Ġ{ ĊĠĠĠ ĠassertThat ( sort ( message (" android . wizard . module . new . mobile ")) ). contains Exactly ( message (" android . wizard . module . new . mobile ")). in Order () ĊĠ Ġ} ĊĊĠ Ġfun Ġtest Sort Two Module Entries () Ġ{ ĊĠĠĠ ĠassertThat ( sort ( message (" android . wizard . module . new . library "), Ġmessage (" android . wizard . module . new . mobile "))) ĊĠĠĠĠĠ Ġ. contains Exactly ( message (" android . wizard . module . new . mobile "), Ġmessage (" android . wizard . module . new . library ")). in Order () ĊĠĠĠ ĠassertThat ( sort (" A ", Ġmessage (" android . wizard . module . new . mobile "))) ĊĠĠĠĠĠ Ġ. contains Exactly ( message (" android . wizard . module . new . mobile "), Ġ" A "). in Order () ĊĠĠĠ ĠassertThat ( sort ( message (" android . wizard . module . new . we ar "), Ġ" A ")) ĊĠĠĠĠĠ Ġ. contains Exactly ( message (" android . wizard . module . new . we ar "), Ġ" A "). in Order () ĊĠĠĠ ĠassertThat ( sort (" C ", Ġ" A ")). contains Exactly (" A ", Ġ" C "). in Order () ĊĠ Ġ} ĊĊĠ Ġfun Ġtest Sort Full Module Entries () Ġ{ ĊĠĠĠ ĠassertThat ( ĊĠĠĠĠĠ Ġsort (" Z ", Ġmessage (" android . wizard . module . new . library "), Ġmessage (" android . wizard . module . new . mobile "), ĊĠĠĠĠĠĠĠĠĠĠ Ġmessage (" android . wizard . module . new . we ar "), Ġmessage (" android . wizard . module . new . tv "), ĊĠĠĠĠĠĠĠĠĠĠ Ġmessage (" android . wizard . module . import . gradle . title "), Ġmessage (" android . wizard . module . import . eclipse . title "), ĊĠĠĠĠĠĠĠĠĠĠ Ġmessage (" android . wizard . module . new . google . cloud "), Ġmessage (" android . wizard . module . new . java . or . kotlin . library "), ĊĠĠĠĠĠĠĠĠĠĠ Ġmessage (" android . wizard . module . new . benchmark . module . app "), Ġ" A ")) ĊĠĠĠĠĠ Ġ. contains Exactly ( ĊĠĠĠĠĠĠĠ Ġmessage (" android . wizard . module . new . mobile "), Ġmessage (" android . wizard . module . new . library "), ĊĠĠĠĠĠĠĠ Ġmessage (" android . wizard . module . new . we ar "), Ġmessage (" android . wizard . module . new . tv "), ĊĠĠĠĠĠĠĠ Ġmessage (" android . wizard . module . import . gradle . title "), Ġmessage (" android . wizard . module . import . eclipse . title "), ĊĠĠĠĠĠĠĠ Ġmessage (" android . wizard . module . new . java . or . kotlin . library "), Ġmessage (" android . wizard . module . new . google . cloud "), ĊĠĠĠĠĠĠĠ Ġmessage (" android . wizard . module . new . benchmark . module . app "), Ġ" A ", Ġ" Z ") ĊĠĠĠĠĠ Ġ. in Order () ĊĠ Ġ} ĊĊĠ Ġfun Ġtest Sort Existing Module Entries () Ġ{ ĊĠĠĠ Ġval Ġproviders Ġ= ĠlistOf ( Import Module Gallery Entry Provider (), ĠNew Android Module Description Provider (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠNew Dynamic App Module Description Provider (), ĠNew Library Module Description Provider (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠNew Benchmark Module Description Provider ()) ĊĠĠĠ Ġval Ġmodule Descriptions Ġ= Ġproviders . flatMap Ġ{ Ġit . get Descriptions ( project ) Ġ} ĊĊĠĠĠ Ġval Ġsorted Entries Ġ= Ġsort Module Entries ( module Descriptions ). map Ġ{ Ġit . name Ġ} ĊĊĠĠĠ Ġval Ġexpected Entries Ġ= ĠlistOf ( ĊĠĠĠĠĠ Ġmessage (" android . wizard . module . new . mobile "), ĊĠĠĠĠĠ Ġmessage (" android . wizard . module . new . library "), ĊĠĠĠĠĠ Ġmessage (" android . wizard . module . new . native . library "), ĊĠĠĠĠĠ Ġmessage (" android . wizard . module . new . dynamic . module "), ĊĠĠĠĠĠ Ġmessage (" android . wizard . module . new . dynamic . module . instant "), ĊĠĠĠĠĠ Ġmessage (" android . wizard . module . new . autom otive "), ĊĠĠĠĠĠ Ġmessage (" android . wizard . module . new . we ar "), ĊĠĠĠĠĠ Ġmessage (" android . wizard . module . new . tv "), ĊĠĠĠĠĠ Ġmessage (" android . wizard . module . import . gradle . title "), ĊĠĠĠĠĠ Ġmessage (" android . wizard . module . import . eclipse . title "), ĊĠĠĠĠĠ Ġmessage (" android . wizard . module . new . java . or . kotlin . library "), ĊĠĠĠĠĠ Ġmessage (" android . wizard . module . new . benchmark . module . app ") ĊĠĠĠ Ġ). filter Not Ġ{ ĊĠĠĠĠĠ Ġit Ġ== Ġmessage (" android . wizard . module . import . gradle . title ") Ġ|| Ġit Ġ== Ġmessage (" android . wizard . module . import . eclipse . title ") ĊĠĠĠ Ġ} ĊĊĠĠĠ ĠassertThat ( sorted Entries ). contains Exactly Elements In ( expected Entries ). in Order () ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġsort ( var arg Ġentries : ĠString ): ĠList < String > Ġ{ ĊĠĠĠ Ġval Ġmodule Descriptions Ġ= Ġentries . map Ġ{ ĊĠĠĠĠĠ ĠMockito . mock ( Module Gallery Entry :: class . java ). apply Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( name ). thenReturn ( it ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġsorted Entries Ġ= Ġsort Module Entries ( module Descriptions ) ĊĠĠĠ ĠassertEquals ( entries . size , Ġsorted Entries . size ) ĊĊĠĠĠ Ġreturn Ġsorted Entries . map Ġ{ Ġit . name Ġ} ĊĠ Ġ} Ċ }