### Question:
IssueMapper implements EntityMapper<Issue> { @Override public XContentBuilder map(final EntityContainer<Issue> container) { Issue issue = container.getEntity(); try (XContentBuilder jsonBuilder = XContentFactory.jsonBuilder()) { jsonBuilder.startObject(); jsonBuilder .field(DOC_TYPE_FIELD, SearchDocumentType.ISSUE.name()) .field("id", issue.getId()) .field("name", issue.getName()) .field("text", issue.getText()) .field("status", issue.getStatus()) .field("createdDate", parseDataToString(issue.getCreatedDate())) .field("updatedDate", parseDataToString(issue.getUpdatedDate())); buildLabels(issue.getLabels(), jsonBuilder); buildAttachments(issue.getAttachments(), jsonBuilder); buildEntityVO(issue.getEntity(), jsonBuilder); buildComments(issue.getComments(), jsonBuilder); buildPermissions(container.getPermissions(), jsonBuilder); buildUserContent(container.getOwner(), jsonBuilder); jsonBuilder.endObject(); return jsonBuilder; } catch (IOException e) { throw new IllegalArgumentException("Failed to create elasticsearch document for issue: ", e); } }  @Override XContentBuilder map(final EntityContainer<Issue> container);  }### Answer:
@Test void shouldMapIssue() throws IOException { IssueMapper mapper = new IssueMapper(); Attachment attachment = new Attachment(); attachment.setPath(TEST_PATH); attachment.setOwner(USER_NAME); IssueComment comment = IssueComment .builder() .author(USER_NAME) .text(TEST_DESCRIPTION) .build(); EntityVO entity = new EntityVO(1L, AclClass.TOOL); Issue issue = Issue .builder() .id(1L) .name(TEST_NAME) .text(TEST_DESCRIPTION) .status(IssueStatus.OPEN) .labels(Collections.singletonList(TEST_LABEL)) .attachments(Collections.singletonList(attachment)) .comments(Collections.singletonList(comment)) .entity(entity) .build(); EntityContainer<Issue> container = EntityContainer.<Issue>builder() .entity(issue) .owner(USER) .permissions(PERMISSIONS_CONTAINER) .build(); XContentBuilder contentBuilder = mapper.map(container); verifyIssue(issue, contentBuilder); verifyAttachments(Collections.singletonList(attachment.getPath()), contentBuilder); verifyComments(Collections.singletonList(comment.getAuthor() + " : " + comment.getText()), contentBuilder); verifyPipelineUser(USER, contentBuilder); verifyPermissions(PERMISSIONS_CONTAINER, contentBuilder); }