diff --git a/gapic-generator/templates/default/helpers/presenters/file_presenter.rb b/gapic-generator/templates/default/helpers/presenters/file_presenter.rb index 793c42058..cc5887cd5 100644 --- a/gapic-generator/templates/default/helpers/presenters/file_presenter.rb +++ b/gapic-generator/templates/default/helpers/presenters/file_presenter.rb @@ -26,6 +26,10 @@ def initialize api, file @file = file end + def name + @file.name + end + def address @file.address end diff --git a/gapic-generator/templates/default/helpers/presenters/package_presenter.rb b/gapic-generator/templates/default/helpers/presenters/package_presenter.rb index d9a1e71c0..aa2e81cdf 100644 --- a/gapic-generator/templates/default/helpers/presenters/package_presenter.rb +++ b/gapic-generator/templates/default/helpers/presenters/package_presenter.rb @@ -27,8 +27,8 @@ def initialize api, package @package = package end - def def gem - GemPresenter.new.new @api + def gem + GemPresenter.new @api end def name diff --git a/gapic-generator/test/google/gapic/presenters/file/garbage_test.rb b/gapic-generator/test/google/gapic/presenters/file/garbage_test.rb new file mode 100644 index 000000000..14f1a0fde --- /dev/null +++ b/gapic-generator/test/google/gapic/presenters/file/garbage_test.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require "test_helper" + +class GarbageFilePresenterTest < PresenterTest + def schema + api :garbage + end + + def test_garbage + file = schema.files.find { |f| f.name == "garbage/garbage.proto" } + fp = FilePresenter.new schema, file + + assert_equal ["endless", "trash", "forever"], fp.address + assert_equal "So::Much::Trash", fp.namespace + assert_equal "garbage/garbage.rb", fp.docs_file_path + + assert_equal ["LongRunningGarbageRequest", "LongRunningGarbageResponse", "LongRunningGarbageMetadata", "ListGarbageRequest", "ListGarbageResponse", "GarbageItem", "SimpleGarbage", "SimpleGarbageItem", "TypicalGarbage", "SpecificGarbage", "RepeatedGarbage", "GarbageMap"], fp.messages.map(&:name) + fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } + + assert_equal ["GarbageEnum"], fp.enums.map(&:name) + fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } + end +end diff --git a/gapic-generator/test/google/gapic/presenters/file/googleads_test.rb b/gapic-generator/test/google/gapic/presenters/file/googleads_test.rb new file mode 100644 index 000000000..8e1af92b4 --- /dev/null +++ b/gapic-generator/test/google/gapic/presenters/file/googleads_test.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require "test_helper" + +class GoogleAdsFilePresenterTest < PresenterTest + def schema + api :googleads + end + + def test_campaign_service + file = schema.files.find { |f| f.name == "google/ads/googleads/v1/services/campaign_service.proto" } + fp = FilePresenter.new schema, file + + assert_equal ["google", "ads", "googleads", "v1", "services"], fp.address + assert_equal "Google::Ads::GoogleAds::V1::Services", fp.namespace + assert_equal "google/ads/googleads/v1/services/campaign_service.rb", fp.docs_file_path + + assert_equal ["GetCampaignRequest", "MutateCampaignsRequest", "CampaignOperation", "MutateCampaignsResponse", "MutateCampaignResult"], fp.messages.map(&:name) + fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } + + assert_equal [], fp.enums.map(&:name) + fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } + end +end diff --git a/gapic-generator/test/google/gapic/presenters/file/showcase_test.rb b/gapic-generator/test/google/gapic/presenters/file/showcase_test.rb new file mode 100644 index 000000000..690747501 --- /dev/null +++ b/gapic-generator/test/google/gapic/presenters/file/showcase_test.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true + +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require "test_helper" + +class ShowcaseFilePresenterTest < PresenterTest + def schema + api :showcase + end + + def test_echo + file = schema.files.find { |f| f.name == "google/showcase/v1alpha3/echo.proto" } + fp = FilePresenter.new schema, file + + assert_equal ["google", "showcase", "v1alpha3"], fp.address + assert_equal "Google::Showcase::V1alpha3", fp.namespace + assert_equal "google/showcase/v1alpha3/echo.rb", fp.docs_file_path + + assert_equal ["EchoRequest", "EchoResponse", "ExpandRequest", "PagedExpandRequest", "PagedExpandResponse", "WaitRequest", "WaitResponse", "WaitMetadata"], fp.messages.map(&:name) + fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } + + assert_equal [], fp.enums.map(&:name) + fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } + end + + def test_identity + file = schema.files.find { |f| f.name == "google/showcase/v1alpha3/identity.proto" } + fp = FilePresenter.new schema, file + + assert_equal ["google", "showcase", "v1alpha3"], fp.address + assert_equal "Google::Showcase::V1alpha3", fp.namespace + assert_equal "google/showcase/v1alpha3/identity.rb", fp.docs_file_path + + assert_equal ["User", "CreateUserRequest", "GetUserRequest", "UpdateUserRequest", "DeleteUserRequest", "ListUsersRequest", "ListUsersResponse"], fp.messages.map(&:name) + fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } + + assert_equal [], fp.enums.map(&:name) + fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } + end + + def test_messaging + file = schema.files.find { |f| f.name == "google/showcase/v1alpha3/messaging.proto" } + fp = FilePresenter.new schema, file + + assert_equal ["google", "showcase", "v1alpha3"], fp.address + assert_equal "Google::Showcase::V1alpha3", fp.namespace + assert_equal "google/showcase/v1alpha3/messaging.rb", fp.docs_file_path + + assert_equal ["Room", "CreateRoomRequest", "GetRoomRequest", "UpdateRoomRequest", "DeleteRoomRequest", "ListRoomsRequest", "ListRoomsResponse", "Blurb", "CreateBlurbRequest", "GetBlurbRequest", "UpdateBlurbRequest", "DeleteBlurbRequest", "ListBlurbsRequest", "ListBlurbsResponse", "SearchBlurbsRequest", "SearchBlurbsMetadata", "SearchBlurbsResponse", "StreamBlurbsRequest", "StreamBlurbsResponse", "SendBlurbsResponse", "ConnectRequest"], fp.messages.map(&:name) + fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } + + assert_equal [], fp.enums.map(&:name) + fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } + end + + def test_testing + file = schema.files.find { |f| f.name == "google/showcase/v1alpha3/testing.proto" } + fp = FilePresenter.new schema, file + + assert_equal ["google", "showcase", "v1alpha3"], fp.address + assert_equal "Google::Showcase::V1alpha3", fp.namespace + assert_equal "google/showcase/v1alpha3/testing.rb", fp.docs_file_path + + assert_equal ["Session", "CreateSessionRequest", "GetSessionRequest", "ListSessionsRequest", "ListSessionsResponse", "DeleteSessionRequest", "ReportSessionRequest", "ReportSessionResponse", "Test", "Issue", "ListTestsRequest", "ListTestsResponse", "TestRun", "DeleteTestRequest", "VerifyTestRequest", "VerifyTestResponse"], fp.messages.map(&:name) + fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } + + assert_equal [], fp.enums.map(&:name) + fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } + end +end diff --git a/gapic-generator/test/google/gapic/presenters/file/speech_test.rb b/gapic-generator/test/google/gapic/presenters/file/speech_test.rb new file mode 100644 index 000000000..fcf03cdfa --- /dev/null +++ b/gapic-generator/test/google/gapic/presenters/file/speech_test.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require "test_helper" + +class SpeechFilePresenterTest < PresenterTest + def schema + api :speech + end + + def test_cloud_speech + file = schema.files.find { |f| f.name == "google/cloud/speech/v1/cloud_speech.proto" } + fp = FilePresenter.new schema, file + + assert_equal ["google", "cloud", "speech", "v1"], fp.address + assert_equal "Google::Cloud::Speech::V1", fp.namespace + assert_equal "google/cloud/speech/v1/cloud_speech.rb", fp.docs_file_path + + assert_equal ["RecognizeRequest", "LongRunningRecognizeRequest", "StreamingRecognizeRequest", "StreamingRecognitionConfig", "RecognitionConfig", "SpeechContext", "RecognitionAudio", "RecognizeResponse", "LongRunningRecognizeResponse", "LongRunningRecognizeMetadata", "StreamingRecognizeResponse", "StreamingRecognitionResult", "SpeechRecognitionResult", "SpeechRecognitionAlternative", "WordInfo"], fp.messages.map(&:name) + fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } + + assert_equal [], fp.enums.map(&:name) + fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } + end +end diff --git a/gapic-generator/test/google/gapic/presenters/file/vision_test.rb b/gapic-generator/test/google/gapic/presenters/file/vision_test.rb new file mode 100644 index 000000000..96d1ed25a --- /dev/null +++ b/gapic-generator/test/google/gapic/presenters/file/vision_test.rb @@ -0,0 +1,113 @@ +# frozen_string_literal: true + +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require "test_helper" + +class VisionFilePresenterTest < PresenterTest + def schema + api :vision + end + + def test_geometry + file = schema.files.find { |f| f.name == "google/cloud/vision/v1/geometry.proto" } + fp = FilePresenter.new schema, file + + assert_equal ["google", "cloud", "vision", "v1"], fp.address + assert_equal "Google::Cloud::Vision::V1", fp.namespace + assert_equal "google/cloud/vision/v1/geometry.rb", fp.docs_file_path + + assert_equal ["Vertex", "NormalizedVertex", "BoundingPoly", "Position"], fp.messages.map(&:name) + fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } + + assert_equal [], fp.enums.map(&:name) + fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } + end + + def test_product_search_service + file = schema.files.find { |f| f.name == "google/cloud/vision/v1/product_search_service.proto" } + fp = FilePresenter.new schema, file + + assert_equal ["google", "cloud", "vision", "v1"], fp.address + assert_equal "Google::Cloud::Vision::V1", fp.namespace + assert_equal "google/cloud/vision/v1/product_search_service.rb", fp.docs_file_path + + assert_equal ["Product", "ProductSet", "ReferenceImage", "CreateProductRequest", "ListProductsRequest", "ListProductsResponse", "GetProductRequest", "UpdateProductRequest", "DeleteProductRequest", "CreateProductSetRequest", "ListProductSetsRequest", "ListProductSetsResponse", "GetProductSetRequest", "UpdateProductSetRequest", "DeleteProductSetRequest", "CreateReferenceImageRequest", "ListReferenceImagesRequest", "ListReferenceImagesResponse", "GetReferenceImageRequest", "DeleteReferenceImageRequest", "AddProductToProductSetRequest", "RemoveProductFromProductSetRequest", "ListProductsInProductSetRequest", "ListProductsInProductSetResponse", "ImportProductSetsGcsSource", "ImportProductSetsInputConfig", "ImportProductSetsRequest", "ImportProductSetsResponse", "BatchOperationMetadata"], fp.messages.map(&:name) + fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } + + assert_equal [], fp.enums.map(&:name) + fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } + end + + def test_product_search + file = schema.files.find { |f| f.name == "google/cloud/vision/v1/product_search.proto" } + fp = FilePresenter.new schema, file + + assert_equal ["google", "cloud", "vision", "v1"], fp.address + assert_equal "Google::Cloud::Vision::V1", fp.namespace + assert_equal "google/cloud/vision/v1/product_search.rb", fp.docs_file_path + + assert_equal ["ProductSearchParams", "ProductSearchResults"], fp.messages.map(&:name) + fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } + + assert_equal [], fp.enums.map(&:name) + fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } + end + + def test_text_annotation + file = schema.files.find { |f| f.name == "google/cloud/vision/v1/text_annotation.proto" } + fp = FilePresenter.new schema, file + + assert_equal ["google", "cloud", "vision", "v1"], fp.address + assert_equal "Google::Cloud::Vision::V1", fp.namespace + assert_equal "google/cloud/vision/v1/text_annotation.rb", fp.docs_file_path + + assert_equal ["TextAnnotation", "Page", "Block", "Paragraph", "Word", "Symbol"], fp.messages.map(&:name) + fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } + + assert_equal [], fp.enums.map(&:name) + fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } + end + + def test_web_detection + file = schema.files.find { |f| f.name == "google/cloud/vision/v1/web_detection.proto" } + fp = FilePresenter.new schema, file + + assert_equal ["google", "cloud", "vision", "v1"], fp.address + assert_equal "Google::Cloud::Vision::V1", fp.namespace + assert_equal "google/cloud/vision/v1/web_detection.rb", fp.docs_file_path + + assert_equal ["WebDetection"], fp.messages.map(&:name) + fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } + + assert_equal [], fp.enums.map(&:name) + fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } + end + + def test_image_annotator + file = schema.files.find { |f| f.name == "google/cloud/vision/v1/image_annotator.proto" } + fp = FilePresenter.new schema, file + + assert_equal ["google", "cloud", "vision", "v1"], fp.address + assert_equal "Google::Cloud::Vision::V1", fp.namespace + assert_equal "google/cloud/vision/v1/image_annotator.rb", fp.docs_file_path + + assert_equal ["Feature", "ImageSource", "Image", "FaceAnnotation", "LocationInfo", "Property", "EntityAnnotation", "LocalizedObjectAnnotation", "SafeSearchAnnotation", "LatLongRect", "ColorInfo", "DominantColorsAnnotation", "ImageProperties", "CropHint", "CropHintsAnnotation", "CropHintsParams", "WebDetectionParams", "ImageContext", "AnnotateImageRequest", "ImageAnnotationContext", "AnnotateImageResponse", "AnnotateFileResponse", "BatchAnnotateImagesRequest", "BatchAnnotateImagesResponse", "AsyncAnnotateFileRequest", "AsyncAnnotateFileResponse", "AsyncBatchAnnotateFilesRequest", "AsyncBatchAnnotateFilesResponse", "InputConfig", "OutputConfig", "GcsSource", "GcsDestination", "OperationMetadata"], fp.messages.map(&:name) + fp.messages.each { |mp| assert_kind_of MessagePresenter, mp } + + assert_equal ["Likelihood"], fp.enums.map(&:name) + fp.enums.each { |ep| assert_kind_of EnumPresenter, ep } + end +end diff --git a/gapic-generator/test/google/gapic/presenters/gem/garbage_test.rb b/gapic-generator/test/google/gapic/presenters/gem/garbage_test.rb new file mode 100644 index 000000000..a8a48ff75 --- /dev/null +++ b/gapic-generator/test/google/gapic/presenters/gem/garbage_test.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require "test_helper" + +class GarbageGemPresenterTest < PresenterTest + def presenter + GemPresenter.new api :garbage + end + + def test_garbage + assert_equal ["Google", "Garbage"], presenter.address + assert_equal "google-garbage", presenter.name + assert_equal "Google::Garbage", presenter.namespace + assert_equal "Google Garbage", presenter.title + assert_equal "0.0.1", presenter.version + assert_equal "google/garbage/version", presenter.version_require + assert_equal "google/garbage/version.rb", presenter.version_file_path + assert_equal "Google::Garbage::VERSION", presenter.version_name_full + assert_equal ["Google LLC"], presenter.authors + assert_equal "googleapis-packages@google.com", presenter.email + assert_equal "google-garbage is the official library for Google Garbage API.", presenter.description + assert_equal "API Client library for Google Garbage API", presenter.summary + assert_equal "https://github.com/googleapis/googleapis", presenter.homepage + assert_equal "GARBAGE", presenter.env_prefix + + assert_equal ["endless.trash.forever"], presenter.packages.map(&:name) + presenter.packages.each { |pp| assert_kind_of PackagePresenter, pp } + + assert_equal ["GarbageService"], presenter.services.map(&:name) + presenter.services.each { |sp| assert_kind_of ServicePresenter, sp } + + assert_equal ["google/api/http.proto", "google/protobuf/descriptor.proto", "google/api/client.proto", "google/api/field_behavior.proto", "google/api/resource.proto", "google/protobuf/any.proto", "google/protobuf/empty.proto", "google/rpc/status.proto", "google/longrunning/operations.proto", "google/protobuf/timestamp.proto", "garbage/garbage.proto"], presenter.proto_files.map(&:name) + presenter.proto_files.each { |fp| assert_kind_of FilePresenter, fp } + end +end diff --git a/gapic-generator/test/google/gapic/presenters/gem/googleads_test.rb b/gapic-generator/test/google/gapic/presenters/gem/googleads_test.rb new file mode 100644 index 000000000..afc845ebc --- /dev/null +++ b/gapic-generator/test/google/gapic/presenters/gem/googleads_test.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require "test_helper" + +class GoogleAdsGemPresenterTest < PresenterTest + def presenter + GemPresenter.new api :googleads + end + + def test_googleads + assert_equal ["Google", "Ads", "Googleads"], presenter.address + assert_equal "google-ads-googleads", presenter.name + assert_equal "Google::Ads::GoogleAds", presenter.namespace + assert_equal "Google Ads GoogleAds", presenter.title + assert_equal "0.0.1", presenter.version + assert_equal "google/ads/google_ads/version", presenter.version_require + assert_equal "google/ads/google_ads/version.rb", presenter.version_file_path + assert_equal "Google::Ads::GoogleAds::VERSION", presenter.version_name_full + assert_equal ["Google LLC"], presenter.authors + assert_equal "googleapis-packages@google.com", presenter.email + assert_equal "google-ads-googleads is the official library for Google Ads GoogleAds API.", presenter.description + assert_equal "API Client library for Google Ads GoogleAds API", presenter.summary + assert_equal "https://github.com/googleapis/googleapis", presenter.homepage + assert_equal "GOOGLEADS", presenter.env_prefix + + assert_equal ["google.ads.googleads.v1.services"], presenter.packages.map(&:name) + presenter.packages.each { |pp| assert_kind_of PackagePresenter, pp } + + assert_equal ["CampaignService"], presenter.services.map(&:name) + presenter.services.each { |sp| assert_kind_of ServicePresenter, sp } + + assert_equal ["google/api/http.proto", "google/protobuf/descriptor.proto", "google/ads/googleads/v1/enums/page_one_promoted_strategy_goal.proto", "google/ads/googleads/v1/enums/target_impression_share_location.proto", "google/protobuf/wrappers.proto", "google/ads/googleads/v1/common/bidding.proto", "google/ads/googleads/v1/common/custom_parameter.proto", "google/ads/googleads/v1/enums/frequency_cap_event_type.proto", "google/ads/googleads/v1/enums/frequency_cap_level.proto", "google/ads/googleads/v1/enums/frequency_cap_time_unit.proto", "google/ads/googleads/v1/common/frequency_cap.proto", "google/ads/googleads/v1/common/real_time_bidding_setting.proto", "google/ads/googleads/v1/enums/targeting_dimension.proto", "google/ads/googleads/v1/common/targeting_setting.proto", "google/ads/googleads/v1/enums/ad_serving_optimization_status.proto", "google/ads/googleads/v1/enums/advertising_channel_sub_type.proto", "google/ads/googleads/v1/enums/advertising_channel_type.proto", "google/ads/googleads/v1/enums/bidding_strategy_type.proto", "google/ads/googleads/v1/enums/brand_safety_suitability.proto", "google/ads/googleads/v1/enums/campaign_serving_status.proto", "google/ads/googleads/v1/enums/campaign_status.proto", "google/ads/googleads/v1/enums/negative_geo_target_type.proto", "google/ads/googleads/v1/enums/positive_geo_target_type.proto", "google/ads/googleads/v1/enums/vanity_pharma_display_url_mode.proto", "google/ads/googleads/v1/enums/vanity_pharma_text.proto", "google/ads/googleads/v1/resources/campaign.proto", "google/protobuf/field_mask.proto", "google/protobuf/any.proto", "google/rpc/status.proto", "google/ads/googleads/v1/services/campaign_service.proto"], presenter.proto_files.map(&:name) + presenter.proto_files.each { |fp| assert_kind_of FilePresenter, fp } + end +end diff --git a/gapic-generator/test/google/gapic/presenters/gem/showcase_test.rb b/gapic-generator/test/google/gapic/presenters/gem/showcase_test.rb new file mode 100644 index 000000000..89d9f858f --- /dev/null +++ b/gapic-generator/test/google/gapic/presenters/gem/showcase_test.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require "test_helper" + +class ShowcaseGemPresenterTest < PresenterTest + def presenter + GemPresenter.new api :showcase + end + + def test_showcase + assert_equal ["Google", "Showcase"], presenter.address + assert_equal "google-showcase", presenter.name + assert_equal "Google::Showcase", presenter.namespace + assert_equal "Google Showcase", presenter.title + assert_equal "0.0.1", presenter.version + assert_equal "google/showcase/version", presenter.version_require + assert_equal "google/showcase/version.rb", presenter.version_file_path + assert_equal "Google::Showcase::VERSION", presenter.version_name_full + assert_equal ["Google LLC"], presenter.authors + assert_equal "googleapis-packages@google.com", presenter.email + assert_equal "google-showcase is the official library for Google Showcase API.", presenter.description + assert_equal "API Client library for Google Showcase API", presenter.summary + assert_equal "https://github.com/googleapis/googleapis", presenter.homepage + assert_equal "SHOWCASE", presenter.env_prefix + + assert_equal ["google.showcase.v1alpha3"], presenter.packages.map(&:name) + presenter.packages.each { |pp| assert_kind_of PackagePresenter, pp } + + assert_equal ["Echo", "Identity", "Messaging", "Testing"], presenter.services.map(&:name) + presenter.services.each { |sp| assert_kind_of ServicePresenter, sp } + + assert_equal ["google/api/http.proto", "google/protobuf/descriptor.proto", "google/api/client.proto", "google/api/field_behavior.proto", "google/protobuf/any.proto", "google/protobuf/empty.proto", "google/rpc/status.proto", "google/longrunning/operations.proto", "google/protobuf/duration.proto", "google/protobuf/timestamp.proto", "google/showcase/v1alpha3/echo.proto", "google/api/resource.proto", "google/protobuf/field_mask.proto", "google/showcase/v1alpha3/identity.proto", "google/rpc/error_details.proto", "google/showcase/v1alpha3/messaging.proto", "google/showcase/v1alpha3/testing.proto"], presenter.proto_files.map(&:name) + presenter.proto_files.each { |fp| assert_kind_of FilePresenter, fp } + end +end diff --git a/gapic-generator/test/google/gapic/presenters/gem/speech_test.rb b/gapic-generator/test/google/gapic/presenters/gem/speech_test.rb new file mode 100644 index 000000000..cdda95214 --- /dev/null +++ b/gapic-generator/test/google/gapic/presenters/gem/speech_test.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require "test_helper" + +class SpeechGemPresenterTest < PresenterTest + def presenter + GemPresenter.new api :speech + end + + def test_speech + assert_equal ["Google", "Cloud", "Speech"], presenter.address + assert_equal "google-cloud-speech", presenter.name + assert_equal "Google::Cloud::Speech", presenter.namespace + assert_equal "Google Cloud Speech", presenter.title + assert_equal "0.0.1", presenter.version + assert_equal "google/cloud/speech/version", presenter.version_require + assert_equal "google/cloud/speech/version.rb", presenter.version_file_path + assert_equal "Google::Cloud::Speech::VERSION", presenter.version_name_full + assert_equal ["Google LLC"], presenter.authors + assert_equal "googleapis-packages@google.com", presenter.email + assert_equal "google-cloud-speech is the official library for Google Cloud Speech API.", presenter.description + assert_equal "API Client library for Google Cloud Speech API", presenter.summary + assert_equal "https://github.com/googleapis/googleapis", presenter.homepage + assert_equal "SPEECH", presenter.env_prefix + + assert_equal ["google.cloud.speech.v1"], presenter.packages.map(&:name) + presenter.packages.each { |pp| assert_kind_of PackagePresenter, pp } + + assert_equal ["Speech"], presenter.services.map(&:name) + presenter.services.each { |sp| assert_kind_of ServicePresenter, sp } + + assert_equal ["google/api/http.proto", "google/protobuf/descriptor.proto", "google/protobuf/any.proto", "google/protobuf/empty.proto", "google/rpc/status.proto", "google/longrunning/operations.proto", "google/protobuf/duration.proto", "google/protobuf/timestamp.proto", "google/cloud/speech/v1/cloud_speech.proto"], presenter.proto_files.map(&:name) + presenter.proto_files.each { |fp| assert_kind_of FilePresenter, fp } + end +end diff --git a/gapic-generator/test/google/gapic/presenters/gem/vision_test.rb b/gapic-generator/test/google/gapic/presenters/gem/vision_test.rb new file mode 100644 index 000000000..9f4cbdaab --- /dev/null +++ b/gapic-generator/test/google/gapic/presenters/gem/vision_test.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require "test_helper" + +class VisionGemPresenterTest < PresenterTest + def presenter + GemPresenter.new api :vision + end + + def test_vision + assert_equal ["Google", "Cloud", "Vision"], presenter.address + assert_equal "google-cloud-vision", presenter.name + assert_equal "Google::Cloud::Vision", presenter.namespace + assert_equal "Google Cloud Vision", presenter.title + assert_equal "0.0.1", presenter.version + assert_equal "google/cloud/vision/version", presenter.version_require + assert_equal "google/cloud/vision/version.rb", presenter.version_file_path + assert_equal "Google::Cloud::Vision::VERSION", presenter.version_name_full + assert_equal ["Google LLC"], presenter.authors + assert_equal "googleapis-packages@google.com", presenter.email + assert_equal "google-cloud-vision is the official library for Google Cloud Vision API.", presenter.description + assert_equal "API Client library for Google Cloud Vision API", presenter.summary + assert_equal "https://github.com/googleapis/googleapis", presenter.homepage + assert_equal "VISION", presenter.env_prefix + + assert_equal ["google.cloud.vision.v1"], presenter.packages.map(&:name) + presenter.packages.each { |pp| assert_kind_of PackagePresenter, pp } + + assert_equal ["ProductSearch", "ImageAnnotator"], presenter.services.map(&:name) + presenter.services.each { |sp| assert_kind_of ServicePresenter, sp } + + assert_equal ["google/api/http.proto", "google/protobuf/descriptor.proto", "google/cloud/vision/v1/geometry.proto", "google/protobuf/any.proto", "google/protobuf/empty.proto", "google/rpc/status.proto", "google/longrunning/operations.proto", "google/protobuf/field_mask.proto", "google/protobuf/timestamp.proto", "google/cloud/vision/v1/product_search_service.proto", "google/cloud/vision/v1/product_search.proto", "google/cloud/vision/v1/text_annotation.proto", "google/cloud/vision/v1/web_detection.proto", "google/protobuf/wrappers.proto", "google/type/color.proto", "google/type/latlng.proto", "google/cloud/vision/v1/image_annotator.proto"], presenter.proto_files.map(&:name) + presenter.proto_files.each { |fp| assert_kind_of FilePresenter, fp } + end +end diff --git a/gapic-generator/test/google/gapic/presenters/package/garbage_test.rb b/gapic-generator/test/google/gapic/presenters/package/garbage_test.rb new file mode 100644 index 000000000..d1fa9a2b2 --- /dev/null +++ b/gapic-generator/test/google/gapic/presenters/package/garbage_test.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require "test_helper" + +class GarbagePackagePresenterTest < PresenterTest + def test_endless_trash_forever + presenter = PackagePresenter.new api(:garbage), "endless.trash.forever" + + assert_equal ["endless", "trash", "forever"], presenter.address + assert_equal "endless.trash.forever", presenter.name + assert_equal "So::Much::Trash", presenter.namespace + assert_equal "so/much/trash", presenter.version_require + assert_equal "so/much/trash.rb", presenter.version_file_path + + assert_kind_of GemPresenter, presenter.gem + + assert_equal ["GarbageService"], presenter.services.map(&:name) + presenter.services.each { |sp| assert_kind_of ServicePresenter, sp } + end +end diff --git a/gapic-generator/test/google/gapic/presenters/package/googleads_test.rb b/gapic-generator/test/google/gapic/presenters/package/googleads_test.rb new file mode 100644 index 000000000..05d893772 --- /dev/null +++ b/gapic-generator/test/google/gapic/presenters/package/googleads_test.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require "test_helper" + +class GoogleAdsPackagePresenterTest < PresenterTest + def test_google_ads_googleads_v1_services + presenter = PackagePresenter.new api(:googleads), "google.ads.googleads.v1.services" + + assert_equal ["google", "ads", "googleads", "v1", "services"], presenter.address + assert_equal "google.ads.googleads.v1.services", presenter.name + assert_equal "Google::Ads::GoogleAds::V1::Services", presenter.namespace + assert_equal "google/ads/google_ads/v1/services", presenter.version_require + assert_equal "google/ads/google_ads/v1/services.rb", presenter.version_file_path + + assert_kind_of GemPresenter, presenter.gem + + assert_equal ["CampaignService"], presenter.services.map(&:name) + presenter.services.each { |sp| assert_kind_of ServicePresenter, sp } + end +end diff --git a/gapic-generator/test/google/gapic/presenters/package/showcase_test.rb b/gapic-generator/test/google/gapic/presenters/package/showcase_test.rb new file mode 100644 index 000000000..bbaddd8cb --- /dev/null +++ b/gapic-generator/test/google/gapic/presenters/package/showcase_test.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require "test_helper" + +class ShowcasePackagePresenterTest < PresenterTest + def test_google_showcase_v1alpha3 + presenter = PackagePresenter.new api(:showcase), "google.showcase.v1alpha3" + + assert_equal ["google", "showcase", "v1alpha3"], presenter.address + assert_equal "google.showcase.v1alpha3", presenter.name + assert_equal "Google::Showcase::V1alpha3", presenter.namespace + assert_equal "google/showcase/v1alpha3", presenter.version_require + assert_equal "google/showcase/v1alpha3.rb", presenter.version_file_path + + assert_kind_of GemPresenter, presenter.gem + + assert_equal ["Echo", "Identity", "Messaging", "Testing"], presenter.services.map(&:name) + presenter.services.each { |sp| assert_kind_of ServicePresenter, sp } + end +end diff --git a/gapic-generator/test/google/gapic/presenters/package/speech_test.rb b/gapic-generator/test/google/gapic/presenters/package/speech_test.rb new file mode 100644 index 000000000..4f7e6b132 --- /dev/null +++ b/gapic-generator/test/google/gapic/presenters/package/speech_test.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require "test_helper" + +class SpeechPackagePresenterTest < PresenterTest + def test_google_cloud_speech_v1 + presenter = PackagePresenter.new api(:speech), "google.cloud.speech.v1" + + assert_equal ["google", "cloud", "speech", "v1"], presenter.address + assert_equal "google.cloud.speech.v1", presenter.name + assert_equal "Google::Cloud::Speech::V1", presenter.namespace + assert_equal "google/cloud/speech/v1", presenter.version_require + assert_equal "google/cloud/speech/v1.rb", presenter.version_file_path + + assert_kind_of GemPresenter, presenter.gem + + assert_equal ["Speech"], presenter.services.map(&:name) + presenter.services.each { |sp| assert_kind_of ServicePresenter, sp } + end +end diff --git a/gapic-generator/test/google/gapic/presenters/package/vision_test.rb b/gapic-generator/test/google/gapic/presenters/package/vision_test.rb new file mode 100644 index 000000000..78cd74790 --- /dev/null +++ b/gapic-generator/test/google/gapic/presenters/package/vision_test.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require "test_helper" + +class VisionPackagePresenterTest < PresenterTest + def test_google_cloud_vision_v1 + presenter = PackagePresenter.new api(:vision), "google.cloud.vision.v1" + + assert_equal ["google", "cloud", "vision", "v1"], presenter.address + assert_equal "google.cloud.vision.v1", presenter.name + assert_equal "Google::Cloud::Vision::V1", presenter.namespace + assert_equal "google/cloud/vision/v1", presenter.version_require + assert_equal "google/cloud/vision/v1.rb", presenter.version_file_path + + assert_kind_of GemPresenter, presenter.gem + + assert_equal ["ProductSearch", "ImageAnnotator"], presenter.services.map(&:name) + presenter.services.each { |sp| assert_kind_of ServicePresenter, sp } + end +end