@Test public void getReporter() { Issue issue = new Issue(null, Utils.getTestIssue()); assertNotNull(issue.getReporter()); User reporter = issue.getReporter(); assertEquals(reporter.getDisplayName(), "Joseph McCarthy"); assertEquals(reporter.getName(), "joseph"); assertTrue(reporter.isActive()); assertEquals(reporter.getEmail(), "*****@*****.**"); Map<String, String> avatars = reporter.getAvatarUrls(); assertNotNull(avatars); assertEquals(avatars.size(), 4); assertEquals( "https://secure.gravatar.com/avatar/a5a271f9eee8bbb3795f41f290274f8c?d=mm&s=16", avatars.get("16x16")); assertEquals( "https://secure.gravatar.com/avatar/a5a271f9eee8bbb3795f41f290274f8c?d=mm&s=24", avatars.get("24x24")); assertEquals( "https://secure.gravatar.com/avatar/a5a271f9eee8bbb3795f41f290274f8c?d=mm&s=32", avatars.get("32x32")); assertEquals( "https://secure.gravatar.com/avatar/a5a271f9eee8bbb3795f41f290274f8c?d=mm&s=48", avatars.get("48x48")); }
@Test public void testJSONDeserializer() throws IOException, URISyntaxException { User user = new User(new RestClient(null, new URI("/123/asd")), getTestJSON()); assertEquals(user.getName(), username); assertEquals(user.getDisplayName(), displayName); assertEquals(user.getEmail(), email); assertEquals(user.getId(), userID); Map<String, String> avatars = user.getAvatarUrls(); assertEquals( "https://secure.gravatar.com/avatar/a5a271f9eee8bbb3795f41f290274f8c?d=mm&s=16", avatars.get("16x16")); assertEquals( "https://secure.gravatar.com/avatar/a5a271f9eee8bbb3795f41f290274f8c?d=mm&s=24", avatars.get("24x24")); assertEquals( "https://secure.gravatar.com/avatar/a5a271f9eee8bbb3795f41f290274f8c?d=mm&s=32", avatars.get("32x32")); assertEquals( "https://secure.gravatar.com/avatar/a5a271f9eee8bbb3795f41f290274f8c?d=mm&s=48", avatars.get("48x48")); assertTrue(user.isActive()); }
@Test public void change_one_field_and_other_attributes_are_the_same() { createFullUser("cnaoaats"); createUpdateUserWithJustOtherNickname(); updateUser(); assertNotEquals(testUser.getNickName(), returnUser.getNickName()); assertEquals(testUser.isActive(), returnUser.isActive()); assertEquals(testUser.getDisplayName(), returnUser.getDisplayName()); assertEquals(testUser.getExternalId(), returnUser.getExternalId()); assertEquals(testUser.getLocale(), returnUser.getLocale()); assertEquals(testUser.getPreferredLanguage(), returnUser.getPreferredLanguage()); assertEquals(testUser.getProfileUrl(), returnUser.getProfileUrl()); assertEquals(testUser.getTimezone(), returnUser.getTimezone()); assertEquals(testUser.getTitle(), returnUser.getTitle()); assertEquals(testUser.getUserType(), returnUser.getUserType()); assertEquals(testUser.getName().getFamilyName(), returnUser.getName().getFamilyName()); }
public EditableUser(final User source) { this.source = source; this.displayName = source.getDisplayName(); this.email = source.getEmail(); this.login = source.getLogin(); this.authenticationHash = source.getAuthenticationHash(); this.loginDisabled = source.isDisabled(); this.key = source.getKey(); this.modifiedTime = source.getModifiedTime(); this.profile = source.getProfile().copy(); }
GroupInvite(User sender, User receiver, Group group) { this.sender = sender; this.receiver = receiver; this.group = group; this.text = "<a href = profile.jsp?ID=" + sender.getID() + ">" + sender.getDisplayName() + "</a>" + " has invited you to join " + "<a href profile.jsp?ID=" + group.getID() + ">" + group.getDisplayName() + "</a>"; type = "GroupInvite"; }
@Test public void delete_all_single_values() { createFullUser("desv"); createUpdateUserWithDeleteFields(); updateUser(); assertNull(returnUser.getNickName()); assertNull(returnUser.getDisplayName()); assertNull(returnUser.getLocale()); assertNull(returnUser.getPreferredLanguage()); assertNull(returnUser.getProfileUrl()); assertNull(returnUser.getTimezone()); assertNull(returnUser.getTitle()); assertNull(returnUser.getUserType()); assertNull(returnUser.getName()); assertNull(returnUser.getExternalId()); }
@Test public void update_all_single_values() { createFullUser("uasv"); createUpdateUserWithUpdateFields(); updateUser(); assertEquals("UserName", returnUser.getUserName()); assertEquals("NickName", returnUser.getNickName()); assertNotEquals(testUser.isActive(), returnUser.isActive()); assertEquals("DisplayName", returnUser.getDisplayName()); assertEquals("ExternalId", returnUser.getExternalId()); assertEquals("Locale", returnUser.getLocale()); assertEquals("PreferredLanguage", returnUser.getPreferredLanguage()); assertEquals("ProfileUrl", returnUser.getProfileUrl()); assertEquals("Timezone", returnUser.getTimezone()); assertEquals("Title", returnUser.getTitle()); assertEquals("UserType", returnUser.getUserType()); assertEquals("FamilyName", returnUser.getName().getFamilyName()); assertEquals("ExternalId", returnUser.getExternalId()); }
private void update() { try { group.subscribeTo(receiver); receiver.addGroup(group); Date date = new Date(); receiver.post( "<a href = profile.jsp?ID=" + receiver.getID() + ">" + receiver.getDisplayName() + "</a>" + " joined " + "<a href = profile.jsp?ID=" + group.getID() + ">" + group.getDisplayName() + "</a>", receiver, date); } catch (Exception e) { // Fix to later return some sort of bs e.printStackTrace(); } }
public void build(MessageWireframe wireframe, int desiredWidth, StelsApplication application) { Logger.d(TAG, "Build layout start"); checkResources(application); senderPaint = initTextPaint(); senderPaint.setTypeface(FontController.loadTypeface(application, "regular")); senderPaint.setTextSize(bodyPaint.getTextSize()); senderPaint.setColor(0xff000000); forwardingPaint = initTextPaint(); forwardingPaint.setTypeface(FontController.loadTypeface(application, "light")); forwardingPaint.setTextSize(bodyPaint.getTextSize()); forwardingPaint.setColor(0xff000000); this.layoutDesiredWidth = desiredWidth; this.isOut = wireframe.message.isOut(); this.showState = isOut; this.isGroup = wireframe.message.getPeerType() == PeerType.PEER_CHAT && !isOut; if (isGroup) { User user = wireframe.senderUser; this.senderName = user.getDisplayName(); if (!wireframe.message.isForwarded()) { senderPaint.setColor( Placeholders.USER_PLACEHOLDERS_COLOR[ wireframe.message.getSenderId() % Placeholders.USER_PLACEHOLDERS_COLOR.length]); forwardingPaint.setColor( Placeholders.USER_PLACEHOLDERS_COLOR[ wireframe.message.getSenderId() % Placeholders.USER_PLACEHOLDERS_COLOR.length]); } } if (wireframe.message.isForwarded()) { isForwarded = true; this.forwarderName = wireframe.forwardUser.getDisplayName(); if (isOut) { forwardingPaint.setColor(0xff739f53); senderPaint.setColor(0xff739f53); } else { forwardingPaint.setColor(0xff4884cf); senderPaint.setColor(0xff4884cf); } } else { isForwarded = false; } if (isGroup) { User user = application.getEngine().getUser(wireframe.message.getSenderId()); this.senderName = user.getDisplayName(); } if (wireframe.message.isForwarded()) { isForwarded = true; this.forwarderName = wireframe.forwardUser.getDisplayName(); } else { isForwarded = false; } layoutDesiredWidth = desiredWidth; long start = SystemClock.uptimeMillis(); this.spannable = application .getEmojiProcessor() .processEmojiCompatMutable( wireframe.message.getMessage(), EmojiProcessor.CONFIGURATION_BUBBLES); // spannable = new SpannableString(wireframe.message.getMessage()); Logger.d(TAG, "Emoji processed in " + (SystemClock.uptimeMillis() - start) + " ms"); start = SystemClock.uptimeMillis(); Linkify.addLinks( this.spannable, Linkify.WEB_URLS | Linkify.PHONE_NUMBERS | Linkify.EMAIL_ADDRESSES); fixLinks(spannable); Logger.d(TAG, "Added links in " + (SystemClock.uptimeMillis() - start) + " ms"); start = SystemClock.uptimeMillis(); layout = new StaticLayout( spannable, bodyPaint, desiredWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, true); Logger.d(TAG, "Built base layout in " + (SystemClock.uptimeMillis() - start) + " ms"); if (layout.getLineCount() < 20) { int layoutTextWidth = 0; for (int i = 0; i < layout.getLineCount(); i++) { layoutTextWidth = (int) Math.max(layout.getLineWidth(i), layoutTextWidth); } if (layoutTextWidth < layout.getWidth() - px(10)) { layout = new StaticLayout( spannable, bodyPaint, layoutTextWidth + px(2), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, true); } } layoutRealWidth = layout.getWidth(); timeWidth = (int) clockOutPaint.measureText(wireframe.date) + px((showState ? 23 : 0) + 6); if (layout.getLineCount() == 1) { boolean isLastRtl = layout.getParagraphDirection(0) == Layout.DIR_RIGHT_TO_LEFT; if (!isLastRtl && desiredWidth - layoutRealWidth > timeWidth) { layoutRealWidth += timeWidth; layoutHeight = layout.getHeight() + px(3); } else if (isLastRtl && desiredWidth - layout.getWidth() > timeWidth) { layoutRealWidth = layout.getWidth() + timeWidth; layoutHeight = layout.getHeight() + px(3); } else { if (isLastRtl) { layoutRealWidth = layout.getWidth(); } layoutHeight = layout.getHeight() + px(17); } } else { boolean isLastRtl = layout.getParagraphDirection(layout.getLineCount() - 1) == Layout.DIR_RIGHT_TO_LEFT; if (!isLastRtl && (desiredWidth - layout.getLineWidth(layout.getLineCount() - 1) > timeWidth)) { layoutRealWidth = (int) Math.max( layoutRealWidth, layout.getLineWidth(layout.getLineCount() - 1) + timeWidth); layoutHeight = layout.getHeight() + px(3); } else if (isLastRtl && (desiredWidth - layout.getWidth() > timeWidth)) { layoutRealWidth = (int) Math.max(layoutRealWidth, layout.getWidth() + timeWidth); layoutHeight = layout.getHeight() + px(3); } else { layoutHeight = layout.getHeight() + px(17); } } if (layoutRealWidth < timeWidth) { layoutRealWidth = timeWidth; } if (isForwarded) { layoutHeight += px(19) * 2; forwardOffset = (int) forwardingPaintBase.measureText("From "); layoutRealWidth = (int) Math.max(layoutRealWidth, forwardingPaintBase.measureText("Forwarded message")); forwarderNameMeasured = TextUtils.ellipsize( forwarderName, senderPaintBase, desiredWidth - forwardOffset, TextUtils.TruncateAt.END) .toString(); layoutRealWidth = (int) Math.max( layoutRealWidth, forwardOffset + senderPaintBase.measureText(forwarderNameMeasured)); } if (isGroup && !isOut && !isForwarded) { layoutHeight += px(19); senderNameMeasured = TextUtils.ellipsize(senderName, senderPaintBase, desiredWidth, TextUtils.TruncateAt.END) .toString(); int width = (int) senderPaintBase.measureText(senderNameMeasured); layoutRealWidth = Math.max(layoutRealWidth, width); } Logger.d(TAG, "Build layout end"); }