85 lines
3.1 KiB
C++
85 lines
3.1 KiB
C++
////////////////////////////////////////////////////////////////////////////////
|
|
// (c) Copyright, Ubisoft Entertainment Inc. || Created by Harbour //
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
#include "testsIntegration/processPrimaryStoreMockHelper.h"
|
|
#include "tests/mock/MockAsyncResult.h"
|
|
#include "tests/mock/MockHttpClientImpl.h"
|
|
#include "tests/mock/mockResultHelper.h"
|
|
#include "ubiservices/services/http/request/httpRequest.h"
|
|
|
|
namespace US_NS {;
|
|
|
|
ProcessPrimaryStoreMockHelper::ProcessPrimaryStoreMockHelper(const SpaceId& spaceId)
|
|
: m_spaceId(spaceId)
|
|
{
|
|
}
|
|
|
|
const SpaceId& ProcessPrimaryStoreMockHelper::getSpaceId()
|
|
{
|
|
return m_spaceId;
|
|
}
|
|
|
|
Json ProcessPrimaryStoreMockHelper::getMockMappingResult() const
|
|
{
|
|
#if defined(US_TARGET_ANDROID) || defined(US_TARGET_IOS) || defined(US_TARGET_WINDOWS) || defined(US_TARGET_UWP)
|
|
const char* const ITEM_ID_1 = "dummyUplayPcItemId";
|
|
const char* const ITEM_ID_2 = "dummyUplayPcConsumableId";
|
|
#elif defined(US_TARGET_PS4) || defined(US_TARGET_KILI)
|
|
const char* const ITEM_ID_1 = "UBISERVICESDLC01";
|
|
const char* const ITEM_ID_2 = "CONSU3";
|
|
#elif defined(US_TARGET_XONE)
|
|
const char* const ITEM_ID_1 = "6df724cf-af33-4767-842f-dcd7cf86b5ac"; //DLC-Skin
|
|
const char* const ITEM_ID_2 = "96287574-7512-465f-92e3-0003a9e078f8"; // Consumable 3
|
|
#else
|
|
const char* const ITEM_ID_1 = nullptr;
|
|
const char* const ITEM_ID_2 = nullptr;
|
|
#endif
|
|
|
|
JsonWriter mappingElements(JsonWriterType::Array);
|
|
{
|
|
JsonWriter mappingDlc;
|
|
if (ITEM_ID_1 != nullptr)
|
|
{
|
|
mappingDlc["primaryStoreItemId"] = ITEM_ID_1;
|
|
}
|
|
mappingDlc["items"] = JsonWriter(JsonWriterType::Array).getJson();
|
|
mappingElements.addItemToArray(mappingDlc.getJson());
|
|
}
|
|
{
|
|
JsonWriter mappingConsumable;
|
|
if (ITEM_ID_2 != nullptr)
|
|
{
|
|
mappingConsumable["primaryStoreItemId"] = ITEM_ID_2;
|
|
}
|
|
mappingConsumable["items"] = JsonWriter(JsonWriterType::Array).getJson();
|
|
mappingElements.addItemToArray(mappingConsumable.getJson());
|
|
}
|
|
|
|
JsonWriter mapping;
|
|
mapping["mappings"] = mappingElements.getJson();
|
|
|
|
return mapping.getJson();
|
|
}
|
|
|
|
void MockProcessPrimaryStoreHelper::mockProcessPrimaryStore(MockHttpClientImpl& client)
|
|
{
|
|
ProcessPrimaryStoreMockHelper mockHelper;
|
|
{
|
|
const MockAsyncResult mockResult = MockResultHelper::createSuccessResult(
|
|
mockHelper.getMockMappingResult().renderContent());
|
|
|
|
US_EXPECT_CALL_HTTP(client, HttpMethod::HTTP_GET,
|
|
String::formatText("/%s/mock-spaces-primarystoremapping", static_cast<String>(mockHelper.getSpaceId()).getUtf8()))
|
|
.Times(testing::AnyNumber())
|
|
.WillRepeatedly(testing::Return(mockResult));
|
|
}
|
|
|
|
{
|
|
const MockAsyncResult mockResult = MockResultHelper::createSuccessResult("{\"results\":[],\"errors\":[]}");
|
|
US_EXPECT_CALL_HTTP(client, HttpMethod::HTTP_POST, "/mock-profiles-inventory-primarystore")
|
|
.Times(testing::AnyNumber())
|
|
.WillRepeatedly(testing::Return(mockResult));
|
|
}
|
|
}
|
|
|
|
};
|