### Question:
NTGMessageHelper extends MessageHelper { @Override public IMessage prepareMessageToEncode(IMessage message, Map<String, String> params) { IMessage header = (IMessage) message.getField(MESSAGE_HEADER); NTGMessageMetadata m = getMetadata(message.getName()); if(header == null) { header = getMessageFactory().createMessage(MESSAGE_HEADER, getNamespace()); message.addField(MESSAGE_HEADER, header); } if (!header.isFieldSet(FIELD_MESSAGE_LENGTH)) { header.addField(FIELD_MESSAGE_LENGTH, m.messageSize); } if (!header.isFieldSet(FIELD_START_OF_MESSAGE)) { header.addField(FIELD_START_OF_MESSAGE, VALUE_START_OF_MESSAGE); } if (!header.isFieldSet(MESSAGE_TYPE)) { header.addField(MESSAGE_TYPE, m.messageType); } if (params != null) { String value = params.get(FIELD_DIRTY_MSG_LEN); if (value != null) { header.addField(FIELD_MESSAGE_LENGTH, Integer.valueOf(value)); } value = params.get(FIELD_DIRTY_MSG_TYPE); if (value != null) { header.addField(MESSAGE_TYPE, value); } value = params.get(FIELD_DIRTY_START); if (value != null) { header.addField(FIELD_START_OF_MESSAGE, Integer.valueOf(value)); } } return message; }  @Override void init(IMessageFactory messageFactory, IDictionaryStructure messageDictionary); @Override synchronized AbstractCodec getCodec(IServiceContext serviceContext); @Override IMessage prepareMessageToEncode(IMessage message, Map<String, String> params); @Override long getSenderTime(IMessage message); static final String MESSAGE_HEADER; static String FIELD_DIRTY_MSG_TYPE; static String FIELD_DIRTY_START; static String FIELD_DIRTY_MSG_LEN; static final String FIELD_MESSAGE_LENGTH; static final String FIELD_START_OF_MESSAGE; static final int VALUE_START_OF_MESSAGE; static final String FIELD_TRANSACT_TIME; static final String MESSAGE_TYPE; static final String MESSAGE_LOGON; static final String MESSAGE_HEARTBEAT; static final String MESSAGE_REJECT; static final String ATTRIBUTE_MESSAGE_TYPE; }### Answer:
@Test public void testMessageType() throws IOException { IFieldStructure typeField = dictionary.getFields().get("MessageType"); for (String element : typeField.getValues().keySet()) { IMessage message = messageFactory.createMessage(element, namespace); messageHelper.prepareMessageToEncode(message, null); checkValueInMessageHeader(message, "MessageType", typeField.getValues().get(element).getCastValue()); checkValueInMessageHeader(message, "StartOfMessage", 2); } }