--[[----------------------------------------------------------------------------

WFCatSpaceTestUtilsTest.lua

--------------------------------------------------------------------------------

ADOBE CONFIDENTIAL
------------------
Copyright 2022 Adobe

All Rights Reserved.
NOTICE: All information contained herein is, and remains
the property of Adobe and its suppliers, if any. The intellectual
and technical concepts contained herein are proprietary to Adobe
and its suppliers and are protected by all applicable intellectual
property laws, including trade secret and copyright laws.
Dissemination of this information or reproduction of this material
is strictly forbidden unless prior written permission is obtained
from Adobe.

------------------------------------------------------------------------------]]

	-- WF.core.self_test
local WFRxTestCase = require 'WFRxTestCase'

	-- WF.core.os
local KSDate = require 'KSDate'

	-- WF.core.utils
local KSIdGenerator = require 'KSIdGenerator'

    -- WF.oz_client.managed_catalog
local WFCatSpaceTestUtils = require 'WFCatSpaceTestUtils'
	
--============================================================================--

local WFCatSpaceTestUtilsTest = {}

--------------------------------------------------------------------------------

function WFCatSpaceTestUtilsTest.rxTestCreateComment( rxTest )

	local assetId = KSIdGenerator.uuidInLowercaseHex()
	local authorId = KSIdGenerator.uuidInLowercaseHex()
	local commentId = KSIdGenerator.uuidInLowercaseHex()
	local commentRevId = KSIdGenerator.uuidInLowercaseHex()
	local createdDate = KSDate.timeInIso8601Format( nil, false )
	local spaceId = KSIdGenerator.uuidInLowercaseHex()
	
	local commentDoc = {
			_id = commentId,
			_newRevId = commentRevId,
			type = 'comment',
			subtype = 'user',
			_spaceId = spaceId,
			asset = { id = assetId },
			body = 'foo',
			_localOnly = {
				created = createdDate,
				author = {
					id = authorId,
					full_name = "John Smith",
					first_name = "John",
					last_name = "Smith",
				},
			},
		}
		
	local overrides = {
			assetId = assetId,
			authorId = authorId,
			commentRevId = commentRevId,
			createdDate = createdDate,
			spaceId = spaceId,
		}
		
	local generatedCommentDoc = WFCatSpaceTestUtils.createComment( commentId, overrides )
	rxTest:expectEqual(commentDoc, generatedCommentDoc)
	
end

--------------------------------------------------------------------------------

function WFCatSpaceTestUtilsTest.rxTestCreateFavorite( rxTest )

	local assetId = KSIdGenerator.uuidInLowercaseHex()
	local authorId = KSIdGenerator.uuidInLowercaseHex()
	local createdDate = KSDate.timeInIso8601Format( nil, false )
	local favoriteId = KSIdGenerator.uuidInLowercaseHex()
	local spaceId = KSIdGenerator.uuidInLowercaseHex()
	
	local favoriteDoc = {
			_id = favoriteId,
			type = 'favorite',
			subtype = 'user',
			asset = { 
				id = assetId 
			},
			body = 'foo',
			_localOnly = {
				created = createdDate,
				author = {
					id = authorId,
					full_name = "John Smith",
					first_name = "John",
					last_name = "Smith",
				},
			},
			space = {
				id = spaceId 
			},
		}
		
	local overrides = {
			assetId = assetId,
			authorId = authorId,
			createdDate = createdDate,
			spaceId = spaceId,
		}
		
	local generatedFavoriteDoc = WFCatSpaceTestUtils.createFavorite( favoriteId, overrides )
	rxTest:expectEqual(favoriteDoc, generatedFavoriteDoc)
	
end

--------------------------------------------------------------------------------

function WFCatSpaceTestUtilsTest.rxTestCreateSpaceAlbum( rxTest )

	local spaceAlbumId = KSIdGenerator.uuidInLowercaseHex()
	local albumId = KSIdGenerator.uuidInLowercaseHex()
	local userCreatedDate = KSDate.timeInIso8601Format( nil, false )
	local userUpdatedDate = KSDate.timeInIso8601Format( nil, false )
	local spaceId = KSIdGenerator.uuidInLowercaseHex()
	
	local spaceAlbumDoc = {
				_id = spaceAlbumId,
				type = 'space_album',
				space = {
					id = spaceId
				},
				album = {
					id = albumId
				},
				userCreated = userCreatedDate,
				userUpdated = userUpdatedDate,
			}
		
	local overrides = {
			albumId = albumId,
			spaceAlbumId = spaceAlbumId,
			spaceId = spaceId,
			userCreatedDate = userCreatedDate,
			userUpdatedDate = userUpdatedDate,
		}
		
	local generatedSpaceAlbumDoc = WFCatSpaceTestUtils.createSpaceAlbumDocument( spaceAlbumId, overrides )
	rxTest:expectEqual(spaceAlbumDoc, generatedSpaceAlbumDoc)
	
end

--------------------------------------------------------------------------------

function WFCatSpaceTestUtilsTest.rxTestCreateSpaceDocument( rxTest )

	local spaceDocId = KSIdGenerator.uuidInLowercaseHex()
	
	local spaceDoc = {
			_id = spaceDocId,
			type = 'space',
			comments_disabled = true,
			favorites_disabled = true,
			subtype = 'gallery',
			download = true,
			private = true,
			location = true,
			metadata = true,
		}
		
	local overrides = {
			commentsDisabledStatus = true,
			docSubtype = 'gallery',
			downloadStatus = true,
			favoritesDisabledStatus = true,
			locationStatus = true,
			metadataStatus = true,
			privateStatus = true,
		}
		
	local generatedSpaceDoc = WFCatSpaceTestUtils.createSpaceDocument( spaceDocId, overrides )
	rxTest:expectEqual(spaceDoc, generatedSpaceDoc)
	
end

--------------------------------------------------------------------------------

return WFRxTestCase.wrapSuite( 'WFCatSpaceTestUtilsTest', WFCatSpaceTestUtilsTest )
