protected String putFieldInMsgMapCode(String fieldNameInProto, String getFieldMethodName, String optionalDecodeMethod,
      String optionalAdditionalCalls) {
    if (StringUtils.isBlank(optionalAdditionalCalls)) {
      optionalAdditionalCalls = "";
    }
    if (!StringUtils.isBlank(optionalDecodeMethod)) {
      return String.format("msgMap.put(\"%s\", %s(msg.%s()%s))",
          fieldNameInProto, optionalDecodeMethod, getFieldMethodName, optionalAdditionalCalls);
    }
    return String.format("msgMap.put(\"%s\", msg.%s()%s)",
        fieldNameInProto, getFieldMethodName, optionalAdditionalCalls);
  }
@Test
    public void testPutFieldInMsgMapCode() {
        MessageCodeGen messageCodeGen = new MessageCodeGen();
        assertEquals(
            messageCodeGen.putFieldInMsgMapCode("field1", "getField1", null, null),
            "msgMap.put(\"field1\", msg.getField1())");
        assertEquals(
            messageCodeGen.putFieldInMsgMapCode("field1", "getField1", "", ""),
            "msgMap.put(\"field1\", msg.getField1())");
        assertEquals(
            messageCodeGen.putFieldInMsgMapCode("field1", "getField1", "decodeField1", null),
            "msgMap.put(\"field1\", decodeField1(msg.getField1()))");
        assertEquals(
            messageCodeGen.putFieldInMsgMapCode("field1", "getField1", "decodeField1",
                ""), "msgMap.put(\"field1\", decodeField1(msg.getField1()))");
        assertEquals(
            messageCodeGen.putFieldInMsgMapCode("field1", "getField1", null, ".toByteArray()"),
            "msgMap.put(\"field1\", msg.getField1().toByteArray())");
        assertEquals(
            messageCodeGen.putFieldInMsgMapCode("field1", "getField1", "", ".toByteArray()"),
            "msgMap.put(\"field1\", msg.getField1().toByteArray())");
        assertEquals(
            messageCodeGen.putFieldInMsgMapCode("field1", "getField1", "decodeField1", ".toString()"),
            "msgMap.put(\"field1\", decodeField1(msg.getField1().toString()))");
    }