Skip to content

Add asynchronous methods for GetLatestVersion functionality - #1306

Open
dudnyk wants to merge 1 commit into
masterfrom
task/olpedge-2718
Open

Add asynchronous methods for GetLatestVersion functionality#1306
dudnyk wants to merge 1 commit into
masterfrom
task/olpedge-2718

Conversation

@dudnyk

@dudnykdudnyk commented Jan 25, 2022

Copy link
Copy Markdown
Contributor

Creation of asynchronous methods is a part of task
continuation changes, later will be used in asynchronous
GetVersion method. GetVersion is not added in this commit
as it's in the private section and cannot be covered with tests.

Add asynchronous version of GetLatestVersion method
which handles the logic of getting data from cache/network.
Add asynchronous version of GetLatestCatalogVersion.
Move common functionality of getting data from the cache
and storing data returned from a request to the cache
to the RetrieveLatestVersion function.

Add unit tests which cover asynchronous methods for getting
the latest version.
Replaced mock expectation arguments with WithoutArgs.

Relates-To: OLPEDGE-2718

Signed-off-by: Yevhenii Dudnyk ext-yevhenii.dudnyk@here.com

@codecov

codecovBot commented Jan 25, 2022

Copy link
Copy Markdown

Codecov Report

Merging #1306 (529fa85) into master (b1cd55b) will increase coverage by 0.1%.
The diff coverage is 98.8%.

❗ Current head 529fa85 differs from pull request most recent head 20d7ec1. Consider uploading reports for the commit 20d7ec1 to get more accurate results

Impacted file tree graph

@@ Coverage Diff @@## master #1306 +/- ##
========================================
+ Coverage 86.1% 86.2% +0.1% 
========================================
Files 381 381 Lines 13425 13497 +72 ========================================
+ Hits 11565 11636 +71 - Misses 1860 1861 +1 
Impacted FilesCoverage Δ
...aservice-read/src/repositories/CatalogRepository.h100.0% <ø> (ø)
...ervice-read/src/repositories/CatalogRepository.cpp99.3% <98.5%> (-0.7%)⬇️
...dataservice-read/src/generated/api/MetadataApi.cpp72.4% <100.0%> (+5.0%)⬆️
...ice-read/src/repositories/CatalogCacheRepository.h100.0% <0.0%> (ø)
...clude/olp/dataservice/read/CatalogVersionRequest.h95.8% <0.0%> (+0.6%)⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1cd55b...20d7ec1. Read the comment docs.

