use of com.google.api.codegen.LongRunningConfigProto 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);
}
Aggregations