@Test(expected = JiraException.class) public void testGetUserRestError() throws Exception { final RestClient restClient = PowerMockito.mock(RestClient.class); when(restClient.get(anyString(),anyMap())).thenThrow(Exception.class); User.get(restClient, "username"); }
public static User get(RestClient restclient, String username) throws JiraException { JSON result = null; Map<String, String> params = new HashMap<String, String>(); params.put("username", username); try { result = restclient.get(getBaseUri() + "user", params); } catch (Exception ex) { throw new JiraException("Failed to retrieve user " + username, ex); } if (!(result instanceof JSONObject)) throw new JiraException("JSON payload is malformed"); return new User(restclient, (JSONObject) result); }
User extends Resource { public static User get(RestClient restclient, String username) throws JiraException { JSON result = null; Map<String, String> params = new HashMap<String, String>(); params.put("username", username); try { result = restclient.get(getBaseUri() + "user", params); } catch (Exception ex) { throw new JiraException("Failed to retrieve user " + username, ex); } if (!(result instanceof JSONObject)) throw new JiraException("JSON payload is malformed"); return new User(restclient, (JSONObject) result); } }
User extends Resource { public static User get(RestClient restclient, String username) throws JiraException { JSON result = null; Map<String, String> params = new HashMap<String, String>(); params.put("username", username); try { result = restclient.get(getBaseUri() + "user", params); } catch (Exception ex) { throw new JiraException("Failed to retrieve user " + username, ex); } if (!(result instanceof JSONObject)) throw new JiraException("JSON payload is malformed"); return new User(restclient, (JSONObject) result); } protected  User(RestClient restclient, JSONObject json); }
User extends Resource { public static User get(RestClient restclient, String username) throws JiraException { JSON result = null; Map<String, String> params = new HashMap<String, String>(); params.put("username", username); try { result = restclient.get(getBaseUri() + "user", params); } catch (Exception ex) { throw new JiraException("Failed to retrieve user " + username, ex); } if (!(result instanceof JSONObject)) throw new JiraException("JSON payload is malformed"); return new User(restclient, (JSONObject) result); } protected  User(RestClient restclient, JSONObject json); static User get(RestClient restclient, String username); @Override String toString(); boolean isActive(); Map<String, String> getAvatarUrls(); String getDisplayName(); String getEmail(); String getName(); }
User extends Resource { public static User get(RestClient restclient, String username) throws JiraException { JSON result = null; Map<String, String> params = new HashMap<String, String>(); params.put("username", username); try { result = restclient.get(getBaseUri() + "user", params); } catch (Exception ex) { throw new JiraException("Failed to retrieve user " + username, ex); } if (!(result instanceof JSONObject)) throw new JiraException("JSON payload is malformed"); return new User(restclient, (JSONObject) result); } protected  User(RestClient restclient, JSONObject json); static User get(RestClient restclient, String username); @Override String toString(); boolean isActive(); Map<String, String> getAvatarUrls(); String getDisplayName(); String getEmail(); String getName();  }