### Question:
CountryDeploymentTransformer { CountryDeploymentDTO toDto(CountryDeployment countryDeployment) { CountryDeploymentDTO result = new CountryDeploymentDTO(); result.setId(0L); if (null != countryDeployment) { result.setId(countryDeployment.getId()); result.setCountry(countryTransformer.toDto(countryDeployment.getCountry())); result.setPlatform(countryDeployment.getPlatform()); result.setJobUrl(countryDeployment.getJobUrl()); result.setStatus(countryDeployment.getStatus()); result.setResult(countryDeployment.getResult()); result.setStartDateTime(countryDeployment.getStartDateTime()); result.setEstimatedDuration(countryDeployment.getEstimatedDuration()); result.setDuration(countryDeployment.getDuration()); } return result; }    }### Answer:
@Test public void toDto_should_return_transformed_object() { Country country = new Country(1L, 1L, "FR", "France"); CountryDTO expectedCountry = new CountryDTO("FR", "France"); Date start = new Date(); CountryDeployment value = new CountryDeployment( 1L, 23L, null, country, "ptf", "http: JobStatus.DONE, Result.FAILURE, start, 1000L, 500L ); Mockito.doReturn(expectedCountry).when(countryTransformer).toDto(country); CountryDeploymentDTO result = cut.toDto(value); Assertions.assertThat(result).isNotNull(); Assertions.assertThat(result.getId()).isEqualTo(1L); Assertions.assertThat(result.getCountry()).isEqualTo(expectedCountry); Assertions.assertThat(result.getPlatform()).isEqualTo("ptf"); Assertions.assertThat(result.getJobUrl()).isEqualTo("http: Assertions.assertThat(result.getStatus()).isEqualTo(JobStatus.DONE); Assertions.assertThat(result.getResult()).isEqualTo(Result.FAILURE); Assertions.assertThat(result.getStartDateTime()).isEqualTo(start); Assertions.assertThat(result.getEstimatedDuration()).isEqualTo(1000L); Assertions.assertThat(result.getDuration()).isEqualTo(500L); }
@Test public void toDto_should_return_empty_when_country_deployment_is_null() { CountryDeploymentDTO result = cut.toDto(null); Assertions.assertThat(result).isNotNull(); Mockito.verify(countryTransformer, Mockito.never()).toDto(Mockito.any()); Assertions.assertThat(result.getId()).isEqualTo(0L); Assertions.assertThat(result.getCountry()).isNull(); Assertions.assertThat(result.getPlatform()).isNull(); Assertions.assertThat(result.getJobUrl()).isNull(); Assertions.assertThat(result.getStatus()).isNull(); Assertions.assertThat(result.getResult()).isNull(); Assertions.assertThat(result.getStartDateTime()).isNull(); Assertions.assertThat(result.getEstimatedDuration()).isNull(); Assertions.assertThat(result.getDuration()).isNull(); }