@dudnykdudnyk changed the title Task/olpedge 2718Add GetVersionOnline method Jan 26, 2022
@dudnyk
dudnykforce-pushed the task/olpedge-2718 branch 15 times, most recently from afd16fe to 21d435aCompareFebruary 1, 2022 09:49
@dudnykdudnyk changed the title Add GetVersionOnline method Add asynchronous methods for GetLatestVersion functionalityFeb 1, 2022
@dudnyk
dudnykforce-pushed the task/olpedge-2718 branch 2 times, most recently from 0c57b8f to e93ebbcCompareFebruary 1, 2022 09:54
Comment threadolp-cpp-sdk-dataservice-read/src/generated/api/MetadataApi.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/src/generated/api/MetadataApi.h Outdated
Comment threadolp-cpp-sdk-dataservice-read/src/generated/api/MetadataApi.h Outdated
Comment threadolp-cpp-sdk-dataservice-read/src/repositories/CatalogRepository.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/src/repositories/CatalogRepository.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/src/repositories/CatalogRepository.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/src/repositories/CatalogRepository.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/src/repositories/CatalogRepository.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/src/repositories/CatalogRepository.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/src/repositories/CatalogRepository.cpp Outdated
@dudnyk
dudnykforce-pushed the task/olpedge-2718 branch 3 times, most recently from 27bc9ff to aba52e9CompareFebruary 3, 2022 08:48
Comment threadolp-cpp-sdk-dataservice-read/src/repositories/CatalogRepository.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/src/repositories/CatalogRepository.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/src/repositories/CatalogRepository.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/src/repositories/CatalogRepository.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/src/repositories/CatalogRepository.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/tests/CatalogRepositoryTest.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/tests/CatalogRepositoryTest.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/tests/CatalogRepositoryTest.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/tests/CatalogRepositoryTest.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/tests/CatalogRepositoryTest.cpp Outdated
@dudnyk
dudnykforce-pushed the task/olpedge-2718 branch 2 times, most recently from 9b268e8 to 1ea88ecCompareFebruary 4, 2022 16:15
Comment threadolp-cpp-sdk-dataservice-read/src/repositories/CatalogRepository.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/src/repositories/CatalogRepository.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/src/repositories/CatalogRepository.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/src/repositories/CatalogRepository.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/src/generated/api/MetadataApi.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/tests/CatalogRepositoryTest.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/tests/CatalogRepositoryTest.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/tests/CatalogRepositoryTest.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/tests/CatalogRepositoryTest.cpp Outdated
Comment threadolp-cpp-sdk-dataservice-read/tests/CatalogRepositoryTest.cpp Outdated
Creation of asynchronous methods is a part of task
continuation changes, later will be used in asynchronous
GetVersion method. GetVersion is not added in this commit
as it's in the private section and cannot be covered with tests.
Add asynchronous version of GetLatestVersion method
which handles the logic of getting data from cache/network.
Add asynchronous version of GetLatestCatalogVersion.
Move common functionality of getting data from the cache
and storing data returned from a request to the cache
to the RetrieveLatestVersion function.
Add unit tests which cover asynchronous methods for getting
the latest version.
Replaced mock expectation arguments with WithoutArgs.
Relates-To: OLPEDGE-2718
Signed-off-by: Yevhenii Dudnyk <ext-yevhenii.dudnyk@here.com>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
read::CatalogVersionCallbackcallback);
CatalogVersionCallbackcallback);

}
}

return std::move(version_response);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pessimizing-move
More info: https://stackoverflow.com/questions/62061433/how-to-avoid-the-pessimizing-move-warning-of-nrvo

Suggested change
returnstd::move(version_response);
return version_response;

version_response = std::move(*cached_version);
}

return std::move(version_response);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pessimizing-move
More info: https://stackoverflow.com/questions/62061433/how-to-avoid-the-pessimizing-move-warning-of-nrvo

Suggested change
returnstd::move(version_response);
return version_response;


lookup_client_ =
std::make_shared<olp::client::ApiLookupClient>(kHrn, settings_);
lookup_client_ = std::make_shared<client::ApiLookupClient>(kHrn, settings_);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a distinct using for this one.

Suggested change
lookup_client_ = std::make_shared<client::ApiLookupClient>(kHrn, settings_);
lookup_client_ = std::make_shared<ApiLookupClient>(kHrn, settings_);

olp::client::OlpClientSettings settings_;
std::shared_ptr<olp::client::ApiLookupClient> lookup_client_;
client::OlpClientSettings settings_;
std::shared_ptr<client::ApiLookupClient> lookup_client_;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::shared_ptr<client::ApiLookupClient> lookup_client_;
std::shared_ptr<ApiLookupClient> lookup_client_;

olp::client::CancellationContext context;
TEST_F(CatalogRepositoryTest, AsyncGetLatestVersionOnlineOnlyForbidden) {
const auto request =
read::CatalogVersionRequest().WithFetchOption(read::OnlineIfNotFound);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have OnlineIfNotFound request, but the name of the test contains OnlineOnly. Also, line 316 contains a mention of OnlineOnly.

}

TEST_F(CatalogRepositoryTest, AsyncGetLatestVersionOnlineOnlyUserCancelled2) {
const auto request = read::CatalogVersionRequest();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A default fetch option is OnlineIfNotFound. But the test name contains OnlineOnly

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@dudnyk@mykolamalik