package Ġcom . wand era . workshop . service Ċ Ċ import Ġcom . wand era . workshop . model . Duplicate Id Exception Ċ import Ġcom . wand era . workshop . model . K weet Ċ import Ġorg . junit . Assert . assertEquals Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . rules . Expected Exception Ċ Ċ class ĠK weet Service Test Ġ{ ĊĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġval Ġthrown : ĠExpected Exception Ġ= ĠExpected Exception . none () ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġservice : ĠK weet Service ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġservice Ġ= ĠK weet Service () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Post K weet () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals ( service . post K weet ( K weet ( id Ġ= Ġ" some ", ĠuserId Ġ= Ġ" user ")), Ġ" some ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Post Duplicate K weet () Ġ{ ĊĠĠĠĠĠĠĠ Ġthrown . expect ( Duplicate Id Exception :: class . java ) ĊĠĠĠĠĠĠĠ Ġservice . post K weet ( K weet ( id Ġ= Ġ" some ", ĠuserId Ġ= Ġ" user ")) ĊĠĠĠĠĠĠĠ Ġservice . post K weet ( K weet ( id Ġ= Ġ" some ", ĠuserId Ġ= Ġ" user ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠtestGet K weet () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġk weet Ġ= ĠK weet ( id Ġ= Ġ" some ", ĠuserId Ġ= Ġ" user ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( service . post K weet ( k weet ), Ġ" some ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( service . get K weet (" some "), Ġk weet ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Delete K weet () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġk weet Ġ= ĠK weet ( id Ġ= Ġ" some ", ĠuserId Ġ= Ġ" user ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( service . post K weet ( k weet ), Ġ" some ") ĊĠĠĠĠĠĠĠ Ġservice . delete K weet (" some ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( service . get K weet (" some "), Ġnull ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest List K weets () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals ( service . post K weet ( K weet ( id Ġ= Ġ" some ", ĠuserId Ġ= Ġ" user ")), Ġ" some ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( service . post K weet ( K weet ( id Ġ= Ġ" some 2 ", ĠuserId Ġ= Ġ" user ")), Ġ" some 2 ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( service . get K weets ForUser (" user "). size , Ġ 2 ) ĊĠĠĠ Ġ} Ċ }