### Question:
Transformers { public static PlatformMessage requestToMessage(Request req, UUID placeId, String population, int ttl) { Preconditions.checkNotNull(req, "req must not be null"); Preconditions.checkNotNull(req.getInputs(), "inputs must not be null"); Preconditions.checkArgument(req.getInputs().size() == 1, "inputs must be of length 1"); MessageBody body; Request.Input input = req.getInputs().get(0); switch(input.getIntent()) { case Constants.Intents.SYNC: body = inputToSyncMessage(); break; case Constants.Intents.QUERY: body = inputToQueryMessage(input.getPayload()); break; case Constants.Intents.EXECUTE: body = inputToExecuteMessage(input.getPayload()); break; default: body = null; break; } if(body == null) { throw new ErrorEventException(Constants.Error.NOT_SUPPORTED, "unknown intent " + input.getIntent()); } return PlatformMessage.buildRequest(body, Constants.BRIDGE_ADDRESS, Constants.SERVICE_ADDRESS) .withTimeToLive(ttl) .withCorrelationId(req.getRequestId()) .withPlaceId(placeId) .withPopulation(population) .create(); } 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 testRequestToMessage() { Request req = new Request(); Request.Input input = new Request.Input(); input.setIntent(Constants.Intents.SYNC); req.setInputs(ImmutableList.of(input)); UUID id = IrisUUID.randomUUID(); String population = Population.NAME_GENERAL; assertEquals( GoogleService.SyncRequest.NAME, Transformers.requestToMessage(req, id, population, 100).getMessageType() ); input = new Request.Input(); input.setIntent(Constants.Intents.QUERY); req.setInputs(ImmutableList.of(input)); assertEquals( GoogleService.QueryRequest.NAME, Transformers.requestToMessage(req, id, population, 100).getMessageType() ); input = new Request.Input(); input.setIntent(Constants.Intents.EXECUTE); req.setInputs(ImmutableList.of(input)); assertEquals( GoogleService.ExecuteRequest.NAME, Transformers.requestToMessage(req, id, population, 100).getMessageType() ); try { input = new Request.Input(); input.setIntent("WrongIntent"); req.setInputs(ImmutableList.of(input)); Transformers.requestToMessage(req, id, population, 100); fail("exception should have been thrown"); } catch(ErrorEventException eee) { assertEquals(Constants.Error.NOT_SUPPORTED, eee.getCode()); } }