StringBuilder codeForMapWithValueMessageType(Descriptors.FieldDescriptor desc,
      String fieldNameInCode,
      String valueDescClassName,
      int indent,
      int varNum) {
    StringBuilder code = new StringBuilder();
    varNum++;
    String mapVarName = "map" + varNum;
    StringBuilder code1 = new StringBuilder();
    code.append(
        completeLine(String.format("Map<Object, Map<String, Object>> %s = new HashMap<>()", mapVarName), indent));
    code.append(addIndent(String.format("for (Map.Entry<%s, %s> entry: msg.%s().entrySet()) {",
        ProtoBufUtils.getTypeStrFromProto(desc.getMessageType().findFieldByName("key")),
        ProtoBufUtils.getTypeStrFromProto(desc),
        getProtoFieldMethodName(fieldNameInCode + "Map")), indent));
    code.append(completeLine(String.format("%s.put(entry.getKey(), %s( (%s) entry.getValue()))", mapVarName,
        getDecoderMethodName(valueDescClassName), valueDescClassName), ++indent));
    code.append(addIndent("}", --indent));
    code.append(completeLine(String.format("msgMap.put(\"%s\", %s)", desc.getName(), mapVarName), indent));
    return code;
  }
@Test
    public void testCodeForMapWithValueMessageType() {
        MessageCodeGen messageCodeGen = new MessageCodeGen();
        // Repeated decoder method is non empty
        Descriptors.FieldDescriptor fd = ComplexTypes.TestMessage.getDescriptor().findFieldByName(COMPLEX_MAP);
        String fieldNameInCode = ProtobufInternalUtils.underScoreToCamelCase(fd.getName(), true);
        String javaType = ProtoBufUtils.getFullJavaName(fd.getMessageType());
        String expectedCode = "  Map<Object, Map<String, Object>> map2 = new HashMap<>();\n"
            + "  for (Map.Entry<String, Map<String,"
            + "org.apache.pinot.plugin.inputformat.protobuf.ComplexTypes.TestMessage.NestedMessage>> entry:"
            + " msg.getComplexMapMap().entrySet()) {\n"
            + "    map2.put(entry.getKey(), decodeNestedMessageMapMessage( (NestedMessageMap) entry.getValue()));\n"
            + "  }\n"
            + "  msgMap.put(\"complex_map\", map2);\n";
        assertEquals(messageCodeGen.codeForMapWithValueMessageType(
            fd, fieldNameInCode, "NestedMessageMap", 1, 1).toString(), expectedCode);
    }