Consider:
return attachmentList.stream().map(attachment -> {
AttachmentBO attachmentBO = new AttachmentBO();
attachmentBO.setId(attachment.getId());
attachmentBO.setTitle(attachment.getName());
attachmentBO.setType(attachment.getValue().get("type").toString());
attachmentBO.setCreatorId(attachment.getAuditUserId());
String[] filteredPermissionsForNote = this.filterPermissionCommand.filterPermissions(answer.getTopicId(), attachment.getAuditUserId(), topicDetails.getPermissions(), topicDetails.getEffectiveRoles(), true);
attachmentBO.setPermissions(filteredPermissionsForNote);
if (attachmentBO.getType().equalsIgnoreCase("URL")) {
attachmentBO.setUrl(String.valueOf(attachment.getMediaInfo().get("url")));
} else if (attachmentBO.getType().equalsIgnoreCase("FILE")) {
attachmentBO.setSize((Double) attachment.getValue().get("size"));
}
return attachmentBO;
}).collect(Collectors.toList());
I have mocked the attachmentList using Mockito, so I am getting the attachmentList. But how should I mock the remaining code? I have even mocked filterpermission.