@Test public void excludeTypeExcludesRpc() throws Exception { Schema schema = new RepoBuilder() .add("service.proto", "" + "service ServiceA {\n" + " rpc CallB (MessageB) returns (MessageB);\n" + " rpc CallC (MessageC) returns (MessageC);\n" + "}\n" + "message MessageB {\n" + "}\n" + "message MessageC {\n" + "}\n") .schema(); Schema pruned = schema.prune(new IdentifierSet.Builder() .include("ServiceA") .exclude("MessageC") .build()); assertThat(pruned.getType("MessageB")).isNotNull(); assertThat(pruned.getService("ServiceA").rpc("CallB")).isNotNull(); assertThat(pruned.getType("MessageC")).isNull(); assertThat(pruned.getService("ServiceA").rpc("CallC")).isNull(); }
@Test public void retainRpcRetainsRequestAndResponseTypes() throws Exception { Schema schema = new RepoBuilder() .add("service.proto", "" + "message RequestA {\n" + "}\n" + "message ResponseA {\n" + "}\n" + "message RequestB {\n" + "}\n" + "message ResponseB {\n" + "}\n" + "service Service {\n" + " rpc CallA (RequestA) returns (ResponseA);\n" + " rpc CallB (RequestB) returns (ResponseB);\n" + "}\n") .schema(); Schema pruned = schema.prune(new IdentifierSet.Builder() .include("Service#CallA") .build()); assertThat(pruned.getService("Service").rpc("CallA")).isNotNull(); assertThat(pruned.getType("RequestA")).isNotNull(); assertThat(pruned.getType("ResponseA")).isNotNull(); assertThat(pruned.getService("Service").rpc("CallB")).isNull(); assertThat(pruned.getType("RequestB")).isNull(); assertThat(pruned.getType("ResponseB")).isNull(); }
@Test public void excludeRpcExcludesTypes() throws Exception { Schema schema = new RepoBuilder() .add("service.proto", "" + "service ServiceA {\n" + " rpc CallB (MessageB) returns (MessageB);\n" + " rpc CallC (MessageC) returns (MessageC);\n" + "}\n" + "message MessageB {\n" + "}\n" + "message MessageC {\n" + "}\n") .schema(); Schema pruned = schema.prune(new IdentifierSet.Builder() .include("ServiceA") .exclude("ServiceA#CallC") .build()); assertThat(pruned.getType("MessageB")).isNotNull(); assertThat(pruned.getService("ServiceA").rpc("CallB")).isNotNull(); assertThat(pruned.getType("MessageC")).isNull(); assertThat(pruned.getService("ServiceA").rpc("CallC")).isNull(); }
@Test public void linkService() throws Exception { Schema schema = new RepoBuilder() .add("service.proto", "" + "import \"request.proto\";\n" + "import \"response.proto\";\n" + "service Service {\n" + " rpc Call (Request) returns (Response);\n" + "}\n") .add("request.proto", "" + "message Request {\n" + "}\n") .add("response.proto", "" + "message Response {\n" + "}\n") .schema(); Service service = schema.getService("Service"); Rpc call = service.rpc("Call"); assertThat(call.requestType()).isEqualTo(schema.getType("Request").type()); assertThat(call.responseType()).isEqualTo(schema.getType("Response").type()); }
Rpc rpc = service.rpc(member); if (rpc != null) { markRpc(service.type(), rpc);
Rpc rpc = service.rpc(member); if (rpc != null) { markRpc(service.type(), rpc);
Rpc rpc = service.rpc(member); if (rpc != null) { markRpc(service.type(), rpc);