### Question:
ProtoDescriptorSerializer { public List<FileContent> descriptorToString(FileDescriptorSet descriptorSet) { List<FileContent> result = new LinkedList<>(); for (FileDescriptorProto protoFileDesc : descriptorSet.getFileList()) { StringBuilder buffer = new StringBuilder(); buffer.append("syntax = \"").append(protoFileDesc.getSyntax()).append("\";\n"); for (Entry<FieldDescriptor, Object> opt : protoFileDesc.getOptions().getAllFields().entrySet()) { buffer.append("option ").append(opt.getKey().getName()).append(" = ").append(opt.getValue()).append(";\n"); } buffer.append("package ").append(protoFileDesc.getPackage()).append(";\n"); buffer.append("\n"); for (DescriptorProto msgType : protoFileDesc.getMessageTypeList()) { buffer.append("message ").append(msgType.getName()).append(" {\n"); for (FieldDescriptorProto field : msgType.getFieldList()) { String type = getType(field.getType()); buffer.append(" ") .append(toLabel(field.getLabel())) .append(type) .append(" ") .append(field.getName()) .append(" = ") .append(field.getNumber()) .append(";\n"); } buffer.append("}\n\n"); } boolean firstService = true; for (ServiceDescriptorProto serviceDesc : protoFileDesc.getServiceList()) { if (!firstService) { buffer.append("\n"); } firstService = false; buffer.append("service ").append(serviceDesc.getName()).append(" {\n"); for (MethodDescriptorProto method : serviceDesc.getMethodList()) { buffer.append(" rpc ") .append(method.getName()) .append("("); if (method.getClientStreaming()) buffer.append("stream "); buffer.append(method.getInputType()) .append(") returns ("); if (method.getServerStreaming()) buffer.append("stream "); buffer .append(method.getOutputType()) .append(");\n"); } buffer.append("}\n"); } result.add(new FileContent(protoFileDesc.getName(), buffer.toString())); } return result; }  List<FileContent> descriptorToString(FileDescriptorSet descriptorSet);  }### Answer:
@Test void test() throws Exception { String file = IOUtils.toString(getClass().getResourceAsStream("/HelloService.proto")); FileDescriptorSet descriptorSet = toDescriptor(file); var sut = new ProtoDescriptorSerializer(); var generatedFiles = sut.descriptorToString(descriptorSet); var generatedContent = generatedFiles.get(0).getContents(); var generatedDesc = toDescriptor(generatedContent); assertThat(generatedDesc.getFile(0)).isEqualToIgnoringGivenFields(descriptorSet.getFile(0), "name_", "package_", "syntax_"); }