UserInfo implements Serializable { public Object lookUp() { if (!name.isEmpty()) { BitbucketClient bitbucketClient = getBitbucketClient(); user = bitbucketClient.getUserAccount(name); if (!isFound()) { FacesContext facesContext = FacesContext.getCurrentInstance(); UIComponent c = UIComponent.getCurrentComponent(facesContext); facesContext.addMessage(c.getClientId(facesContext), new FacesMessage("User not found.")); } } else { user = null; } return null; } @Inject  UserInfo(final SessionUser sessionUser); SessionUser getSessionUser(); String getName(); void setName(final String value); BitbucketAccount getUser(); boolean isFound(); Object lookUp();  }
@Disabled("Faces runtime is required") @Test void testLookUp() { UserInfo userInfo = new UserInfo(sessionUser); Object outcome; userInfo.setName(""); outcome = userInfo.lookUp(); assertNull(outcome); assertNull(userInfo.getUser()); assertEquals(false, userInfo.isFound()); userInfo.setName("kazssym"); outcome = userInfo.lookUp(); assertNull(outcome); assertNotNull(userInfo.getUser()); assertEquals(true, userInfo.isFound()); assertEquals("kazssym", userInfo.getUser().getUsername()); }