### Question:
OkrCompanyMapper implements DataMapper<OkrCompany, OkrCompanyDto> { @Override public OkrCompanyDto mapEntityToDto(OkrCompany okrCompany) { OkrCompanyDto okrCompanyDto = new OkrCompanyDto(); okrCompanyDto.setOkrUnitId(okrCompany.getId()); okrCompanyDto.setUnitName(okrCompany.getName()); okrCompanyDto.setLabel(okrCompany.getLabel()); okrCompanyDto.setCycleId(okrCompany.getCycle().getId()); okrCompanyDto.setHistoryId(okrCompany.getHistory().getId()); Collection<Long> departmentIds = new ArrayList<>(); for (OkrChildUnit okrChildUnit : okrCompany.getOkrChildUnits()) { departmentIds.add(okrChildUnit.getId()); } okrCompanyDto.setOkrChildUnitIds(departmentIds); Collection<Long> objectiveIds = new ArrayList<>(); for (Objective objective : okrCompany.getObjectives()) { objectiveIds.add(objective.getId()); } okrCompanyDto.setObjectiveIds(objectiveIds); logger.info("Mapped OkrCompany (id:" + okrCompany.getId() + ") to OkrCompanyDto."); return okrCompanyDto; }  @Override OkrCompany mapDtoToEntity(OkrCompanyDto okrCompanyDto); @Override OkrCompanyDto mapEntityToDto(OkrCompany okrCompany); @Override Collection<OkrCompany> mapDtosToEntities(Collection<OkrCompanyDto> input); @Override Collection<OkrCompanyDto> mapEntitiesToDtos(Collection<OkrCompany> companies);  }### Answer:
@Test public void test_mapEntityToDto_expects_idIsMapped() { Long expected = 5L; okrCompany.setId(expected); okrCompanyDto = okrCompanyMapper.mapEntityToDto(okrCompany); Assert.assertEquals(expected, okrCompanyDto.getOkrUnitId()); }
@Test public void test_mapEntityToDto_expects_nameIsMapped() { String expected = "test"; okrCompany.setName(expected); okrCompanyDto = okrCompanyMapper.mapEntityToDto(okrCompany); Assert.assertEquals(expected, okrCompanyDto.getUnitName()); }
@Test public void test_mapEntityToDto_expects_labelIsMapped() { String expected = "t1e2s3t"; okrCompany.setLabel(expected); okrCompanyDto = okrCompanyMapper.mapEntityToDto(okrCompany); Assert.assertEquals(expected, okrCompanyDto.getLabel()); }
@Test public void test_mapEntityToDto_expects_departmentsSizeIsEqual4() { int expected = 4; Collection<OkrChildUnit> departments = new ArrayList<>(); for (int i = 1; i <= expected; i++) { departments.add(new OkrDepartment()); } okrCompany.setOkrChildUnits(departments); okrCompanyDto = okrCompanyMapper.mapEntityToDto(okrCompany); Assert.assertEquals(expected, okrCompanyDto.getOkrChildUnitIds().size()); }
@Test public void test_mapEntityToDto_expects_objectiveSizeIsEqual() { int expected = 4; Collection<Objective> objectives = new ArrayList<>(); for (int i = 1; i <= expected; i++) { objectives.add(new Objective()); } okrCompany.setObjectives(objectives); okrCompanyDto = okrCompanyMapper.mapEntityToDto(okrCompany); Assert.assertEquals(expected, okrCompanyDto.getObjectiveIds().size()); }
@Test public void test_mapEntityToDto_expects_CycleIsMapped() { Long expected = 14L; Cycle cycle = new Cycle(); cycle.setId(expected); okrCompany.setCycle(cycle); okrCompanyDto = okrCompanyMapper.mapEntityToDto(okrCompany); Assert.assertEquals(expected, okrCompanyDto.getCycleId()); }
@Test public void test_mapEntityToDto_expects_HistoryIsMapped() { Long expected = 27L; OkrCompanyHistory history = new OkrCompanyHistory(); history.setId(expected); okrCompany.setHistory(history); okrCompanyDto = okrCompanyMapper.mapEntityToDto(okrCompany); Assert.assertEquals(expected, okrCompanyDto.getHistoryId()); }