String locale = account.asHuman().getLocale(); if (locale != null) { String requestLocale = UrlParameters.getParameters(request.getQueryString()).get("locale");
public void testGetAccountNotLoggedUser() throws InvalidParticipantAddress, PersistenceException, IOException { // Mock data accountStore.putAccount(ACCOUNT_JOE); when(sessionManager.getLoggedInUser((HttpSession) anyObject())).thenReturn(ACCOUNT_MAT.getId()); when(sessionManager.getLoggedInUser((HttpServletRequest) anyObject())).thenReturn( ACCOUNT_MAT.getId()); // Test AccountServiceData requestData = new AccountServiceData(); ByteArrayOutputStream responseStream = new ByteArrayOutputStream(); executeService("/account/joe", "GET", requestData, responseStream, HttpServletResponse.SC_OK); AccountServiceData responseData = (AccountServiceData) ServiceData.fromJson(responseStream.toString("UTF-8"), AccountServiceData.class); assertNull(responseData.email); assertEquals(ACCOUNT_JOE.getLocale(), responseData.locale); assertTrue(responseData.avatarUrl.contains("image.png")); }
public void testGetAccount() throws InvalidParticipantAddress, PersistenceException, IOException { // Mock data accountStore.putAccount(ACCOUNT_JOE); when(sessionManager.getLoggedInUser((HttpSession) anyObject())).thenReturn(ACCOUNT_JOE.getId()); when(sessionManager.getLoggedInUser((HttpServletRequest) anyObject())).thenReturn( ACCOUNT_JOE.getId()); // Test AccountServiceData requestData = new AccountServiceData(); ByteArrayOutputStream responseStream = new ByteArrayOutputStream(); executeService("/account/joe", "GET", requestData, responseStream, HttpServletResponse.SC_OK); AccountServiceData responseData = (AccountServiceData) ServiceData.fromJson(responseStream.toString("UTF-8"), AccountServiceData.class); assertEquals(ACCOUNT_JOE.getEmail(), responseData.email); assertEquals(ACCOUNT_JOE.getLocale(), responseData.locale); assertTrue(responseData.avatarUrl.contains("image.png")); }