package Ġcom . we ed ow . search y . query . specification Ċ Ċ import Ġcom . n ha ar man . mock it ok otlin 2 .* Ċ import Ġcom . query dsl . core . types . Predicate Ċ import Ġcom . query dsl . core . types . Visitor Ċ import Ġcom . we ed ow . search y . query . QueryBuilder Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . extension . Extend With Ċ import Ġorg . mockito . junit . jupiter . Mockito Extension Ċ Ċ @ Extend With ( Mockito Extension :: class ) Ċ internal Ġclass ĠSpecification Test Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ no _ predicate () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġno Predicate Ġ= ĠSpecification . NO _ PRE D ICATE ĊĊĠĠĠĠĠĠĠ Ġval Ġvisitor Ġ= Ġmock < Visitor < Any , Ġin ĠAny >>() ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= Ġmock < Any >() ĊĊĠĠĠĠĠĠĠ ĠassertThat ( no Predicate . accept ( visitor , Ġcontext )). isNull () ĊĠĠĠĠĠĠĠ ĠassertThat ( no Predicate . type ). isEqualTo ( Boolean :: class . java ) ĊĠĠĠĠĠĠĠ ĠassertThat ( no Predicate . not ()). is Same As ( no Predicate ) ĊĊĠĠĠĠĠĠĠ Ġverify Zero Interactions ( visitor ) ĊĠĠĠĠĠĠĠ Ġverify Zero Interactions ( context ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ not _ with _ null _ specification () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġquery Builder Ġ= Ġmock < QueryBuilder < Any >>() ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠSpecification . not < Any >( null ). to Predicate ( query Builder ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( result ). is Same As ( Specification . NO _ PRE D ICATE ) ĊĊĠĠĠĠĠĠĠ Ġverify Zero Interactions ( query Builder ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ not () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġquery Builder Ġ= Ġmock < QueryBuilder < Any >>() ĊĊĠĠĠĠĠĠĠ Ġval Ġpredicate Ġ= Ġmock < Predicate >() ĊĠĠĠĠĠĠĠ Ġval Ġspec Ġ= Ġmock < Specification < Any >> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Ġ{ Ġthis . to Predicate ( query Builder ) Ġ}. thenReturn ( predicate ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġnot Predicate Ġ= Ġmock < Predicate >() ĊĠĠĠĠĠĠĠ Ġwhenever ( query Builder . not ( predicate )). thenReturn ( not Predicate ) ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠSpecification . not ( spec ). to Predicate ( query Builder ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( result ). is Same As ( not Predicate ) ĊĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( query Builder ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ where _ with _ null _ specification () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġquery Builder Ġ= Ġmock < QueryBuilder < Any >>() ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠSpecification . where < Any >( null ). to Predicate ( query Builder ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( result ). is Same As ( Specification . NO _ PRE D ICATE ) ĊĊĠĠĠĠĠĠĠ Ġverify Zero Interactions ( query Builder ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ where () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġspec Ġ= Ġmock < Specification < Any >>() ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠSpecification . where ( spec ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( result ). is Same As ( spec ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ and () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġquery Builder Ġ= Ġmock < QueryBuilder < Any >>() ĊĊĠĠĠĠĠĠĠ Ġval Ġpredicate 1 Ġ= Ġmock < Predicate >() ĊĠĠĠĠĠĠĠ Ġval Ġspecification 1 Ġ= Ġspy < Specification < Any >> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Ġ{ Ġthis . to Predicate ( query Builder ) Ġ}. thenReturn ( predicate 1 ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġpredicate 2 Ġ= Ġmock < Predicate >() ĊĠĠĠĠĠĠĠ Ġval Ġspecification 2 Ġ= Ġspy < Specification < Any >> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Ġ{ Ġthis . to Predicate ( query Builder ) Ġ}. thenReturn ( predicate 2 ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġpredicate Ġ= Ġmock < Predicate >() ĊĠĠĠĠĠĠĠ Ġwhenever ( query Builder . and ( predicate 1 , Ġpredicate 2 )). thenReturn ( predicate ) ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġspecification 1 . and ( specification 2 ). to Predicate ( query Builder ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( result ). is Same As ( predicate ) ĊĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( query Builder ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ or () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġquery Builder Ġ= Ġmock < QueryBuilder < Any >>() ĊĊĠĠĠĠĠĠĠ Ġval Ġpredicate 1 Ġ= Ġmock < Predicate >() ĊĠĠĠĠĠĠĠ Ġval Ġspecification 1 Ġ= Ġspy < Specification < Any >> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Ġ{ Ġthis . to Predicate ( query Builder ) Ġ}. thenReturn ( predicate 1 ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġpredicate 2 Ġ= Ġmock < Predicate >() ĊĠĠĠĠĠĠĠ Ġval Ġspecification 2 Ġ= Ġspy < Specification < Any >> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Ġ{ Ġthis . to Predicate ( query Builder ) Ġ}. thenReturn ( predicate 2 ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġpredicate Ġ= Ġmock < Predicate >() ĊĠĠĠĠĠĠĠ Ġwhenever ( query Builder . or ( predicate 1 , Ġpredicate 2 )). thenReturn ( predicate ) ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġspecification 1 . or ( specification 2 ). to Predicate ( query Builder ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( result ). is Same As ( predicate ) ĊĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( query Builder ) ĊĠĠĠ Ġ} Ċ }