package Ġuk . gov . just ice . digital . h mp ps . oauth 2 server . resource . api Ċ Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . any Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . mock Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . verify Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . wh enever Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . springframework . security . core . Authentication Ċ import Ġorg . springframework . security . core . authority . Simple Granted Authority Ċ import Ġuk . gov . just ice . digital . h mp ps . oauth 2 server . auth . model . Service Ċ import Ġuk . gov . just ice . digital . h mp ps . oauth 2 server . service . Auth Services Service Ċ Ċ class ĠAuth Services Controller Test Ġ{ ĊĠ Ġprivate Ġval Ġauth Services Service : ĠAuth Services Service Ġ= Ġmock () ĊĠ Ġprivate Ġval Ġauthentication : ĠAuthentication Ġ= Ġmock () ĊĠ Ġprivate Ġval Ġcontroller Ġ= ĠAuth Services Controller ( auth Services Service ) ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` test Ġservices Ġreturns Ġall Ġ Ġservices `() Ġ{ ĊĠĠĠ Ġval Ġauth 1 Ġ= ĠService (" code 1 ", Ġ" name 1 ", Ġ" description 1 ", Ġ" roles 1 ", Ġ" url 1 ", Ġtrue , Ġ" email 1 ") ĊĠĠĠ Ġval Ġauth 2 Ġ= ĠService (" code 2 ", Ġ" name 2 ", Ġ" description 2 ", Ġ" roles 2 ", Ġ" url 2 ", Ġtrue , Ġ" email 2 ") ĊĠĠĠ Ġwhenever ( auth Services Service . list Enabled ()). thenReturn ( listOf ( auth 1 , Ġauth 2 )) ĊĠĠĠ Ġval Ġresponse Ġ= Ġcontroller . services () ĊĠĠĠ ĠassertThat ( response ). contains Exactly ( Auth Service ( auth 1 ), ĠAuth Service ( auth 2 )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` test Ġservices Ġreturns Ġall Ġmy Ġservices `() Ġ{ ĊĠĠĠ Ġval Ġauth 1 Ġ= ĠService (" code 1 ", Ġ" name 1 ", Ġ" description 1 ", Ġ" roles 1 ", Ġ" url 1 ", Ġtrue , Ġ" email 1 ") ĊĠĠĠ Ġval Ġauth 2 Ġ= ĠService (" code 2 ", Ġ" name 2 ", Ġ" description 2 ", Ġ" roles 2 ", Ġ" url 2 ", Ġtrue , Ġ" email 2 ") ĊĠĠĠ Ġwhenever ( auth Services Service . list Enabled ( any ())). thenReturn ( listOf ( auth 1 , Ġauth 2 )) ĊĠĠĠ Ġval Ġauthor ities Ġ= ĠlistOf ( Simple Granted Authority (" role ")) ĊĠĠĠ Ġwhenever ( authentication . author ities ). thenReturn ( author ities ) ĊĠĠĠ Ġval Ġresponse Ġ= Ġcontroller . my Services ( authentication ) ĊĠĠĠ ĠassertThat ( response ). contains Exactly ( Auth Service ( auth 1 ), ĠAuth Service ( auth 2 )) ĊĠĠĠ Ġverify ( auth Services Service ). list Enabled ( author ities ) ĊĠ Ġ} Ċ } Ċ