### Question:
Transformers { static Optional<String> capabilityToTrait(String capability) { if(StringUtils.isBlank(capability)) { return Optional.empty(); } String trait; switch(capability) { case SwitchCapability.NAMESPACE: trait = Constants.Trait.ON_OFF; break; case DimmerCapability.NAMESPACE: trait = Constants.Trait.BRIGHTNESS; break; case ColorCapability.NAMESPACE: trait = Constants.Trait.COLOR_SPECTRUM; break; case ColorTemperatureCapability.NAMESPACE: trait = Constants.Trait.COLOR_TEMPERATURE; break; case SceneCapability.NAMESPACE: trait = Constants.Trait.SCENE; break; case ThermostatCapability.NAMESPACE: trait = Constants.Trait.TEMPERATURE_SETTING; break; default: trait = null; break; } return Optional.ofNullable(trait); } 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 testCapabilityToTrait() { assertFalse(Transformers.capabilityToTrait(null).isPresent()); assertEquals(Constants.Trait.ON_OFF, Transformers.capabilityToTrait(SwitchCapability.NAMESPACE).get()); assertEquals(Constants.Trait.BRIGHTNESS, Transformers.capabilityToTrait(DimmerCapability.NAMESPACE).get()); assertEquals(Constants.Trait.COLOR_SPECTRUM, Transformers.capabilityToTrait(ColorCapability.NAMESPACE).get()); assertEquals(Constants.Trait.COLOR_TEMPERATURE, Transformers.capabilityToTrait(ColorTemperatureCapability.NAMESPACE).get()); assertEquals(Constants.Trait.SCENE, Transformers.capabilityToTrait(SceneCapability.NAMESPACE).get()); assertEquals(Constants.Trait.TEMPERATURE_SETTING, Transformers.capabilityToTrait(ThermostatCapability.NAMESPACE).get()); assertFalse(Transformers.capabilityToTrait(ContactCapability.NAMESPACE).isPresent()); }