### Question:
Transformers { static MessageBody inputToExecuteMessage(JsonElement payload) { List<GoogleCommand> commands = ImmutableList.of(); if(payload != null) { ExecutePayload execute = GSON.fromJson(payload, ExecutePayload.class); if(execute.getCommands() != null) { ImmutableList.Builder<GoogleCommand> builder = ImmutableList.builder(); execute.getCommands().forEach((c) -> addCommands(c, builder)); commands = builder.build(); } } return GoogleService.ExecuteRequest.builder() .withCommands(commands.stream().map(GoogleCommand::toMap).collect(Collectors.toList())) .build(); } 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 testInputToExecuteMessage() { MessageBody expected = GoogleService.ExecuteRequest.builder().withCommands(ImmutableList.of()).build(); assertMessageBody( expected, Transformers.inputToExecuteMessage(null) ); ExecutePayload payload = new ExecutePayload(); assertMessageBody( expected, Transformers.inputToExecuteMessage(Transformers.GSON.toJsonTree(payload, ExecutePayload.class)) ); payload.setCommands(ImmutableList.of()); assertMessageBody( expected, Transformers.inputToExecuteMessage(Transformers.GSON.toJsonTree(payload, ExecutePayload.class)) ); ExecutePayload.Command command = new ExecutePayload.Command(); payload.setCommands(ImmutableList.of(command)); assertMessageBody( expected, Transformers.inputToExecuteMessage(Transformers.GSON.toJsonTree(payload, ExecutePayload.class)) ); command.setDevices(ImmutableList.of()); assertMessageBody( expected, Transformers.inputToExecuteMessage(Transformers.GSON.toJsonTree(payload, ExecutePayload.class)) ); String addr = Address.platformDriverAddress(IrisUUID.randomUUID()).getRepresentation(); command.setDevices(ImmutableList.of(ImmutableMap.of("id", addr))); assertMessageBody( expected, Transformers.inputToExecuteMessage(Transformers.GSON.toJsonTree(payload, ExecutePayload.class)) ); command.setExecution(ImmutableList.of()); assertMessageBody( expected, Transformers.inputToExecuteMessage(Transformers.GSON.toJsonTree(payload, ExecutePayload.class)) ); ExecutePayload.Execution exec = new ExecutePayload.Execution(); exec.setCommand(Commands.OnOff.name); exec.setParams(ImmutableMap.of("on", true)); command.setExecution(ImmutableList.of(exec)); GoogleCommand c = new GoogleCommand(); c.setAddresses(ImmutableSet.of(addr)); c.setParams(ImmutableMap.of("on", true)); c.setCommand(Commands.OnOff.name); expected = GoogleService.ExecuteRequest.builder().withCommands(ImmutableList.of(c.toMap())).build(); assertMessageBody( expected, Transformers.inputToExecuteMessage(Transformers.GSON.toJsonTree(payload, ExecutePayload.class)) ); }