package Ġcom . re les i . intel ig ent integr ated . services Ċ Ċ import Ġcom . re les i . intel ig ent integr ated . documents . Employee Ċ import Ġcom . re les i . intel ig ent integr ated . enums . Profile Enum Ċ import Ġcom . re les i . intel ig ent integr ated . repositories . Employee Repository Ċ import Ġcom . re les i . intel ig ent integr ated . utils . Password Utils Ċ import Ġorg . junit . jupiter . api . Assertions Ċ import Ġorg . junit . jupiter . api . BeforeEach Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . mockito . BDD Mockito Ċ import Ġorg . mockito . Mockito Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . boot . test . autoconfigure . data . mongo . Auto Configure Data Mongo Ċ import Ġorg . springframework . boot . test . context . SpringBootTest Ċ import Ġorg . springframework . boot . test . mock . mockito . Mock Bean Ċ import Ġorg . springframework . test . context . Active Profiles Ċ import Ġjava . util .* ĊĊ Ċ @ SpringBootTest Ċ @ Active Profiles (" test ") Ċ @ Auto Configure Data Mongo Ċ class ĠEmployee Service Test Ġ{ ĊĊĠĠĠ Ġ@ Mock Bean ĊĠĠĠ Ġprivate Ġval Ġemployee Repository : ĠEmployee Repository ? Ġ= Ġnull ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġprivate Ġval Ġemployee Service : ĠEmployee Service ? Ġ= Ġnull ĊĊĠĠĠ Ġprivate Ġfun Ġemployee (): ĠEmployee Ġ= ĊĠĠĠĠĠĠĠ ĠEmployee (" Name ", Ġemail , ĠPassword Utils (). generate BC rypt (" 1 2 3 4 5 6 "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġs sn , ĠProfile Enum . ROLE _ USER , Ġid ) ĊĊĊĠĠĠ Ġprivate Ġval Ġemail : ĠString Ġ= Ġ" email @ email . com " ĊĠĠĠ Ġprivate Ġval Ġs sn : ĠString Ġ= Ġ" 4 3 1 2 6 7 5 1 0 4 0 " ĊĠĠĠ Ġprivate Ġval Ġid : ĠString Ġ= Ġ" 1 " ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun ĠsetUp (){ ĊĠĠĠĠĠĠĠ ĠB DD Mockito . given ( employee Repository ?. save ( Mockito . any ( Employee :: class . java ))). willReturn ( employee ()) ĊĠĠĠĠĠĠĠ ĠB DD Mockito . given ( employee Repository ?. findById ( id )). willReturn ( Optional . of ( employee ())) ĊĠĠĠĠĠĠĠ ĠB DD Mockito . given ( employee Repository ?. findBy Email ( email )). willReturn ( employee ()) ĊĠĠĠĠĠĠĠ ĠB DD Mockito . given ( employee Repository ?. findBy S sn ( ss n )). willReturn ( employee ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Persist Employee (){ ĊĠĠĠĠĠĠĠ Ġval Ġemployee : ĠEmployee ? Ġ= Ġthis . employee Service ?. persist ( employee ()) ĊĠĠĠĠĠĠĠ ĠAssertions . assertNotNull ( employee ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠĠ Ġfun Ġtest Search Employee By S sn (){ ĊĠĠĠĠĠĠĠ Ġval Ġemployee : ĠEmployee ? Ġ= Ġthis . employee Service ?. search By S sn ( ss n ) ĊĠĠĠĠĠĠĠ ĠAssertions . assertNotNull ( employee ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Search Employee By Email (){ ĊĠĠĠĠĠĠĠ Ġval Ġemployee : ĠEmployee ? Ġ= Ġthis . employee Service ?. search By Email ( email ) ĊĠĠĠĠĠĠĠ ĠAssertions . assertNotNull ( employee ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Search Employee ById (){ ĊĠĠĠĠĠĠĠ Ġval Ġemployee : ĠEmployee ? Ġ= Ġthis . employee Service ?. search ById ( id ) ĊĠĠĠĠĠĠĠ ĠAssertions . assertNotNull ( employee ) ĊĠĠĠ Ġ} Ċ }