### Question:
Transformers { public static Optional<GoogleDevice> modelToDevice(Model m, boolean whitelisted, @Nullable ProductCatalogEntry pm, boolean reportStateEnabled) { if(!Predicates.isSupportedModel(m, whitelisted, pm)) { return Optional.empty(); } GoogleDevice dev = new GoogleDevice(); modelToDeviceName(m).ifPresent((n) -> dev.setName(n.toMap())); dev.setId(m.getAddress().getRepresentation()); modelToGoogleType(m).ifPresent(dev::setType); dev.setTraits(capabilitiesToTraits(m.getCapabilities())); dev.setAttributes(modelToTraitAttributes(m)); modelToDeviceInfo(m).ifPresent((i) -> dev.setDeviceInfo(i.toMap())); dev.setCustomData(modelToCustomData(m)); if(!reportStateEnabled || !StringUtils.isBlank(SceneModel.getName(m))) { dev.setWillReportState(false); } else { dev.setWillReportState(true); } if(dev.getName() == null || dev.getType() == null) { return Optional.empty(); } return Optional.of(dev); } private  Transformers(); static Optional<GoogleDevice> modelToDevice(Model m, boolean whitelisted, @Nullable ProductCatalogEntry pm, boolean reportStateEnabled); static Map<String,Object> modelToStateMap(Model m, boolean hubOffline, boolean whitelisted, @Nullable ProductCatalogEntry pm); static Optional<MessageBody> commandToMessageBody(Model m, boolean hubOffline, String command, Map<String, Object> params, boolean whitelisted, @Nullable ProductCatalogEntry pm); static PlatformMessage requestToMessage(Request req, UUID placeId, String population, int ttl); static Response messageToResponse(PlatformMessage msg); static final Gson GSON; static final String PRODUCT_ID; static final String TYPE_HINT; }### Answer:
@Test public void testModelToDevice() { assertEquals(Optional.empty(), Transformers.modelToDevice(null, true, null, true)); assertEquals(Optional.empty(), Transformers.modelToDevice(nonDevModel, true, null, true)); assertEquals(Optional.empty(), Transformers.modelToDevice(allCaps, true, null, true)); allCaps.setAttribute(DeviceCapability.ATTR_NAME, "foobar"); GoogleDevice dev = new GoogleDevice(); dev.setId(allCaps.getAddress().getRepresentation()); dev.setName(devName.toMap()); dev.setDeviceInfo(devInfo.toMap()); dev.setAttributes(ImmutableMap.of( Constants.Attributes.ColorTemperature.TEMPERATURE_MIN_K, 2000, Constants.Attributes.ColorTemperature.TEMPERATURE_MAX_K, 6500 )); dev.setTraits(ImmutableSet.of(Constants.Trait.BRIGHTNESS, Constants.Trait.COLOR_SPECTRUM, Constants.Trait.COLOR_TEMPERATURE, Constants.Trait.ON_OFF)); dev.setType(Constants.Type.LIGHT); dev.setWillReportState(true); dev.setCustomData(ImmutableMap.of(Transformers.PRODUCT_ID, "12345", Transformers.TYPE_HINT, "Light")); assertDevice(dev, Transformers.modelToDevice(allCaps, true, null, true).get()); }