package Ġtest . bar ine k . continu um . projects Ċ Ċ import Ġcom . fasterxml . jackson . core . type . Type Reference Ċ import Ġio . bar ine k . continu um . j db cs upport . DataSource Config Ċ import Ġio . bar ine k . continu um . j db cs upport . Jdbc Template Ċ import Ġio . bar ine k . continu um . projects . Project Controller V 1 Ċ import Ġio . bar ine k . continu um . projects . Project Data Gateway Ċ import Ġio . bar ine k . continu um . projects . Project Info V 1 Ċ import Ġio . bar ine k . continu um . rest support . Basic App Ċ import Ġio . bar ine k . continu um . test support . Test Controller Support Ċ import Ġio . bar ine k . continu um . test support . Test Scenario Support Ċ import Ġorg . apache . http . message . Basic NameValuePair Ċ import Ġorg . eclipse . jetty . server . handler . Handler List Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġkotlin . test . assertEquals Ċ import Ġkotlin . test . assertFalse Ċ Ċ class ĠProject Controller V 1 Test Ġ: ĠTest Controller Support () Ġ{ ĊĠĠĠ Ġval ĠdataSource Ġ= ĠDataSource Config (). create DataSource (" registration ") ĊĊĠĠĠ Ġinternal Ġvar Ġapp : ĠBasic App Ġ= Ġobject Ġ: ĠBasic App () Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġget Port () Ġ= Ġ 8 0 8 1 ĊĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġhandler List () Ġ= ĠHandler List (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadd Handler ( Project Controller V 1 ( mapper , ĠProject Data Gateway ( Jdbc Template ( dataSource )))) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ ĠJdbc Template ( dataSource ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexecute (" delete Ġfrom Ġprojects ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexecute (" delete Ġfrom Ġaccounts ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexecute (" delete Ġfrom Ġusers ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġapp . start () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠĠĠĠĠ Ġapp . stop () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Create () Ġ{ ĊĠĠĠĠĠĠĠ ĠTest Scenario Support ( dataSource ). load Test Scenario (" jack s - test - scenario ") ĊĊĠĠĠĠĠĠĠ Ġval Ġjson Ġ= Ġ"{\" accountId \": 1 6 7 3 ,\" name \":\" a Project \" }" ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġtemplate . post (" http :// localhost : 8 0 8 1 / projects ", Ġ" application / vnd . app continu um . v 1 + json ", Ġjson ) ĊĠĠĠĠĠĠĠ Ġval Ġactual Ġ= Ġmapper . readValue ( response , ĠProject Info V 1 :: class . java ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 6 7 3 L , Ġactual . accountId ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" a Project ", Ġactual . name ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" project Ġinfo ", Ġactual . info ) ĊĠĠĠĠĠĠĠ Ġassert ( actual . active ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest List () Ġ{ ĊĠĠĠĠĠĠĠ ĠTest Scenario Support ( dataSource ). load Test Scenario (" jack s - test - scenario ") ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġtemplate . get (" http :// localhost : 8 0 8 1 / projects ", Ġ" application / vnd . app continu um . v 1 + json ", ĠBasic NameValuePair (" accountId ", Ġ" 1 6 7 3 ")) ĊĠĠĠĠĠĠĠ Ġval Ġlist : ĠList < Project Info V 1 > Ġ= Ġmapper . readValue ( response , Ġobject Ġ: ĠType Reference < List < Project Info V 1 >>() Ġ{}) ĊĠĠĠĠĠĠĠ Ġval Ġactual Ġ= Ġlist . first () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 5 5 4 3 2 L , Ġactual . id ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 6 7 3 L , Ġactual . accountId ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" Flag ship ", Ġactual . name ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" project Ġinfo ", Ġactual . info ) ĊĠĠĠĠĠĠĠ Ġassert ( actual . active ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠtestGet () Ġ{ ĊĠĠĠĠĠĠĠ ĠTest Scenario Support ( dataSource ). load Test Scenario (" jack s - test - scenario ") ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġtemplate . get (" http :// localhost : 8 0 8 1 / project ", Ġ" application / vnd . app continu um . v 1 + json ", ĠBasic NameValuePair (" projectId ", Ġ" 5 5 4 3 1 ")) ĊĠĠĠĠĠĠĠ Ġval Ġactual Ġ= Ġmapper . readValue ( response , ĠProject Info V 1 :: class . java ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 5 5 4 3 1 L , Ġactual . id ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 6 7 3 L , Ġactual . accountId ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" Hover craft ", Ġactual . name ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" project Ġinfo ", Ġactual . info ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( actual . active ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest NotFound () Ġ{ ĊĠĠĠĠĠĠĠ ĠTest Scenario Support ( dataSource ). load Test Scenario (" jack s - test - scenario ") ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġtemplate . get (" http :// localhost : 8 0 8 1 / project ", Ġ" application / vnd . app continu um . v 1 + json ", ĠBasic NameValuePair (" projectId ", Ġ" 5 2 8 0 ")) ĊĠĠĠĠĠĠĠ Ġassert ( response . isBlank ()) ĊĠĠĠ Ġ} Ċ }