diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/Parser.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/Parser.java index d0e046f718..ff89a87555 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/Parser.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/Parser.java @@ -436,24 +436,16 @@ public static List parseService( return fileDescriptor.getServices().stream() .filter( - s -> { - String pakkage = TypeParser.getPackage(fileDescriptor); - List methods = parseMethods( - s, - pakkage, - messageTypes, - resourceNames, - serviceConfigOpt, - serviceYamlProtoOpt, - outputArgResourceNames, - transport); - if (methods.isEmpty()) { - LOGGER.warning(String.format("No rpc methods specified in %s, generation will be skipped.", s.getName())); - // Service.builder() + serviceDescriptor -> { + List methodsList = serviceDescriptor.getMethods(); + if (methodsList.isEmpty()) { + LOGGER.warning( + String.format( + "No rpc methods specified in %s, generation will be skipped.", + serviceDescriptor.getName())); } - return !methods.isEmpty(); - } - ) + return !methodsList.isEmpty(); + }) .map( s -> { // Workaround for a missing default_host and oauth_scopes annotation from a service @@ -514,19 +506,6 @@ public static List parseService( overriddenServiceName = languageSettings.getJavaServiceName(fileDescriptor.getPackage(), s.getName()); } - List methods = parseMethods( - s, - pakkage, - messageTypes, - resourceNames, - serviceConfigOpt, - serviceYamlProtoOpt, - outputArgResourceNames, - transport); - if (methods.isEmpty()) { - LOGGER.warning("No methods in this service."); - // Service.builder() - } return serviceBuilder .setName(serviceName) .setOverriddenName(overriddenServiceName) @@ -537,7 +516,15 @@ public static List parseService( .setProtoPakkage(fileDescriptor.getPackage()) .setIsDeprecated(isDeprecated) .setMethods( - methods) + parseMethods( + s, + pakkage, + messageTypes, + resourceNames, + serviceConfigOpt, + serviceYamlProtoOpt, + outputArgResourceNames, + transport)) .build(); }) .collect(Collectors.toList()); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ParserTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ParserTest.java index 32007e823f..c1cb182fad 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ParserTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ParserTest.java @@ -58,7 +58,6 @@ import java.util.Map; import java.util.Optional; import java.util.Set; -import java.util.stream.Collectors; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -704,19 +703,15 @@ void testServiceWithoutApiVersionParsed() { assertNull(parsedBookshopService.apiVersion()); } - @Test void parseServiceWithNoMethodsTest() { - FileDescriptor fileDescriptor = com.google.api.service.without.methods.test.ServiceWithNoMethodsOuterClass.getDescriptor(); + FileDescriptor fileDescriptor = + com.google.api.service.without.methods.test.ServiceWithNoMethodsOuterClass.getDescriptor(); Map messageTypes = Parser.parseMessages(fileDescriptor); Map resourceNames = Parser.parseResourceNames(fileDescriptor); List services = Parser.parseService( - fileDescriptor, - messageTypes, - resourceNames, - Optional.empty(), - new HashSet<>()); + fileDescriptor, messageTypes, resourceNames, Optional.empty(), new HashSet<>()); assertEquals(1, services.size()); assertEquals("EchoWithMethods", services.get(0).overriddenName()); }