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

LrClassicRootModelTest.lua

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

ADOBE CONFIDENTIAL
------------------
Copyright 2020 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.

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

	-- Rx
local Rx = require "Rx"

	-- com.adobe.wichitafoundation.core.utils
local WFPlatformInfo = require 'WFPlatformInfo'
local WFRxTestCase = require 'WFRxTestCase'

local WFCatIdUtils = require 'WFCatIdUtils'

-- This model test is only valid on the Desktop platforms.

if not WFPlatformInfo.isDesktop then
	return {}
end

	-- WF.oz_client.managed_catalog
local WFCatAlbumsTestFactory = require 'WFCatAlbumsTestFactory'
local WFCatAssetTestFactory = require 'WFCatAssetTestFactory'
local WFCatCollaborationActivity_ClassicTestFactory = require 'WFCatCollaborationActivity_ClassicTestFactory'
local WFCatEditDefaultsTestFactory = require 'WFCatEditDefaultsTestFactory'
local WFCatOzMaintenanceTracker = require 'WFCatOzMaintenanceTracker'
local WFCatOzMaintenanceTrackerTestFactory = require 'WFCatOzMaintenanceTrackerTestFactory'
local WFCatPhotoImportanceTestFactory = require 'WFCatPhotoImportanceTestFactory'
local WFCatStacksTestFactory = require 'WFCatStacksTestFactory'
local WFCatVersionsTestFactory = require 'WFCatVersionsTestFactory'


local LrClassicRootModel = require 'LrClassicRootModel'

--============================================================================--

local function createParentModelForTest( rxTest, wfCatalog )
	
	local MockSynchronizerMethods = {}

	function MockSynchronizerMethods:getOzMaintenanceNotificationStream()
		
		local optArgs = {
			httpErrorStream = wfCatalog:ozCatalogSpec():watchHttpErrors()
		}
		
		local stream = WFCatOzMaintenanceTracker.getOzMaintenanceNotificationStream( wfCatalog, optArgs )

		rxTest:finally( function()
		
			if stream then
				stream:dispose()
			end
		
		end )

		return stream

	end

	local MockSynchronizer = Rx.Class( 'WFCatSynchronizer', MockSynchronizerMethods )

	local wfCatSynchronizer = MockSynchronizer()

	local wfCatalogStream = Rx.Observable.just( wfCatalog, nil, nil, wfCatSynchronizer )

	return LrClassicRootModel.makeModel( wfCatalogStream, Rx.Observable.just( false ) )
	
end

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

local submodelsByImplementation = {

	defaultParentModelConstructorFn = createParentModelForTest,

	[ 'WFCatOzMaintenanceTracker' ] = {
	
		[ 'getOzMaintenanceNotificationStream' ] = {
		
			submodelNamespace = 'LrClassicRootModel',
			submodelName = 'getOzMaintenanceNotificationStream',
			
		}
		
	},
	
	[ 'WFCatPhotoImportance' ] = {
	
		[ 'increaseUploadPriorityForAsset' ] = {
		
			submodelNamespace = 'LrClassicRootModel',
			submodelName = 'flagUploadAsHighPriority',
			
		}
		
	},
	
	[ 'WFCatPhotoImportance' ] = {
	
		[ 'removeUploadPriorityModifier' ] = {
		
			submodelNamespace = 'LrClassicRootModel',
			submodelName = 'removeHighPriorityUploadFlag',
			
		}
		
	},
	
	[ 'WFCatAlbums' ] = {
	
		[ 'getAlbumListForAssetIds' ] = {
		
			submodelNamespace = 'LrClassicRootModel',
			submodelName = 'getAlbumListForImages',
			
		}
	},
	
	[ 'WFCatStacks' ] = {
	
		[ 'deleteStack' ] = {
		
			submodelNamespace = 'LrClassicRootModel',
			submodelName = 'ungroupStack',
			
		}
	},
	
	[ 'WFCatStacks' ] = {
	
		[ 'setCover' ] = {
		
			submodelNamespace = 'LrClassicRootModel',
			submodelName = 'setStackLeader',
			
		}
	}
	
}

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

local LrClassicRootModelTest = WFCatOzMaintenanceTrackerTestFactory( submodelsByImplementation, {} )
LrClassicRootModelTest = WFCatVersionsTestFactory( submodelsByImplementation, LrClassicRootModelTest )
LrClassicRootModelTest = WFCatAssetTestFactory( submodelsByImplementation, LrClassicRootModelTest )
LrClassicRootModelTest = WFCatEditDefaultsTestFactory( submodelsByImplementation, LrClassicRootModelTest )
LrClassicRootModelTest = WFCatPhotoImportanceTestFactory( submodelsByImplementation, LrClassicRootModelTest )
LrClassicRootModelTest = WFCatAlbumsTestFactory( submodelsByImplementation, LrClassicRootModelTest )
LrClassicRootModelTest = WFCatStacksTestFactory( submodelsByImplementation, LrClassicRootModelTest )
LrClassicRootModelTest = WFCatCollaborationActivity_ClassicTestFactory( submodelsByImplementation, LrClassicRootModelTest )

function LrClassicRootModelTest.setUp()

	WFCatIdUtils.debug_clearCaches()
	
end

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

return WFRxTestCase.wrapSuite( 'LrClassicRootModelTest', LrClassicRootModelTest )
