### Question:
RestMsg extends Cdr { public HttpRequestMsg serialize(Cdr cdr) throws EtiqetException { try { update(cdr); Message messageConfig = getMessage(); if (messageConfig == null) { LOG.error("Message type {} not recognised", msgType); throw new EtiqetException("Message type " + msgType + " not recognised"); } instance = (HttpRequestMsg) Class.forName(messageConfig.getImplementation()).getConstructor().newInstance(); handleHttpRequest(); } catch (EtiqetException e) { LOG.error("Exception thrown serializing RestMsg", e); throw e; } catch (Exception e) { LOG.error("Exception thrown serializing RestMsg", e); throw new SerializeException(e); } return instance; } RestMsg(String msgType); HttpRequestMsg serialize(Cdr cdr);  }### Answer:
@Test public void testSerializeMessage() throws EtiqetException { String verb = "POST"; String endpoint = "/api/test"; String authHeader = "Bearer 12345"; String messageName = "test_01"; Cdr cdr = new Cdr(verb); cdr.set("$httpVerb", verb); cdr.set("$httpEndpoint", endpoint); cdr.set("$header.authorization", authHeader); cdr.set("test", "value"); cdr.set("test2", "value2"); RestMsg restMsg = new RestMsg(messageName); assertEquals(messageName, restMsg.getType()); HttpRequestMsg requestMsg = restMsg.serialize(cdr); assertEquals(verb, requestMsg.getVerb()); assertEquals(endpoint, requestMsg.getUrl()); assertTrue(requestMsg.getHeaders().containsKey("authorization")); assertEquals(authHeader, requestMsg.getHeaders().get("authorization")); assertEquals("{\"test\":\"value\",\"test2\":\"value2\"}", requestMsg.getPayload()); }