package Ġcom . netflix . spin n aker . ke el . intent . processor . converter Ċ Ċ import Ġcom . netflix . spin n aker . ham k rest . should Equal Ċ import Ġcom . netflix . spin n aker . ke el . clo udd river . Cloud Driver Cache Ċ import Ġcom . netflix . spin n aker . ke el . clo udd river . model . Elastic LoadBalancer Ċ import Ġcom . netflix . spin n aker . ke el . clo udd river . model . Elastic LoadBalancer . Listener Description Ċ import Ġcom . netflix . spin n aker . ke el . clo udd river . model . Mon iker Ċ import Ġcom . netflix . spin n aker . ke el . clo udd river . model . Network Ċ import Ġcom . netflix . spin n aker . ke el . clo udd river . model . SecurityGroup Ċ import Ġcom . netflix . spin n aker . ke el . intent . Amazon Elastic LoadBalancer Spec Ċ import Ġcom . netflix . spin n aker . ke el . intent . Availability Zone Config . Automatic Ċ import Ġcom . netflix . spin n aker . ke el . intent . HealthCheck Spec Ċ import Ġcom . netflix . spin n aker . ke el . intent . Health Endpoint . Http Ċ import Ġcom . netflix . spin n aker . ke el . intent . Health Endpoint . Https Ċ import Ġcom . netflix . spin n aker . ke el . model . Listener Ċ import Ġcom . netflix . spin n aker . ke el . model . Protocol .* Ċ import Ġcom . netflix . spin n aker . ke el . model . Scheme . internal Ċ import Ġcom . n ha ar man . mockito _ kotlin .* Ċ import Ġorg . junit . Assert . fail Ċ import Ġorg . junit . jupiter . api . Test Ċ Ċ object ĠLoad Balancer Converter Test Ġ{ ĊĊĠ Ġval Ġcloud Driver Ġ= Ġmock < Cloud Driver Cache >() ĊĠ Ġval Ġconverter Ġ= ĠLoad Balancer Converter ( cloud Driver ) ĊĊĠ Ġval Ġspec Ġ= ĠAmazon Elastic LoadBalancer Spec ( ĊĠĠĠ Ġvpc Name Ġ= Ġ" vpc Name ", ĊĠĠĠ Ġapplication Ġ= Ġ" cov fe fe ", ĊĠĠĠ Ġname Ġ= Ġ" cov fe fe - el b ", ĊĠĠĠ Ġcloud Provider Ġ= Ġ" aws ", ĊĠĠĠ Ġaccount Name Ġ= Ġ" prod ", ĊĠĠĠ Ġregion Ġ= Ġ" us - west - 2 ", ĊĠĠĠ Ġsecurity Group Names Ġ= Ġset Of (" cov fe fe ", Ġ" nf - infrastructure ", Ġ" nf - datac enter "), ĊĠĠĠ Ġavailability Zones Ġ= ĠAutomatic , ĊĠĠĠ Ġscheme Ġ= Ġinternal , ĊĠĠĠ Ġlisteners Ġ= Ġset Of ( Listener ( TCP , Ġ 8 0 , ĠTCP , Ġ 7 0 0 1 ), ĠListener ( SSL , Ġ 4 4 3 , ĠSSL , Ġ 7 0 0 2 )), ĊĠĠĠ Ġhealth Check Ġ= ĠHealth Check Spec ( Http ( 7 0 0 1 , Ġ"/ health check ")) ĊĠ Ġ) ĊĊĠ Ġval Ġel b Ġ= ĠElastic LoadBalancer ( ĊĠĠĠ Ġvpc id Ġ= Ġ" vpc - 1 ", ĊĠĠĠ Ġload Balancer Name Ġ= Ġ" cov fe fe - el b ", ĊĠĠĠ Ġsecurity Groups Ġ= Ġset Of (" 1 ", Ġ" 2 ", Ġ" 3 "), ĊĠĠĠ Ġavailability Zones Ġ= Ġset Of (" us - west - 2 a ", Ġ" us - west - 2 b ", Ġ" us - west - 2 c "), ĊĠĠĠ Ġscheme Ġ= Ġinternal , ĊĠĠĠ Ġhealth Check Ġ= ĠElastic LoadBalancer . HealthCheck (" HTTPS : 7 0 0 2 / health check ", Ġ 3 , Ġ 3 0 , Ġ 5 , Ġ 2 0 ), ĊĠĠĠ Ġlistener Descriptions Ġ= Ġset Of ( ĊĠĠĠĠĠ ĠListener Description ( Listener ( HTTP , Ġ 8 0 , ĠHTTP , Ġ 7 0 0 1 )), ĊĠĠĠĠĠ ĠListener Description ( Listener ( HTTPS , Ġ 4 4 3 , ĠHTTPS , Ġ 7 0 0 2 )) ĊĠĠĠ Ġ) ĊĠ Ġ) ĊĊĠ Ġval Ġvpc Ġ= ĠNetwork ( spec . cloud Provider , Ġel b . vpc id !! , Ġspec . vpc Name , Ġspec . account Name , Ġspec . region ) ĊĠ Ġval Ġzones Ġ= Ġel b . availability Zones ĊĠ Ġval Ġsecurity Groups Ġ= Ġset Of ( ĊĠĠĠ ĠSecurity Group ( type Ġ= Ġ" aws ", Ġid Ġ= Ġ" 1 ", Ġname Ġ= Ġ" nf - infrastructure ", Ġdescription Ġ= Ġnull , Ġaccount Name Ġ= Ġ" prod ", Ġregion Ġ= Ġ" us - west - 2 ", Ġvpc Id Ġ= Ġ" vpc - 1 ", Ġmon iker Ġ= ĠMon iker (" cov fe fe ")), ĊĠĠĠ ĠSecurity Group ( type Ġ= Ġ" aws ", Ġid Ġ= Ġ" 2 ", Ġname Ġ= Ġ" nf - datac enter ", Ġdescription Ġ= Ġnull , Ġaccount Name Ġ= Ġ" prod ", Ġregion Ġ= Ġ" us - west - 2 ", Ġvpc Id Ġ= Ġ" vpc - 1 ", Ġmon iker Ġ= ĠMon iker (" cov fe fe ")), ĊĠĠĠ ĠSecurity Group ( type Ġ= Ġ" aws ", Ġid Ġ= Ġ" 3 ", Ġname Ġ= Ġ" cov fe fe ", Ġdescription Ġ= Ġnull , Ġaccount Name Ġ= Ġ" prod ", Ġregion Ġ= Ġ" us - west - 2 ", Ġvpc Id Ġ= Ġ" vpc - 1 ", Ġmon iker Ġ= ĠMon iker (" cov fe fe ")) ĊĠ Ġ) ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` con verts Ġspec Ġto Ġsystem Ġstate `() Ġ{ ĊĠĠĠ Ġwhenever ( cloud Driver . network By ( spec . vpc Name !! , Ġspec . account Name , Ġspec . region )) Ġdo Return Ġvpc ĊĠĠĠ Ġwhenever ( cloud Driver . availability Zones By ( spec . account Name , Ġvpc . id , Ġspec . region )) Ġdo Return Ġzones ĊĊĠĠĠ Ġconverter . convertTo State ( spec ) ĊĠĠĠĠĠ Ġ. apply Ġ{ ĊĠĠĠĠĠĠĠ Ġvpc id Ġshould Equal Ġvpc . id ĊĠĠĠĠĠĠĠ Ġload Balancer Name Ġshould Equal Ġspec . name ĊĠĠĠĠĠĠĠ Ġhealth Check . target Ġshould Equal Ġspec . health Check . target . toString () ĊĠĠĠĠĠĠĠ Ġhealth Check . healthy Threshold Ġshould Equal Ġspec . health Check . healthy Threshold ĊĠĠĠĠĠĠĠ Ġhealth Check . interval Ġshould Equal Ġspec . health Check . interval ĊĠĠĠĠĠĠĠ Ġhealth Check . timeout Ġshould Equal Ġspec . health Check . timeout ĊĠĠĠĠĠĠĠ Ġhealth Check . un healthy Threshold Ġshould Equal Ġspec . health Check . un healthy Threshold ĊĠĠĠĠĠĠĠ Ġavailability Zones Ġshould Equal Ġzones ĊĠĠĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` con verts Ġsystem Ġstate Ġto Ġspec `() Ġ{ ĊĠĠĠ Ġwhenever ( cloud Driver . network By ( el b . vpc id !! )) Ġdo Return Ġvpc ĊĠĠĠ Ġwhenever ( cloud Driver . security GroupBy ( eq ( vpc . account ), Ġany ())) Ġdo Answer Ġ{ Ġinvocation Ġ-> ĊĠĠĠĠĠ Ġsecurity Groups . first OrNull Ġ{ Ġit . id Ġ== Ġinvocation . arguments [ 1 ] Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġwhenever ( cloud Driver . availability Zones By ( vpc . account , Ġvpc . id , Ġvpc . region )) Ġdo Return Ġzones ĊĊĠĠĠ Ġconverter . convert From State ( el b ) ĊĠĠĠĠĠ Ġ. let Ġ{ Ġspec Ġ-> ĊĠĠĠĠĠĠĠ Ġspec . account Name Ġshould Equal Ġvpc . account ĊĠĠĠĠĠĠĠ Ġspec . cloud Provider Ġshould Equal Ġvpc . cloud Provider ĊĠĠĠĠĠĠĠ Ġspec . name Ġshould Equal Ġel b . load Balancer Name ĊĠĠĠĠĠĠĠ Ġspec . region Ġshould Equal Ġvpc . region ĊĠĠĠĠĠĠĠ Ġspec . security Group Names Ġshould Equal Ġsecurity Groups . map Ġ{ Ġit . name Ġ}. toSet () ĊĠĠĠĠĠĠĠ Ġif Ġ( spec Ġis ĠAmazon Elastic LoadBalancer Spec ) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġspec . vpc Name Ġshould Equal Ġvpc . name ĊĠĠĠĠĠĠĠĠĠ Ġspec . availability Zones Ġshould Equal ĠAutomatic ĊĠĠĠĠĠĠĠĠĠ Ġspec . health Check Ġshould Equal ĠHealth Check Spec ( Https ( 7 0 0 2 , Ġ"/ health check "), Ġ 3 , Ġ 3 0 , Ġ 5 , Ġ 2 0 ) ĊĠĠĠĠĠĠĠĠĠ Ġspec . listeners Ġshould Equal Ġel b . listener Descriptions . map Ġ{ Ġit . listener Ġ}. toSet () ĊĠĠĠĠĠĠĠĠĠ Ġspec . scheme Ġshould Equal Ġinternal ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġfail (" Expected Ġ${ Amazon Elastic LoadBalancer Spec :: class . simple Name } Ġbut Ġfound Ġ${ spec . java Class }") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