package Ġcom . bs ch and ram oh an . learn . spring connect . spring boot console Ċ Ċ import Ġcom . bs ch and ram oh an . learn . spring connect . spring boot console . entity . Course Ċ import Ġcom . bs ch and ram oh an . learn . spring connect . spring boot console . entity . Student Ċ import Ġcom . bs ch and ram oh an . learn . spring connect . spring boot console . service . Course Service Ċ import Ġcom . bs ch and ram oh an . learn . spring connect . spring boot console . service . Student Service Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . assert Throws Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . boot . test . context . SpringBootTest Ċ Ċ @ SpringBootTest Ċ class ĠApplication Tests (@ Autowired Ġvar Ġcourse Service : ĠCourse Service , Ġ@ Autowired Ġvar Ġstudent Service : ĠStudent Service ) Ġ{ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Course Get () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThrows < Exception > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Service . get ( 1 ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Course Save AndGet List () Ġ{ ĊĠĠĠĠĠĠĠ Ġcourse Service . save ( ml Course ) ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġcourse Service . get ( 1 0 0 1 L ) ĊĠĠĠĠĠĠĠ Ġassert ( result . name Ġ== Ġml Course . name ) ĊĊĠĠĠĠĠĠĠ Ġcourse Service . save ( kubernetes Course ) ĊĠĠĠĠĠĠĠ Ġval Ġresults Ġ= Ġcourse Service . list () ĊĠĠĠĠĠĠĠ Ġassert ( results . isNotEmpty ()) ĊĠĠĠĠĠĠĠ Ġassert ( results . size Ġ== Ġ 2 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Student Get () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThrows < Exception > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstudent Service . get ( 1 0 0 1 L ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Student Save AndGet List () Ġ{ ĊĠĠĠĠĠĠĠ Ġstudent Service . save ( student Ch andra ) ĊĊĠĠĠĠĠĠĠ Ġassert ( student Service . get ( 1 0 0 1 L ). name Ġ== Ġstudent Ch andra . name ) ĊĊĠĠĠĠĠĠĠ Ġstudent Service . save ( student M oh an ) ĊĊĠĠĠĠĠĠĠ Ġval Ġresults Ġ= Ġstudent Service . list () ĊĊĠĠĠĠĠĠĠ Ġassert ( results . size Ġ== Ġ 2 ) ĊĊĠĠĠĠĠĠĠ Ġstudent Service . add Course ( 1 0 0 1 L , Ġ 1 0 0 1 L ) ĊĠĠĠĠĠĠĠ Ġstudent Service . add Course ( 1 0 0 1 L , Ġ 1 0 0 2 L ) ĊĠĠĠĠĠĠĠ Ġstudent Service . add Course ( 1 0 0 2 L , Ġ 1 0 0 1 L ) ĊĊĠĠĠĠĠĠĠ Ġval Ġupdated List Ġ= Ġstudent Service . list () ĊĠĠĠĠĠĠĠ Ġ// ĠWe Ġcould Ġdo Ġfilter Ġon Ġcourse [ id ] Ġif Ġwe Ġdo Ġnot Ġwant Ġthe Ġassumption Ġof Ġorder Ġof Ġreturns ĊĠĠĠĠĠĠĠ Ġassert ( updated List [ 0 ]. courses . size Ġ== Ġ 2 ) ĊĠĠĠĠĠĠĠ Ġassert ( updated List [ 1 ]. courses . size Ġ== Ġ 1 ) ĊĊĠĠĠĠĠĠĠ ĠassertThrows < Exception > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// ĠCourse Ġ 1 0 0 0 L Ġdoesn 't Ġexist ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstudent Service . add Course ( 1 0 0 2 L , Ġ 1 0 0 0 L ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// Ġsome Ġtest Ġdata ĊĠĠĠ Ġprivate Ġval Ġml Course Ġ= ĠCourse ( 1 0 0 1 L , Ġ" Machine ĠLearning ") ĊĠĠĠ Ġprivate Ġval Ġkubernetes Course Ġ= ĠCourse ( 1 0 0 2 L , Ġ" Kubernetes ") ĊĊĠĠĠ Ġprivate Ġval Ġstudent Ch andra Ġ= ĠStudent ( 1 0 0 1 L , Ġ" Ch andra ") ĊĠĠĠ Ġprivate Ġval Ġstudent M oh an Ġ= ĠStudent ( 1 0 0 2 L , Ġ" M oh an ") Ċ } Ċ