2020#include " CSP/Systems/Assets/AssetSystem.h"
2121#include " CSP/Systems/Spaces/SpaceSystem.h"
2222#include " CSP/Systems/SystemsManager.h"
23+ #include " RAIIMockLogger.h"
2324#include " SpaceSystemTestHelpers.h"
25+ #include " Systems/ResultHelpers.h"
2426#include " TestHelpers.h"
2527#include " UserSystemTestHelpers.h"
2628
@@ -2223,11 +2225,11 @@ CSP_PUBLIC_TEST(CSPEngine, AssetSystemTests, CopyAssetCollectionTest)
22232225 auto [Result] = AWAIT_PRE (AssetSystem, CopyAssetCollectionsToSpace, RequestPredicate, SourceAssetCollections, DestSpace.Id , false );
22242226
22252227 EXPECT_EQ (Result.GetResultCode (), csp::systems::EResultCode::Success);
2228+ EXPECT_EQ (Result.GetHttpResultCode (), 200 );
22262229
22272230 DestAssetCollections = Result.GetAssetCollections ();
22282231 }
22292232
2230- // Validate the copied asset collection and its data
22312233 {
22322234 printf (" Validating the copied asset collection and its data...\n " );
22332235
@@ -2263,27 +2265,39 @@ CSP_PUBLIC_TEST(CSPEngine, AssetSystemTests, CopyAssetCollectionTest)
22632265 EXPECT_EQ (memcmp (DownloadedAssetData, FileData, FileSize), 0 );
22642266 }
22652267
2266- // Validating that we must have at least one asset collection to copy
22672268 {
22682269 printf (" Validating that we must have at least one asset collection to copy...\n " );
22692270
2271+ RAIIMockLogger MockLogger {};
2272+ const csp::common::String Error = " No source asset collections were provided whilst attempting to perform a copy to another space." ;
2273+ EXPECT_CALL (MockLogger.MockLogCallback , Call (csp::common::LogLevel::Error, Error)).Times (1 );
2274+
22702275 const csp::common::Array<csp::systems::AssetCollection> AssetCollections;
22712276 auto [Result] = AWAIT_PRE (AssetSystem, CopyAssetCollectionsToSpace, RequestPredicate, AssetCollections, DestSpace.Id , false );
2277+ // This response is simulated by CSP prior to making the request to the service. Returns an invalid result.
2278+ EXPECT_EQ (Result, MakeInvalid<csp::systems::AssetCollectionsResult>());
22722279 EXPECT_EQ (Result.GetResultCode (), csp::systems::EResultCode::Failed);
2280+ EXPECT_EQ (Result.GetAssetCollections ().Size (), 0 );
22732281 }
22742282
2275- // Validating we cannot perform a copy if the asset has no space ID
22762283 {
22772284 printf (" Validating we cannot perform a copy if the asset has no space ID...\n " );
22782285
22792286 csp::systems::AssetCollection NoSpaceIDAssetCollection;
22802287
2288+ RAIIMockLogger MockLogger {};
2289+ const csp::common::String Error
2290+ = " An asset with no space ID was provided whilst attempting to perform a copy to another space. All assets must have a valid space ID." ;
2291+ EXPECT_CALL (MockLogger.MockLogCallback , Call (csp::common::LogLevel::Error, Error)).Times (1 );
2292+
22812293 const csp::common::Array<csp::systems::AssetCollection> AssetCollections = { NoSpaceIDAssetCollection };
22822294 auto [Result] = AWAIT_PRE (AssetSystem, CopyAssetCollectionsToSpace, RequestPredicate, AssetCollections, DestSpace.Id , false );
2295+ // This response is simulated by CSP prior to making the request to the service. Returns an invalid result.
2296+ EXPECT_EQ (Result, MakeInvalid<csp::systems::AssetCollectionsResult>());
22832297 EXPECT_EQ (Result.GetResultCode (), csp::systems::EResultCode::Failed);
2298+ EXPECT_EQ (Result.GetAssetCollections ().Size (), 0 );
22842299 }
22852300
2286- // Validating we cannot perform a copy of assets that belong to different spaces
22872301 {
22882302 printf (" Validating we cannot perform a copy of assets that belong to different spaces but still get the async response...\n " );
22892303
@@ -2293,9 +2307,60 @@ CSP_PUBLIC_TEST(CSPEngine, AssetSystemTests, CopyAssetCollectionTest)
22932307 csp::systems::AssetCollection SecondSpaceAssetCollection;
22942308 SecondSpaceAssetCollection.SpaceId = " 456789" ;
22952309
2310+ RAIIMockLogger MockLogger {};
2311+ const csp::common::String Error = " All asset collections must belong to the same space for a copy operation." ;
2312+ EXPECT_CALL (MockLogger.MockLogCallback , Call (csp::common::LogLevel::Error, Error)).Times (1 );
2313+
22962314 const csp::common::Array<csp::systems::AssetCollection> AssetCollections = { FirstSpaceAssetCollection, SecondSpaceAssetCollection };
22972315 auto [Result] = AWAIT_PRE (AssetSystem, CopyAssetCollectionsToSpace, RequestPredicate, AssetCollections, DestSpace.Id , false );
2316+ // This response is simulated by CSP prior to making the request to the service. Returns an invalid result.
2317+ EXPECT_EQ (Result, MakeInvalid<csp::systems::AssetCollectionsResult>());
2318+ EXPECT_EQ (Result.GetResultCode (), csp::systems::EResultCode::Failed);
2319+ EXPECT_EQ (Result.GetAssetCollections ().Size (), 0 );
2320+ }
2321+
2322+ {
2323+ printf (" Validating we encounter failures when providing malformed asset collection IDs...\n " );
2324+
2325+ csp::systems::AssetCollection FirstSpaceAssetCollection;
2326+ FirstSpaceAssetCollection.SpaceId = SourceSpace.Id ;
2327+ FirstSpaceAssetCollection.Id = " AnInvalidlId" ;
2328+
2329+ const csp::common::Array<csp::systems::AssetCollection> AssetCollections = { FirstSpaceAssetCollection };
2330+ auto [Result] = AWAIT_PRE (AssetSystem, CopyAssetCollectionsToSpace, RequestPredicate, AssetCollections, DestSpace.Id , false );
2331+ // This response is returned by the service.
2332+ EXPECT_EQ (Result.GetResultCode (), csp::systems::EResultCode::Failed);
2333+ EXPECT_EQ (Result.GetHttpResultCode (), 400 );
2334+ EXPECT_EQ (Result.GetAssetCollections ().Size (), 0 );
2335+ // The response does not come with an x-errorcode.
2336+ EXPECT_EQ (Result.GetFailureReason (), csp::systems::ERequestFailureReason::None);
2337+ }
2338+
2339+ {
2340+ printf (" Validating we encounter failures when a malformed destination space ID is provided...\n " );
2341+
2342+ const csp::common::String InvalidDestSpaceId = " AnInvalidlId" ;
2343+ const csp::common::Array<csp::systems::AssetCollection> AssetCollections = { SourceAssetCollection };
2344+ auto [Result] = AWAIT_PRE (AssetSystem, CopyAssetCollectionsToSpace, RequestPredicate, AssetCollections, InvalidDestSpaceId, false );
2345+ // This response is returned by the service.
2346+ EXPECT_EQ (Result.GetResultCode (), csp::systems::EResultCode::Failed);
2347+ EXPECT_EQ (Result.GetHttpResultCode (), 400 );
2348+ EXPECT_EQ (Result.GetAssetCollections ().Size (), 0 );
2349+ // The response does not come with an x-errorcode.
2350+ EXPECT_EQ (Result.GetFailureReason (), csp::systems::ERequestFailureReason::None);
2351+ }
2352+
2353+ {
2354+ printf (" Validating that we cannot copy an asset to the same space...\n " );
2355+
2356+ const csp::common::Array<csp::systems::AssetCollection> AssetCollections = { SourceAssetCollection };
2357+ auto [Result] = AWAIT_PRE (AssetSystem, CopyAssetCollectionsToSpace, RequestPredicate, AssetCollections, SourceSpace.Id , false );
2358+ // This response is returned by the service.
22982359 EXPECT_EQ (Result.GetResultCode (), csp::systems::EResultCode::Failed);
2360+ EXPECT_EQ (Result.GetHttpResultCode (), 400 );
2361+ EXPECT_EQ (Result.GetAssetCollections ().Size (), 0 );
2362+ // The response does not come with an x-errorcode.
2363+ EXPECT_EQ (Result.GetFailureReason (), csp::systems::ERequestFailureReason::None);
22992364 }
23002365
23012366 // Delete spaces
0 commit comments