use of com.google.api.tools.framework.model.DiagCollector in project toolkit by googleapis.
the class LongRunningConfigTest method testCreateSameLROFromProtoFileAndGapicConfig.
@Test
public void testCreateSameLROFromProtoFileAndGapicConfig() {
Mockito.when(protoParser.isProtoAnnotationsEnabled()).thenReturn(true);
// Given a Protobuf LRO method annotated with the same Return and Metadata Type
// as in the GAPIC config, use the GAPIC config settings.
DiagCollector diagCollector = new BoundedDiagCollector();
// Use a GAPIC config with the same return and metadata types as the LRO proto annotations.
LongRunningConfigProto longRunningConfigProto = lroConfigProtoWithPollSettings.toBuilder().setMetadataType(PROTO_PACKAGE_NAME + "." + ANNOTATIONS_METADATA_TYPE).setReturnType(PROTO_PACKAGE_NAME + "." + ANNOTATIONS_RETURN_TYPE_NAME).build();
LongRunningConfig longRunningConfig = LongRunningConfig.createLongRunningConfig(lroAnnotatedMethod, diagCollector, longRunningConfigProto, protoParser);
assertThat(diagCollector.getErrorCount()).isEqualTo(0);
assertThat(longRunningConfig).isNotNull();
// Assert that we are using gapic config LRO settings.
ProtoTypeRef metadataTypeModel = (ProtoTypeRef) longRunningConfig.getMetadataType();
assertThat(metadataTypeModel.getProtoType()).isEqualTo(annotationsMetadataType);
ProtoTypeRef returnTypeModel = (ProtoTypeRef) longRunningConfig.getReturnType();
assertThat(returnTypeModel.getProtoType()).isEqualTo(annotationsReturnType);
assertThat(longRunningConfig.getInitialPollDelay().toMillis()).isEqualTo(TEST_INITIAL_POLL_DELAY);
assertThat(longRunningConfig.getMaxPollDelay().toMillis()).isEqualTo(TEST_MAX_POLL_DELAY);
assertThat(longRunningConfig.getPollDelayMultiplier()).isEqualTo(TEST_POLL_DELAY_MULTIPLIER);
assertThat(longRunningConfig.getTotalPollTimeout().toMillis()).isEqualTo(TEST_TOTAL_POLL_TIMEOUT);
}
use of com.google.api.tools.framework.model.DiagCollector in project toolkit by googleapis.
the class DiscoGapicGeneratorApp method loadConfigFromFiles.
private static ConfigProto loadConfigFromFiles(List<String> configFileNames) {
ConfigProto configProto = null;
DiagCollector diagCollector = new SimpleDiagCollector();
if (configFileNames.size() > 0) {
// Read the YAML config and convert it to proto.
ConfigSource configSource = loadGapicConfigFromFiles(configFileNames, diagCollector);
if (configSource == null) {
return null;
}
configProto = (ConfigProto) configSource.getConfig();
if (configProto == null || configProto.equals(ConfigProto.getDefaultInstance())) {
return null;
}
}
return configProto;
}
Aggregations