/* Ċ Ġ* ĠCopyright Ġ 2 0 2 0 ĠGoogle ĠLLC . Ċ Ġ* Ċ Ġ* ĠThis Ġcode Ġmay Ġonly Ġbe Ġused Ġunder Ġthe ĠBSD Ġstyle Ġlicense Ġfound Ġat Ċ Ġ* Ġhttp :// polymer . github . io / LICENSE . txt Ċ Ġ* Ċ Ġ* ĠCode Ġdistributed Ġby ĠGoogle Ġas Ġpart Ġof Ġthis Ġproject Ġis Ġalso Ġsubject Ġto Ġan Ġadditional ĠIP Ġrights Ċ Ġ* Ġgrant Ġfound Ġat Ċ Ġ* Ġhttp :// polymer . github . io / PAT ENTS . txt Ċ Ġ*/ Ċ Ċ package Ġar cs . core . data Ċ Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġkotlin . test . assert Fails With Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . junit . runners . JUnit 4 Ċ Ċ @ RunWith ( JUnit 4 :: class ) Ċ class ĠSchema Registry Test Ġ{ ĊĠ Ġ@ Before ĊĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠ ĠSchema Registry . clear For Test () ĊĠ Ġ} ĊĊĠ Ġ@ After ĊĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠ ĠSchema Registry . clear For Test () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġget Schema _ un registered Schema _ throws Exception () Ġ{ ĊĠĠĠ Ġassert Fails With < NoSuch ElementException > Ġ{ ĠSchema Registry . getSchema ( PRODUCT _ SCHEMA . hash ) Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġget Schema _ succ ses () Ġ{ ĊĠĠĠ ĠSchema Registry . register ( PRODUCT _ SCHEMA ) ĊĠĠĠ ĠassertThat ( Schema Registry . getSchema ( PRODUCT _ SCHEMA . hash )). isEqualTo ( PRODUCT _ SCHEMA ) ĊĠĠĠ Ġassert Fails With < NoSuch ElementException > Ġ{ ĠSchema Registry . getSchema (" other - schema - hash ") Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġget Schema _ dere gister Schema _ throws Exception () Ġ{ ĊĠĠĠ ĠSchema Registry . register ( PRODUCT _ SCHEMA ) ĊĠĠĠ ĠSchema Registry . clear For Test () ĊĠĠĠ Ġassert Fails With < NoSuch ElementException > Ġ{ ĠSchema Registry . getSchema ( PRODUCT _ SCHEMA . hash ) Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġget Schema _ overrides Registration () Ġ{ ĊĠĠĠ ĠSchema Registry . register ( PRODUCT _ SCHEMA ) ĊĠĠĠ ĠassertThat ( Schema Registry . getSchema ( PRODUCT _ SCHEMA . hash )). isEqualTo ( PRODUCT _ SCHEMA ) ĊĠĠĠ ĠSchema Registry . register ( OTHER _ PRODUCT _ SCHEMA ) ĊĠĠĠ ĠassertThat ( Schema Registry . getSchema ( PRODUCT _ SCHEMA . hash )). isEqualTo ( OTHER _ PRODUCT _ SCHEMA ) ĊĠ Ġ} ĊĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġprivate Ġval Ġproduct Schema Hash Ġ= Ġ" product - hash " ĊĊĠĠĠ Ġprivate Ġval ĠPRODUCT _ SCHEMA Ġ= ĠSchema ( ĊĠĠĠĠĠ Ġset Of ( Schema Name (" Product "), ĠSchema Name (" Thing ")), ĊĠĠĠĠĠ ĠSchema Fields ( ĊĠĠĠĠĠĠĠ Ġmap Of (" name " Ġto ĠFieldType . Text ), ĊĠĠĠĠĠĠĠ Ġmap Of (" ratings " Ġto ĠFieldType . Number ) ĊĠĠĠĠĠ Ġ), ĊĠĠĠĠĠ Ġproduct Schema Hash ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġprivate Ġval ĠOTHER _ PRODUCT _ SCHEMA Ġ= ĠSchema ( ĊĠĠĠĠĠ Ġset Of ( Schema Name (" Product "), ĠSchema Name (" Other ")), ĊĠĠĠĠĠ ĠSchema Fields ( empty Map (), Ġempty Map ()), ĊĠĠĠĠĠ Ġproduct Schema Hash ĊĠĠĠ Ġ) ĊĠ Ġ} Ċ } Ċ