@Test public void excludeRepeatedOptions() throws Exception { Schema schema = new RepoBuilder() .add("service.proto", "" + "import \"google/protobuf/descriptor.proto\";\n" + "extend google.protobuf.MessageOptions {\n" + " repeated string a = 22001;\n" + " repeated string b = 22002;\n" + "}\n" + "message Message {\n" + " option (a) = \"a1\";\n" + " option (a) = \"a2\";\n" + " option (b) = \"b1\";\n" + " option (b) = \"b2\";\n" + " optional string f = 1;\n" + "}\n") .schema(); Schema pruned = schema.prune(new IdentifierSet.Builder() .exclude("google.protobuf.MessageOptions#a") .build()); MessageType message = (MessageType) pruned.getType("Message"); assertThat(message.options().get(ProtoMember.get(MESSAGE_OPTIONS, "a"))).isNull(); assertThat(message.options().get(ProtoMember.get(MESSAGE_OPTIONS, "b"))) .isEqualTo(ImmutableList.of("b1", "b2")); }
ProtoMember stringOption = ProtoMember.get(evenMoreOptionsType, "string_option"); MessageType message = (MessageType) schema.getType("a.d.Message"); assertThat(message.options().map()).isEqualTo( ImmutableMap.of(moreOptions, ImmutableMap.of( evenMoreOptions, ImmutableMap.of(stringOption, "foo"))));
MESSAGE_OPTIONS, nameAllocator.get("MESSAGE_OPTIONS"), type.options()); if (messageOptions != null) { builder.addField(messageOptions);
MESSAGE_OPTIONS, nameAllocator.get("MESSAGE_OPTIONS"), type.options()); if (messageOptions != null) { builder.addField(messageOptions);
MESSAGE_OPTIONS, nameAllocator.get("MESSAGE_OPTIONS"), type.options()); if (messageOptions != null) { builder.addField(messageOptions);