Skip to content

Commit

Permalink
removed unused method. address sonar issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhumin8 committed Nov 5, 2024
1 parent 79ec16e commit cf14f15
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
Expand Down Expand Up @@ -442,12 +443,14 @@ static boolean shouldIncludeMethodInGeneration(
// Give warnings and disregard this config. default to include all.
if (!librarySettingsList.get(0).getVersion().isEmpty()
&& !protoPackage.equals(librarySettingsList.get(0).getVersion())) {
LOGGER.warning(
String.format(
"Service yaml config is misconfigured. Version in "
+ "publishing.library_settings (%s) does not match proto package (%s)."
+ "Disregarding selective generation settings.",
librarySettingsList.get(0).getVersion(), protoPackage));
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.warning(
String.format(
"Service yaml config is misconfigured. Version in "
+ "publishing.library_settings (%s) does not match proto package (%s)."
+ "Disregarding selective generation settings.",
librarySettingsList.get(0).getVersion(), protoPackage));
}
return true;
}
// librarySettingsList is technically a list, but is processed upstream and
Expand Down Expand Up @@ -481,10 +484,10 @@ private static boolean isEmptyService(
shouldIncludeMethodInGeneration(method, serviceYamlProtoOpt, protoPackage))
.collect(Collectors.toList());
if (methodListSelected.isEmpty()) {
LOGGER.warning(
String.format(
"Service %s has no RPC methods and will not be generated",
serviceDescriptor.getName()));
LOGGER.log(
Level.WARNING,
"Service {0} has no RPC methods and will not be generated",
serviceDescriptor.getName());
}
return methodListSelected.isEmpty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import com.google.protobuf.Descriptors.FileDescriptor;
import com.google.protobuf.Descriptors.ServiceDescriptor;
import com.google.pubsub.v1.PubsubProto;
import com.google.selective.generate.v1beta1.SelectiveApiGenerationOuterClass;
import com.google.showcase.v1beta1.EchoOuterClass;
import com.google.showcase.v1beta1.IdentityOuterClass;
import com.google.showcase.v1beta1.MessagingOuterClass;
Expand Down Expand Up @@ -362,49 +361,6 @@ public GapicContext parseAutoPopulateFieldTesting() {
.build();
}

public GapicContext parseSelectiveGenerationTesting() {
FileDescriptor selectiveGenerationFileDescriptor =
SelectiveApiGenerationOuterClass.getDescriptor();
ServiceDescriptor selectiveGenerationServiceDescriptor =
selectiveGenerationFileDescriptor.getServices().get(0);
assertEquals(
selectiveGenerationServiceDescriptor.getName(), "EchoServiceShouldGeneratePartial");

String serviceYamlFilename = "selective_api_generation_v1beta1.yaml";
Path serviceYamlPath = Paths.get(testFilesDirectory, serviceYamlFilename);
Optional<com.google.api.Service> serviceYamlOpt =
ServiceYamlParser.parse(serviceYamlPath.toString());
assertTrue(serviceYamlOpt.isPresent());

Map<String, Message> messageTypes = Parser.parseMessages(selectiveGenerationFileDescriptor);
Map<String, ResourceName> resourceNames =
Parser.parseResourceNames(selectiveGenerationFileDescriptor);
Set<ResourceName> outputResourceNames = new HashSet<>();
List<Service> services =
Parser.parseService(
selectiveGenerationFileDescriptor,
messageTypes,
resourceNames,
serviceYamlOpt,
outputResourceNames);

String jsonFilename = "selective_api_generation_grpc_service_config.json";
Path jsonPath = Paths.get(testFilesDirectory, jsonFilename);
Optional<GapicServiceConfig> configOpt = ServiceConfigParser.parse(jsonPath.toString());
assertTrue(configOpt.isPresent());
GapicServiceConfig config = configOpt.get();
return GapicContext.builder()
.setMessages(messageTypes)
.setResourceNames(resourceNames)
.setServices(services)
.setHelperResourceNames(outputResourceNames)
.setServiceYamlProto(serviceYamlOpt.orElse(null))
.setGapicMetadataEnabled(true)
.setServiceConfig(config)
.setTransport(transport)
.build();
}

public GapicContext parsePubSubPublisher() {
FileDescriptor serviceFileDescriptor = PubsubProto.getDescriptor();
FileDescriptor commonResourcesFileDescriptor = CommonResources.getDescriptor();
Expand Down

0 comments on commit cf14f15

Please sign in to comment.