### Question:
TypeTransformer { TypeWithSourceDTO toDtoWithSource(Type type) { TypeWithSourceDTO result = new TypeWithSourceDTO(); if (null != type) { result.setCode(type.getCode()); result.setName(type.getName()); result.setBrowser(type.isBrowser()); result.setMobile(type.isMobile()); result.setSource(sourceTransformer.toDto(type.getSource())); } return result; }    }### Answer:
@Test public void toDtoWithSource_should_transform_type() { Source source = new Source(); Type value = new Type(1L, 66L, "code", "name", true, true, source); Mockito.doReturn(new SourceDTO()).when(sourceTransformer).toDto(source); TypeWithSourceDTO result = cut.toDtoWithSource(value); Assertions.assertThat(result).isNotNull(); Assertions.assertThat(result.getCode()).isEqualTo("code"); Assertions.assertThat(result.getName()).isEqualTo("name"); Assertions.assertThat(result.isBrowser()).isTrue(); Assertions.assertThat(result.isMobile()).isTrue(); Mockito.verify(sourceTransformer).toDto(source); }
@Test public void toDtoWithSource_should_return_empty_object_on_null() { TypeWithSourceDTO result = cut.toDtoWithSource(null); Assertions.assertThat(result).isNotNull(); Assertions.assertThat(result.getCode()).isNull(); Assertions.assertThat(result.getName()).isNull(); Assertions.assertThat(result.isBrowser()).isFalse(); Assertions.assertThat(result.isMobile()).isFalse(); Mockito.verify(sourceTransformer, Mockito.never()).toDto(Mockito.any()); }