Groovy web console

subscribe to the feed Subscribe
to this
site

RND4U Interview test

Published 2 months ago by Long Nguyen
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
def users = [    [loginName : 'dav1hc', reportTo : 'yth2nt'],
    [loginName : 'yth2nt', reportTo : 'nlv3ut'],
    [loginName : 'nlv3ut', reportTo : 'tre4uc'],
    [loginName : 'thf1vb', reportTo : 'rty2hb'],
    [loginName : 'rty2hb', reportTo : 'mul3ut'],
    [loginName : 'mul3ut', reportTo : 'ocb4uc'],
    [loginName : 'uio1hc', reportTo : 'tyy2hc'],
    [loginName : 'tyy2hc', reportTo : 'mlv31t'],
    [loginName : 'mlv31t', reportTo : 'tuo4tj'],
]

assert getAllManagers(users, 'dav1hc') == ['yth2nt', 'nlv3ut', 'tre4uc']
assert getAllManagers(users, 'thf1vb') == ['rty2hb', 'mul3ut', 'ocb4uc']
assert getAllManagers(users, 'uio1hc') == ['tyy2hc', 'mlv31t', 'tuo4tj']
assert getAllManagers(users, 'tyy2hc') == ['mlv31t', 'tuo4tj']
assert getAllManagers(users, 'mul3ut') == ['ocb4uc']
assert getAllManagers(users, 'tuo4tj') == []
assert getAllManagers(users, 'thj1rt') == []
println "Pass All!"

return
//--------------------------------------------------------
/**
 * Find all possible manager of the employee
 * @param creator: login name
 * return list of login name of managers
 */
def getAllManagers(def users, def employee) {
    //Your code here

}