### Question:
ToolGroupMapper implements EntityMapper<ToolGroup> { @Override public XContentBuilder map(final EntityContainer<ToolGroup> container) { ToolGroup toolGroup = container.getEntity(); try (XContentBuilder jsonBuilder = XContentFactory.jsonBuilder()) { jsonBuilder.startObject(); jsonBuilder .field(DOC_TYPE_FIELD, SearchDocumentType.TOOL_GROUP.name()) .field("id", toolGroup.getId()) .field("name", toolGroup.getName()) .field("registryId", toolGroup.getRegistryId()) .field("createdDate", parseDataToString(toolGroup.getCreatedDate())) .field("description", toolGroup.getDescription()); buildUserContent(container.getOwner(), jsonBuilder); buildMetadata(container.getMetadata(), jsonBuilder); buildPermissions(container.getPermissions(), jsonBuilder); jsonBuilder.endObject(); return jsonBuilder; } catch (IOException e) { throw new IllegalArgumentException("Failed to create elasticsearch document for tool group: ", e); } }  @Override XContentBuilder map(final EntityContainer<ToolGroup> container);  }### Answer:
@Test void shouldMapToolGroup() throws IOException { ToolGroupMapper mapper = new ToolGroupMapper(); ToolGroup toolGroup = new ToolGroup(); toolGroup.setId(1L); toolGroup.setName(TEST_NAME); toolGroup.setRegistryId(1L); toolGroup.setDescription(TEST_DESCRIPTION); EntityContainer<ToolGroup> container = EntityContainer.<ToolGroup>builder() .entity(toolGroup) .owner(USER) .metadata(METADATA) .permissions(PERMISSIONS_CONTAINER) .build(); XContentBuilder contentBuilder = mapper.map(container); verifyToolGroup(toolGroup, contentBuilder); verifyPipelineUser(USER, contentBuilder); verifyPermissions(PERMISSIONS_CONTAINER, contentBuilder); verifyMetadata(EXPECTED_METADATA, contentBuilder); }