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

NmbRootModelTest.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 WFCatCollaborationActivityTestFactory = require 'WFCatCollaborationActivityTestFactory'
local WFCatEditDefaultsTestFactory = require 'WFCatEditDefaultsTestFactory'
local WFCatOzMaintenanceTracker = require 'WFCatOzMaintenanceTracker'
local WFCatOzMaintenanceTrackerTestFactory = require 'WFCatOzMaintenanceTrackerTestFactory'
local WFCatPhotoImportanceTestFactory = require 'WFCatPhotoImportanceTestFactory'
local WFCatStacksTestFactory = require 'WFCatStacksTestFactory'
local WFCatVersionsTestFactory = require 'WFCatVersionsTestFactory'

	-- Nmb
local NmbRootModel = require 'NmbRootModel'

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

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 NmbRootModel.makeModel( wfCatalogStream, Rx.Observable.just( false ) )
	
end

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

local submodelsByImplementation = {

	defaultParentModelConstructorFn = createParentModelForTest,

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

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

local NmbRootModelTest = WFCatOzMaintenanceTrackerTestFactory( submodelsByImplementation, {} )
NmbRootModelTest = WFCatVersionsTestFactory( submodelsByImplementation, NmbRootModelTest )
NmbRootModelTest = WFCatAssetTestFactory( submodelsByImplementation, NmbRootModelTest )
NmbRootModelTest = WFCatEditDefaultsTestFactory( submodelsByImplementation, NmbRootModelTest )
NmbRootModelTest = WFCatPhotoImportanceTestFactory( submodelsByImplementation, NmbRootModelTest )
NmbRootModelTest = WFCatAlbumsTestFactory( submodelsByImplementation, NmbRootModelTest )
NmbRootModelTest = WFCatStacksTestFactory( submodelsByImplementation, NmbRootModelTest )
NmbRootModelTest = WFCatCollaborationActivityTestFactory( submodelsByImplementation, NmbRootModelTest )

function NmbRootModelTest.setUp()

	WFCatIdUtils.debug_clearCaches()
	
end

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

return WFRxTestCase.wrapSuite( 'NmbRootModelTest', NmbRootModelTest )
