@Test public final void populateWithoutComment() { ActivityDTO original = new ActivityDTO(); original.setId(1L); original.setBaseObjectType(BaseObjectType.NOTE); StreamEntityDTO originalActor = new StreamEntityDTO(); originalActor.setUniqueIdentifier("testacct"); original.setActor(originalActor); HashMap<String, String> props = new HashMap<String, String>(); props.put("test", "value"); original.setBaseObjectProperties(props); SharePopulator sut = new SharePopulator(original, ""); ActivityDTO activity = new ActivityDTO(); sut.populate(activity); Assert.assertEquals(ActivityVerb.SHARE, activity.getVerb()); Assert.assertEquals(originalActor, activity.getOriginalActor()); Assert.assertEquals(props, activity.getBaseObjectProperties()); Assert.assertEquals(BaseObjectType.NOTE, activity.getBaseObjectType()); Assert.assertEquals(String.valueOf(1L), activity .getBaseObjectProperties().get("originalActivityId")); Assert.assertNull(activity.getFirstComment()); }
public void populate(final ActivityDTO activity) { activity.setVerb(ActivityVerb.SHARE); if (originalActivity.getOriginalActor() != null && originalActivity.getOriginalActor().getUniqueIdentifier() != null) { activity.setOriginalActor(originalActivity.getOriginalActor()); } else { activity.setOriginalActor(originalActivity.getActor()); } activity.setBaseObjectProperties(originalActivity.getBaseObjectProperties()); if (originalActivity.getBaseObjectProperties().containsKey("originalActivityId") && (originalActivity.getBaseObjectProperties().get("originalActivityId") != null)) { activity.getBaseObjectProperties().put("originalActivityId", originalActivity.getBaseObjectProperties().get("originalActivityId")); } else { activity.getBaseObjectProperties().put("originalActivityId", String.valueOf(originalActivity.getId())); } activity.setBaseObjectType(originalActivity.getBaseObjectType()); if (commentBody != null && commentBody.length() > 0) { CommentDTO sharedActivityComment = new CommentDTO(); sharedActivityComment.setBody(commentBody); List<CommentDTO> comments = new ArrayList<CommentDTO>(); comments.add(sharedActivityComment); activity.setFirstComment(sharedActivityComment); activity.setComments(comments); activity.setCommentCount(comments.size()); } }
SharePopulator implements ActivityDTOPopulatorStrategy { public void populate(final ActivityDTO activity) { activity.setVerb(ActivityVerb.SHARE); if (originalActivity.getOriginalActor() != null && originalActivity.getOriginalActor().getUniqueIdentifier() != null) { activity.setOriginalActor(originalActivity.getOriginalActor()); } else { activity.setOriginalActor(originalActivity.getActor()); } activity.setBaseObjectProperties(originalActivity.getBaseObjectProperties()); if (originalActivity.getBaseObjectProperties().containsKey("originalActivityId") && (originalActivity.getBaseObjectProperties().get("originalActivityId") != null)) { activity.getBaseObjectProperties().put("originalActivityId", originalActivity.getBaseObjectProperties().get("originalActivityId")); } else { activity.getBaseObjectProperties().put("originalActivityId", String.valueOf(originalActivity.getId())); } activity.setBaseObjectType(originalActivity.getBaseObjectType()); if (commentBody != null && commentBody.length() > 0) { CommentDTO sharedActivityComment = new CommentDTO(); sharedActivityComment.setBody(commentBody); List<CommentDTO> comments = new ArrayList<CommentDTO>(); comments.add(sharedActivityComment); activity.setFirstComment(sharedActivityComment); activity.setComments(comments); activity.setCommentCount(comments.size()); } } }
SharePopulator implements ActivityDTOPopulatorStrategy { public void populate(final ActivityDTO activity) { activity.setVerb(ActivityVerb.SHARE); if (originalActivity.getOriginalActor() != null && originalActivity.getOriginalActor().getUniqueIdentifier() != null) { activity.setOriginalActor(originalActivity.getOriginalActor()); } else { activity.setOriginalActor(originalActivity.getActor()); } activity.setBaseObjectProperties(originalActivity.getBaseObjectProperties()); if (originalActivity.getBaseObjectProperties().containsKey("originalActivityId") && (originalActivity.getBaseObjectProperties().get("originalActivityId") != null)) { activity.getBaseObjectProperties().put("originalActivityId", originalActivity.getBaseObjectProperties().get("originalActivityId")); } else { activity.getBaseObjectProperties().put("originalActivityId", String.valueOf(originalActivity.getId())); } activity.setBaseObjectType(originalActivity.getBaseObjectType()); if (commentBody != null && commentBody.length() > 0) { CommentDTO sharedActivityComment = new CommentDTO(); sharedActivityComment.setBody(commentBody); List<CommentDTO> comments = new ArrayList<CommentDTO>(); comments.add(sharedActivityComment); activity.setFirstComment(sharedActivityComment); activity.setComments(comments); activity.setCommentCount(comments.size()); } } SharePopulator(final ActivityDTO inOriginalActivity, final String inCommentBody); }
SharePopulator implements ActivityDTOPopulatorStrategy { public void populate(final ActivityDTO activity) { activity.setVerb(ActivityVerb.SHARE); if (originalActivity.getOriginalActor() != null && originalActivity.getOriginalActor().getUniqueIdentifier() != null) { activity.setOriginalActor(originalActivity.getOriginalActor()); } else { activity.setOriginalActor(originalActivity.getActor()); } activity.setBaseObjectProperties(originalActivity.getBaseObjectProperties()); if (originalActivity.getBaseObjectProperties().containsKey("originalActivityId") && (originalActivity.getBaseObjectProperties().get("originalActivityId") != null)) { activity.getBaseObjectProperties().put("originalActivityId", originalActivity.getBaseObjectProperties().get("originalActivityId")); } else { activity.getBaseObjectProperties().put("originalActivityId", String.valueOf(originalActivity.getId())); } activity.setBaseObjectType(originalActivity.getBaseObjectType()); if (commentBody != null && commentBody.length() > 0) { CommentDTO sharedActivityComment = new CommentDTO(); sharedActivityComment.setBody(commentBody); List<CommentDTO> comments = new ArrayList<CommentDTO>(); comments.add(sharedActivityComment); activity.setFirstComment(sharedActivityComment); activity.setComments(comments); activity.setCommentCount(comments.size()); } } SharePopulator(final ActivityDTO inOriginalActivity, final String inCommentBody); void populate(final ActivityDTO activity); }
SharePopulator implements ActivityDTOPopulatorStrategy { public void populate(final ActivityDTO activity) { activity.setVerb(ActivityVerb.SHARE); if (originalActivity.getOriginalActor() != null && originalActivity.getOriginalActor().getUniqueIdentifier() != null) { activity.setOriginalActor(originalActivity.getOriginalActor()); } else { activity.setOriginalActor(originalActivity.getActor()); } activity.setBaseObjectProperties(originalActivity.getBaseObjectProperties()); if (originalActivity.getBaseObjectProperties().containsKey("originalActivityId") && (originalActivity.getBaseObjectProperties().get("originalActivityId") != null)) { activity.getBaseObjectProperties().put("originalActivityId", originalActivity.getBaseObjectProperties().get("originalActivityId")); } else { activity.getBaseObjectProperties().put("originalActivityId", String.valueOf(originalActivity.getId())); } activity.setBaseObjectType(originalActivity.getBaseObjectType()); if (commentBody != null && commentBody.length() > 0) { CommentDTO sharedActivityComment = new CommentDTO(); sharedActivityComment.setBody(commentBody); List<CommentDTO> comments = new ArrayList<CommentDTO>(); comments.add(sharedActivityComment); activity.setFirstComment(sharedActivityComment); activity.setComments(comments); activity.setCommentCount(comments.size()); } } SharePopulator(final ActivityDTO inOriginalActivity, final String inCommentBody); void populate(final ActivityDTO activity);  }