package Ġcom . s oci ete gener ale . github crawler . parsers Ċ Ċ import Ġcom . s oci ete gener ale . github crawler . model . Author Ċ import Ġcom . s oci ete gener ale . github crawler . model . commit . Commit Ċ import Ġcom . s oci ete gener ale . github crawler . model . commit . Commit Stats Ċ import Ġcom . s oci ete gener ale . github crawler . model . commit . Detailed Commit Ċ import Ġcom . s oci ete gener ale . github crawler . model . team . Membership Ċ import Ġcom . s oci ete gener ale . github crawler . model . team . Team Ċ import Ġcom . s oci ete gener ale . github crawler . model . team . Team Member Ċ import Ġcom . s oci ete gener ale . github crawler . remote . Remote GitHub Ċ import Ġcom . s oci ete gener ale . github crawler . repo Task To Perform . ownership . Membership Parser Ċ import Ġcom . s oci ete gener ale . github crawler . repo Task To Perform . ownership . Ownership Parser Impl Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . Test Ċ import Ġorg . mockito . Mockito .* Ċ Ċ class ĠOwn ership Parser Impl Test Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġgithub Client : ĠRemote GitHub Ġ= Ġmock ( Remote GitHub :: class . java ) ĊĠĠĠ Ġprivate Ġval Ġmembership Parser : ĠMembers hip Parser Ġ= Ġmock ( Membership Parser :: class . java ) ĊĠĠĠ Ġprivate Ġval Ġorganization Name Ġ= Ġ" F CC _ OS D " ĊĠĠĠ Ġprivate Ġval Ġrepository FullName Ġ= Ġ" decl arative - process " ĊĠĠĠ Ġprivate Ġval Ġmember Id To Team Name Ġ= ĠMembers hip () ĊĠĠĠ Ġprivate Ġval Ġlast Commit Number Ġ= Ġ 5 ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould _ compute _ team _ ownership _ for _ a _ repo () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// Given ĊĠĠĠĠĠĠĠ Ġmember Id To Team Name . add ( Team (" 2 ", Ġ" St ark "), Ġset Of ( Team Member (" U 1 ", Ġ" user Five "), ĠTeam Member (" U 2 ", Ġ" user One "))) ĊĠĠĠĠĠĠĠ Ġmember Id To Team Name . add ( Team (" 3 ", Ġ" White ĠWalk ers "), Ġset Of ( Team Member (" U 3 ", Ġ" User Four "), ĠTeam Member (" U 4 ", Ġ" User Three "))) ĊĊĠĠĠĠĠĠĠ Ġ` when `( membership Parser . compute Membership ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( member Id To Team Name ) ĊĊĊĠĠĠĠĠĠĠ Ġdo Return ( set Of ( Commit (" 1 "), ĠCommit (" 2 "), ĠCommit (" 3 "))) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. ` when `( github Client ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. fetch Commits ( repository FullName , Ġlast Commit Number ) ĊĊĠĠĠĠĠĠĠ Ġdo Return ( Detailed Commit (" 1 ", ĠAuthor (" 1 2 ", Ġ" user Five "), ĠCommit Stats ( 5 0 0 ))) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. ` when `( github Client ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. fetch Commit ( repository FullName , Ġ" 1 ") ĊĠĠĠĠĠĠĠ Ġdo Return ( Detailed Commit (" 2 ", ĠAuthor (" 1 3 ", Ġ" User Four "), ĠCommit Stats ( 4 5 0 ))) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. ` when `( github Client ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. fetch Commit ( repository FullName , Ġ" 2 ") ĊĠĠĠĠĠĠĠ Ġdo Return ( Detailed Commit (" 3 ", ĠAuthor (" 1 4 ", Ġ" User Three "), ĠCommit Stats ( 4 9 ))) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. ` when `( github Client ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. fetch Commit ( repository FullName , Ġ" 3 ") ĊĊĠĠĠĠĠĠĠ Ġ// When ĊĠĠĠĠĠĠĠ Ġval Ġteam Owner : ĠString Ġ= ĠOwn ership Parser Impl ( github Client , Ġmembership Parser , Ġorganization Name ). compute Ownership For ( Ġrepository FullName , Ġlast Commit Number ) ĊĊĠĠĠĠĠĠĠ Ġ// Then ĊĠĠĠĠĠĠĠ Ġverify ( github Client ). fetch Commits ( repository FullName , Ġlast Commit Number ) ĊĠĠĠĠĠĠĠ ĠassertThat ( team Owner ). isEqualTo (" St ark ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould _ not _ compute _ team _ ownership _ for _ a _ repo _ if _ membership _ not _ provided () Ġ{ ĊĊĠĠĠĠĠĠĠ Ġ// Given ĊĠĠĠĠĠĠĠ Ġ` when `( membership Parser . compute Membership ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( member Id To Team Name ) ĊĊĠĠĠĠĠĠĠ Ġ// When ĊĠĠĠĠĠĠĠ Ġval Ġteam Owner : ĠString Ġ= ĠOwn ership Parser Impl ( github Client , Ġmembership Parser , Ġorganization Name ). compute Ownership For ( repository FullName , Ġlast Commit Number ) ĊĊĠĠĠĠĠĠĠ Ġ// Then ĊĠĠĠĠĠĠĠ Ġverify Zero Interactions ( github Client ) ĊĠĠĠĠĠĠĠ ĠassertThat ( team Owner ). isEqualTo (" Undefined ") ĊĠĠĠ Ġ} Ċ Ċ }