/** * Returns the service with the fully qualified name {@code name}, or null if this schema defines * no such service. */ public Service getService(ProtoType protoType) { return getService(protoType.toString()); }
Service service = schema.getService(protoMember.type()); if (service != null) { Rpc rpc = service.rpc(member); Service service = schema.getService(protoType); if (service != null) { markService(service);
@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 rpcTypeImported() throws Exception { Schema schema = new RepoBuilder() .add("a.proto", "" + "package pa;\n" + "import \"b.proto\";\n" + "service Service {\n" + " rpc Call (pb.B) returns (pb.B);\n" + "}\n") .add("b.proto", "" + "package pb;\n" + "message B {\n" + "}\n") .schema(); Service service = schema.getService("pa.Service"); MessageType b = (MessageType) schema.getType("pb.B"); assertThat(service.rpcs().get(0).requestType()).isEqualTo(b.type()); assertThat(service.rpcs().get(0).responseType()).isEqualTo(b.type()); }
@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 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(); }
+ " rpc OtherOne (SampleRequest) returns (SampleResponse);\n" + "}\n")); Service service = schema.getService("squareup.wire.sample.SampleApi");
@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()); }
/** * Returns the service with the fully qualified name {@code name}, or null if this schema defines * no such service. */ public Service getService(ProtoType protoType) { return getService(protoType.toString()); }
/** * Returns the service with the fully qualified name {@code name}, or null if this schema defines * no such service. */ public Service getService(ProtoType protoType) { return getService(protoType.toString()); }
Service service = schema.getService(protoMember.type()); if (service != null) { Rpc rpc = service.rpc(member); Service service = schema.getService(protoType); if (service != null) { markService(service);
Service service = schema.getService(protoMember.type()); if (service != null) { Rpc rpc = service.rpc(member); Service service = schema.getService(protoType); if (service != null) { markService(service);