@@ -550,7 +550,7 @@ TEST_F(DataserviceReadVersionedLayerClientTest,
550550}
551551
552552TEST_F (DataserviceReadVersionedLayerClientTest,
553- GetDataFromPartitionCacheAndUpdateSync ) {
553+ GetDataFromPartitionOnlineIfNotFoundCacheUpdate ) {
554554 EXPECT_CALL (*network_mock_, Send (_, _, _, _, _))
555555 .WillOnce (ReturnHttpResponse (olp::http::NetworkResponse ().WithStatus (
556556 olp::http::HttpStatusCode::OK),
@@ -582,10 +582,9 @@ TEST_F(DataserviceReadVersionedLayerClientTest,
582582 auto token = client->GetData (
583583 olp::dataservice::read::DataRequest ()
584584 .WithPartitionId (partition)
585- .WithFetchOption (FetchOptions::CacheWithUpdate ),
585+ .WithFetchOption (FetchOptions::OnlineIfNotFound ),
586586 [&response](DataResponse resp) { response = std::move (resp); });
587- ASSERT_FALSE (response.IsSuccessful ());
588- ASSERT_FALSE (response.GetResult () != nullptr );
587+ ASSERT_TRUE (response.IsSuccessful ());
589588
590589 token = client->GetData (
591590 olp::dataservice::read::DataRequest ()
@@ -868,7 +867,7 @@ TEST_F(DataserviceReadVersionedLayerClientTest,
868867 olp::dataservice::read::DataRequest ()
869868 .WithVersion (version)
870869 .WithPartitionId (partition)
871- .WithFetchOption (FetchOptions::CacheWithUpdate ),
870+ .WithFetchOption (FetchOptions::OnlineIfNotFound ),
872871 [&promise](DataResponse response) { promise.set_value (response); });
873872
874873 wait_for_cancel->get_future ().get ();
@@ -1084,25 +1083,6 @@ TEST_F(DataserviceReadVersionedLayerClientTest, GetPartitionsCacheWithUpdate) {
10841083 auto catalog = olp::client::HRN::FromString (
10851084 GetArgument (" dataservice_read_test_catalog" ));
10861085 auto layer = GetArgument (" dataservice_read_test_layer" );
1087-
1088- auto wait_to_start_signal = std::make_shared<std::promise<void >>();
1089- auto pre_callback_wait = std::make_shared<std::promise<void >>();
1090- pre_callback_wait->set_value ();
1091- auto wait_for_end_signal = std::make_shared<std::promise<void >>();
1092-
1093- olp::http::RequestId request_id;
1094- NetworkCallback send_mock;
1095- CancelCallback cancel_mock;
1096-
1097- std::tie (request_id, send_mock, cancel_mock) = GenerateNetworkMockActions (
1098- wait_to_start_signal, pre_callback_wait,
1099- {olp::http::HttpStatusCode::OK, HTTP_RESPONSE_PARTITIONS},
1100- wait_for_end_signal);
1101-
1102- EXPECT_CALL (*network_mock_, Send (IsGetRequest (URL_PARTITIONS), _, _, _, _))
1103- .Times (1 )
1104- .WillOnce (testing::Invoke (std::move (send_mock)));
1105-
11061086 auto client = std::make_unique<olp::dataservice::read::VersionedLayerClient>(
11071087 catalog, layer, *settings_);
11081088
@@ -1121,8 +1101,6 @@ TEST_F(DataserviceReadVersionedLayerClientTest, GetPartitionsCacheWithUpdate) {
11211101 ASSERT_FALSE (response.IsSuccessful ()) << response.GetError ().GetMessage ();
11221102 }
11231103
1124- wait_for_end_signal->get_future ().get ();
1125-
11261104 // Request 2
11271105 {
11281106 auto promise = std::make_shared<std::promise<PartitionsResponse>>();
@@ -1134,8 +1112,8 @@ TEST_F(DataserviceReadVersionedLayerClientTest, GetPartitionsCacheWithUpdate) {
11341112 });
11351113 ASSERT_NE (future.wait_for (kWaitTimeout ), std::future_status::timeout);
11361114 PartitionsResponse response = future.get ();
1137- // Cache should be available here .
1138- ASSERT_TRUE (response.IsSuccessful ()) << response.GetError ().GetMessage ();
1115+ // Cache should not be available for versioned layer .
1116+ ASSERT_FALSE (response.IsSuccessful ()) << response.GetError ().GetMessage ();
11391117 }
11401118}
11411119
@@ -1949,24 +1927,6 @@ TEST_F(DataserviceReadVersionedLayerClientTest, GetData403CacheClear) {
19491927
19501928TEST_F (DataserviceReadVersionedLayerClientTest, GetDataCacheWithUpdate) {
19511929 olp::client::HRN hrn (GetTestCatalog ());
1952- // Setup the expected calls :
1953- auto wait_to_start_signal = std::make_shared<std::promise<void >>();
1954- auto pre_callback_wait = std::make_shared<std::promise<void >>();
1955- pre_callback_wait->set_value ();
1956- auto wait_for_end_signal = std::make_shared<std::promise<void >>();
1957-
1958- olp::http::RequestId request_id;
1959- NetworkCallback send_mock;
1960- CancelCallback cancel_mock;
1961-
1962- std::tie (request_id, send_mock, cancel_mock) = GenerateNetworkMockActions (
1963- wait_to_start_signal, pre_callback_wait,
1964- {olp::http::HttpStatusCode::OK, HTTP_RESPONSE_BLOB_DATA_269},
1965- wait_for_end_signal);
1966-
1967- EXPECT_CALL (*network_mock_, Send (IsGetRequest (URL_BLOB_DATA_269), _, _, _, _))
1968- .Times (1 )
1969- .WillOnce (testing::Invoke (std::move (send_mock)));
19701930
19711931 auto client =
19721932 std::make_unique<VersionedLayerClient>(hrn, " testlayer" , *settings_);
@@ -1979,13 +1939,11 @@ TEST_F(DataserviceReadVersionedLayerClientTest, GetDataCacheWithUpdate) {
19791939 ASSERT_FALSE (data_response.IsSuccessful ())
19801940 << ApiErrorToString (data_response.GetError ());
19811941 // Request 2 to check there is a cached value.
1982- // waiting for cache to fill-in
1983- wait_for_end_signal->get_future ().get ();
19841942 request.WithFetchOption (CacheOnly);
19851943 future = client->GetData (request);
19861944 data_response = future.GetFuture ().get ();
1987- // Cache should be available here .
1988- ASSERT_TRUE (data_response.IsSuccessful ())
1945+ // Cache should not be available for versioned layer .
1946+ ASSERT_FALSE (data_response.IsSuccessful ())
19891947 << ApiErrorToString (data_response.GetError ());
19901948}
19911949
@@ -2685,6 +2643,31 @@ TEST_F(DataserviceReadVersionedLayerClientTest, GetTileOnlineOnly) {
26852643 }
26862644}
26872645
2646+ TEST_F (DataserviceReadVersionedLayerClientTest, GetTileCacheWithUpdate) {
2647+ olp::client::HRN hrn (GetTestCatalog ());
2648+ auto client = std::make_unique<olp::dataservice::read::VersionedLayerClient>(
2649+ hrn, " testlayer" , 4 , *settings_);
2650+
2651+ auto request = olp::dataservice::read::TileRequest ()
2652+ .WithTileKey (olp::geo::TileKey::FromHereTile (" 5904591" ))
2653+ .WithFetchOption (CacheWithUpdate);
2654+ {
2655+ std::cout << " request<=" << request.GetFetchOption () << std::endl;
2656+ SCOPED_TRACE (" Request data using TileKey." );
2657+ auto data_response = client->GetData (request).GetFuture ().get ();
2658+
2659+ ASSERT_FALSE (data_response.IsSuccessful ())
2660+ << ApiErrorToString (data_response.GetError ());
2661+ }
2662+
2663+ {
2664+ SCOPED_TRACE (" Check cache, should not be avialible." );
2665+ auto future = client->GetData (request.WithFetchOption (CacheOnly));
2666+ auto data_response = future.GetFuture ().get ();
2667+ ASSERT_FALSE (data_response.IsSuccessful ());
2668+ }
2669+ }
2670+
26882671TEST_F (DataserviceReadVersionedLayerClientTest, GetTileTwoSequentialCalls) {
26892672 olp::client::HRN hrn (GetTestCatalog ());
26902673 auto client = std::make_unique<olp::dataservice::read::VersionedLayerClient>(
0 commit comments