### Question:
PopulatorFactory { public static <O, T> Optional<Populator> getPopulator(final Class<O> destObjectClass, final Class<T> sourceObjectClass, final BeanTransformer transformer) { Optional<Populator> populator = empty(); if (destObjectClass.isArray()) { populator = of(new ArrayPopulator(transformer)); } else if (Collection.class.isAssignableFrom(destObjectClass)) { populator = of(new CollectionPopulator(transformer)); } else if (Map.class.isAssignableFrom(destObjectClass)) { populator = of(new MapPopulator(transformer)); } else if (Optional.class == sourceObjectClass || Optional.class == destObjectClass) { populator = of(new OptionalPopulator(transformer)); } return populator; }  static Optional<Populator> getPopulator(final Class<O> destObjectClass, final Class<T> sourceObjectClass, final BeanTransformer transformer);  }### Answer:
@Test(dataProvider = "dataProvider") @SuppressWarnings({"unchecked"}) public void testGetPopulatorReturnsTheExpectedResult(final Class type, final Class<? extends Populator> expectedResult) { Optional<Populator> populator = underTest.getPopulator(type, type, transformer); final boolean isNonNullObjectExpected = nonNull(expectedResult); assertThat(populator.isPresent()).isEqualTo(isNonNullObjectExpected); if (isNonNullObjectExpected) { assertThat(populator).containsInstanceOf(expectedResult); } }