@isTest
public with sharing class ProRegisterHandlerTest {

	static testMethod void Test01() {
		System.Test.startTest();
		//ProRegisterHandler prh = new ProRegisterHandler();
		Product_Register__c PRC = new Product_Register__c();
		PRC.Name = '国械注进20183222249';
		PRC.MedPrdClass__c = '3';
		PRC.RegisterNoClass_New__c = '';
		PRC.RegisterNoClass_Old__c = '6822';
		PRC.PrdCompanyAddr__c = '名称:奥林巴斯医疗株式会社;住所:日本国东京都涩谷区幡之谷二丁目43番地2号;联系方式:0081-426-42-2667';
		PRC.ClinicalProductCode__c = 'YYYY';
		PRC.ValidTo__c = Date.today().addDays(22);
		PRC.ValidFrom__c = Date.today().addDays(-22);
		insert PRC;

		Product_Register__c PRC1 = new Product_Register__c();
		PRC1.Name = '国械注进20183222249';
		PRC1.MedPrdClass__c = '3';
		PRC1.RegisterNoClass_New__c = '';
		PRC1.RegisterNoClass_Old__c = '6822';
		PRC1.PrdCompanyAddr__c = '名称:奥林巴斯医疗株式会社;住所:日本国东京都涩谷区幡之谷二丁目43番地2号;联系方式:0081-426-42-2667';
		PRC1.ClinicalProductCode__c = 'tttttt';
		PRC1.ValidTo__c = Date.today().addDays(22);
		PRC1.ValidFrom__c = Date.today().addDays(-22);
		insert PRC1;


		Product2 product2 = new Product2();
		product2.Name = 'WD18100A';
		product2.registrationCode__c = 'XXXX';
		product2.clinical_product_code__c = 'zzzz';
		insert product2;

		Product2 pro = new Product2();
		pro.Name = 'A00507A:密封圈,  透明, 黑色';
		pro.clinical_product_code__c = 'yyyyy';
		insert pro;

		Product_Register_Link__c prl = new Product_Register_Link__c();
		prl.Product2__c = pro.ID;
		prl.Product_Register__c = PRC.ID;
		insert prl;
		Product_Register_Link__c prl2 = new Product_Register_Link__c();
		prl2.Product2__c = pro.ID;
		prl2.Product_Register__c = PRC1.ID;
		insert prl2;

		update PRC;

		System.Test.stopTest();
	}

	static testMethod void Test02() {
		System.Test.startTest();
		Product_Register__c PRC = new Product_Register__c();
		PRC.Name = '国械注进20183222249';
		PRC.MedPrdClass__c = '3';
		PRC.RegisterNoClass_New__c = '';
		PRC.RegisterNoClass_Old__c = '6822';
		PRC.PrdCompanyAddr__c = '名称:奥林巴斯医疗株式会社;住所:日本国东京都涩谷区幡之谷二丁目43番地2号;联系方式:0081-426-42-2667';
		//PRC.ValidTo__c = Date.today();
		PRC.ValidTo__c = Date.today().addDays(22);
		PRC.ValidFrom__c = Date.today().addDays(-22);
		insert PRC;


		Product2 product2 = new Product2();
		product2.Name = 'WD18100A';
		product2.clinical_product_code__c = 'zzzz';
		insert product2;

		Product2 pro = new Product2();
		pro.Name = 'A00507A:密封圈,  透明, 黑色';
		pro.clinical_product_code__c = 'zzzz';

		insert pro;

		Product_Register_Link__c prl = new Product_Register_Link__c();
		prl.Product2__c = pro.ID;
		prl.Product_Register__c = PRC.ID;
		insert prl;
		//ProRegisterHandler prh = new ProRegisterHandler();
		update PRC;

		System.Test.stopTest();
	}

	@isTest static void test_checkProduct2Level() {
        Product2 prd = new Product2();
        prd.Product_ECCode__c      = 'testSBG004';
        prd.ProductCode            = 'testSBG004';
        prd.Name                   = 'testSBG004';
        prd.IsActive               = true;
        prd.Level_Category__c      = '';
        prd.demoteer_Sap__c        = Date.today().addDays(-3);
        prd.Diedatvanink__c        = Date.today().addDays(-4);
        insert prd;

        Product_Register__c PRC = new Product_Register__c();
        PRC.Name                   = '国械注进20183222249';
        PRC.MedPrdClass__c         = '1';
        PRC.RegisterNoClass_New__c = '';
        PRC.RegisterNoClass_Old__c = '6822';
        PRC.PrdCompanyAddr__c      = '名称:奥林巴斯医疗株式会社;住所:日本国东京都涩谷区幡之谷二丁目43番地2号;联系方式:0081-426-42-2667';
        PRC.ClinicalProductCode__c = 'YYYY';
        PRC.ValidTo__c             = Date.today().addDays(22);
        PRC.ValidFrom__c           = Date.today().addDays(-22);
        PRC.Stelsedag__c           = Date.today();
        insert PRC;

        Product_Register__c PRC1 = new Product_Register__c();
        PRC1.Name                   = '国械注进20183222249';
        PRC1.MedPrdClass__c         = '2';
        PRC1.RegisterNoClass_New__c = '';
        PRC1.RegisterNoClass_Old__c = '6822';
        PRC1.PrdCompanyAddr__c      = '名称:奥林巴斯医疗株式会社;住所:日本国东京都涩谷区幡之谷二丁目43番地2号;联系方式:0081-426-42-2667';
        PRC1.ClinicalProductCode__c = 'YYYY';
        PRC1.ValidTo__c             = Date.today().addDays(22);
        PRC1.ValidFrom__c           = Date.today().addDays(-22);
        PRC1.Stelsedag__c           = Date.today().addDays(1);
        insert PRC1;                 

        Product_Register_Link__c prl = new Product_Register_Link__c();
        prl.Product2__c = prd.ID;
        prl.Product_Register__c = PRC.ID;
        insert prl;

        Product_Register_Link__c prl1 = new Product_Register_Link__c();
        prl1.Product2__c = prd.ID;
        prl1.Product_Register__c = PRC1.ID;
        insert prl1;

        PRC1.name = 'v国械注进20183222249';
        update PRC1;
    }

    @isTest static void test_checkProduct2Level1() {
        Product2 prd = new Product2();
        prd.Product_ECCode__c      = 'testSBG004';
        prd.ProductCode            = 'testSBG004';
        prd.Name                   = 'testSBG004';
        prd.IsActive               = true;
        prd.Level_Category__c      = '';
        prd.demoteer_Sap__c        = Date.today().addDays(-3);
        prd.Diedatvanink__c        = Date.today().addDays(-4);
        insert prd;

        Product_Register__c PRC = new Product_Register__c();
        PRC.Name                   = '国械注进20183222249';
        PRC.MedPrdClass__c         = '2';
        PRC.RegisterNoClass_New__c = '';
        PRC.RegisterNoClass_Old__c = '6822';
        PRC.PrdCompanyAddr__c = '名称:奥林巴斯医疗株式会社;住所:日本国东京都涩谷区幡之谷二丁目43番地2号;联系方式:0081-426-42-2667';
        PRC.ClinicalProductCode__c = 'YYYY';
        PRC.ValidTo__c             = Date.today().addDays(22);
        PRC.ValidFrom__c           = Date.today().addDays(-22);
        PRC.Stelsedag__c           = Date.today().addDays(1);
        insert PRC;

        Product_Register__c PRC1 = new Product_Register__c();
        PRC1.Name                   = '国械注进20183222249';
        PRC1.MedPrdClass__c         = '1';
        PRC1.RegisterNoClass_New__c = '';
        PRC1.RegisterNoClass_Old__c = '6822';
        PRC1.PrdCompanyAddr__c = '名称:奥林巴斯医疗株式会社;住所:日本国东京都涩谷区幡之谷二丁目43番地2号;联系方式:0081-426-42-2667';
        PRC1.ClinicalProductCode__c = 'YYYY';
        PRC1.ValidTo__c             = Date.today().addDays(22);
        PRC1.ValidFrom__c           = Date.today().addDays(-22);
        PRC1.Stelsedag__c           = Date.today();
        insert PRC1;

        Product_Register_Link__c prl = new Product_Register_Link__c();
        prl.Product2__c              = prd.ID;
        prl.Product_Register__c      = PRC.ID;
        insert prl;

        Product_Register_Link__c prl1 = new Product_Register_Link__c();
        prl1.Product2__c              = prd.ID;
        prl1.Product_Register__c      = PRC1.ID;
        insert prl1;

        PRC1.name = 'v国械注进20183222249';
        update PRC1;
    }

    @isTest static void test_checkProduct2Level2() {
        Product2 prd = new Product2();
        prd.Product_ECCode__c      = 'testSBG004';
        prd.ProductCode            = 'testSBG004';
        prd.Name                   = 'testSBG004';
        prd.IsActive               = true;
        prd.Level_Category__c      = '';
        prd.demoteer_Sap__c        = Date.today().addDays(-3);
        prd.Diedatvanink__c        = Date.today().addDays(-4);
        insert prd;

        Product_Register__c PRC = new Product_Register__c();
        PRC.Name                   = '国械注进20183222249';
        PRC.MedPrdClass__c         = '';
        PRC.RegisterNoClass_New__c = '';
        PRC.RegisterNoClass_Old__c = '6822';
        PRC.PrdCompanyAddr__c = '名称:奥林巴斯医疗株式会社;住所:日本国东京都涩谷区幡之谷二丁目43番地2号;联系方式:0081-426-42-2667';
        PRC.ClinicalProductCode__c = 'YYYY';
        PRC.ValidTo__c             = Date.today().addDays(22);
        PRC.ValidFrom__c           = Date.today().addDays(-22);
        PRC.Stelsedag__c           = Date.today();
        insert PRC;

        Product_Register__c PRC1 = new Product_Register__c();
        PRC1.Name                   = '国械注进20183222249';
        PRC1.MedPrdClass__c         = '';
        PRC1.RegisterNoClass_New__c = '';
        PRC1.RegisterNoClass_Old__c = '6822';
        PRC1.PrdCompanyAddr__c = '名称:奥林巴斯医疗株式会社;住所:日本国东京都涩谷区幡之谷二丁目43番地2号;联系方式:0081-426-42-2667';
        PRC1.ClinicalProductCode__c = 'YYYY';
        PRC1.ValidTo__c             = Date.today().addDays(22);
        PRC1.ValidFrom__c           = Date.today().addDays(-22);
        insert PRC1;

        Product_Register__c PRC2 = new Product_Register__c();
        PRC2.Name                   = '国械注进20183222249';
        PRC2.MedPrdClass__c         = '';
        PRC2.RegisterNoClass_New__c = '';
        PRC2.RegisterNoClass_Old__c = '6822';
        PRC2.PrdCompanyAddr__c = '名称:奥林巴斯医疗株式会社;住所:日本国东京都涩谷区幡之谷二丁目43番地2号;联系方式:0081-426-42-2667';
        PRC2.ClinicalProductCode__c = 'YYYY';
        PRC2.ValidTo__c             = Date.today().addDays(22);
        PRC2.ValidFrom__c           = Date.today().addDays(-22);
        PRC2.Stelsedag__c           = Date.today();
        insert PRC2;

        Product_Register_Link__c prl = new Product_Register_Link__c();
        prl.Product2__c              = prd.ID;
        prl.Product_Register__c      = PRC.ID;
        insert prl;

        Product_Register_Link__c prl1 = new Product_Register_Link__c();
        prl1.Product2__c              = prd.ID;
        prl1.Product_Register__c      = PRC1.ID;
        insert prl1;

        Product_Register_Link__c prl2 = new Product_Register_Link__c();
        prl2.Product2__c              = prd.ID;
        prl2.Product_Register__c      = PRC2.ID;
        insert prl2;

        PRC1.name = 'v国械注进20183222249';
        update PRC1;
    }

    @isTest static void test_checkProduct2Level3() {
        Product2 prd = new Product2();
        prd.Product_ECCode__c      = 'testSBG004';
        prd.ProductCode            = 'testSBG004';
        prd.Name                   = 'testSBG004';
        prd.IsActive               = true;
        prd.Level_Category__c      = '';
        prd.demoteer_Sap__c        = Date.today().addDays(-3);
        prd.Diedatvanink__c        = Date.today().addDays(5);
        insert prd;

        Product_Register__c PRC = new Product_Register__c();
        PRC.Name                   = '国械注进20183222249';
        PRC.MedPrdClass__c         = '1';
        PRC.RegisterNoClass_New__c = '';
        PRC.RegisterNoClass_Old__c = '6822';
        PRC.PrdCompanyAddr__c = '名称:奥林巴斯医疗株式会社;住所:日本国东京都涩谷区幡之谷二丁目43番地2号;联系方式:0081-426-42-2667';
        PRC.ClinicalProductCode__c = 'YYYY';
        PRC.ValidTo__c             = Date.today().addDays(22);
        PRC.ValidFrom__c           = Date.today().addDays(-22);
        PRC.Stelsedag__c           = Date.today().addDays(1);
        insert PRC;

        Product_Register__c PRC1 = new Product_Register__c();
        PRC1.Name                   = '国械注进20183222249';
        PRC1.MedPrdClass__c         = '2';
        PRC1.RegisterNoClass_New__c = '';
        PRC1.RegisterNoClass_Old__c = '6822';
        PRC1.PrdCompanyAddr__c = '名称:奥林巴斯医疗株式会社;住所:日本国东京都涩谷区幡之谷二丁目43番地2号;联系方式:0081-426-42-2667';
        PRC1.ClinicalProductCode__c = 'YYYY';
        PRC1.ValidTo__c             = Date.today().addDays(22);
        PRC1.ValidFrom__c           = Date.today().addDays(-22);
        PRC1.Stelsedag__c           = Date.today();
        insert PRC1;
        
        Product_Register_Link__c prl = new Product_Register_Link__c();
        prl.Product2__c              = prd.ID;
        prl.Product_Register__c      = PRC.ID;
        insert prl;

        Product_Register_Link__c prl1 = new Product_Register_Link__c();
        prl1.Product2__c              = prd.ID;
        prl1.Product_Register__c      = PRC1.ID;
        insert prl1;

        PRC1.name = 'v国械注进20183222249';
        update PRC1;
    }

    @isTest static void test_checkProduct2Level4() {
        Product2 prd = new Product2();
        prd.Product_ECCode__c      = 'testSBG004';
        prd.ProductCode            = 'testSBG004';
        prd.Name                   = 'testSBG004';
        prd.IsActive               = true;
        prd.Level_Category__c      = '';
        prd.demoteer_Sap__c        = Date.today().addDays(-3);
        prd.Diedatvanink__c        = Date.today().addDays(5);
        insert prd;

        Product_Register__c PRC = new Product_Register__c();
        PRC.Name                   = '国械注进20183222249';
        PRC.MedPrdClass__c         = '2';
        PRC.RegisterNoClass_New__c = '';
        PRC.RegisterNoClass_Old__c = '6822';
        PRC.PrdCompanyAddr__c = '名称:奥林巴斯医疗株式会社;住所:日本国东京都涩谷区幡之谷二丁目43番地2号;联系方式:0081-426-42-2667';
        PRC.ClinicalProductCode__c = 'YYYY';
        PRC.ValidTo__c             = Date.today().addDays(22);
        PRC.ValidFrom__c           = Date.today().addDays(-22);
        PRC.Stelsedag__c           = Date.today().addDays(1);
        insert PRC;

        Product_Register__c PRC1 = new Product_Register__c();
        PRC1.Name                   = '国械注进20183222249';
        PRC1.MedPrdClass__c         = '1';
        PRC1.RegisterNoClass_New__c = '';
        PRC1.RegisterNoClass_Old__c = '6822';
        PRC1.PrdCompanyAddr__c = '名称:奥林巴斯医疗株式会社;住所:日本国东京都涩谷区幡之谷二丁目43番地2号;联系方式:0081-426-42-2667';
        PRC1.ClinicalProductCode__c = 'YYYY';
        PRC1.ValidTo__c             = Date.today().addDays(22);
        PRC1.ValidFrom__c           = Date.today().addDays(-22);
        PRC1.Stelsedag__c           = Date.today();
        insert PRC1;

        Product_Register_Link__c prl = new Product_Register_Link__c();
        prl.Product2__c              = prd.ID;
        prl.Product_Register__c      = PRC.ID;
        insert prl;

        Product_Register_Link__c prl1 = new Product_Register_Link__c();
        prl1.Product2__c              = prd.ID;
        prl1.Product_Register__c      = PRC1.ID;
        insert prl1;

        PRC1.name = 'v国械注进20183222249';
        update PRC1;
    }

    @isTest static void test_checkProduct2Level5() {
        Product2 prd = new Product2();
        prd.Product_ECCode__c      = 'testSBG004';
        prd.ProductCode            = 'testSBG004';
        prd.Name                   = 'testSBG004';
        prd.IsActive               = true;
        prd.Level_Category__c      = '';
        prd.demoteer_Sap__c        = Date.today().addDays(-3);
        prd.Diedatvanink__c        = Date.today().addDays(5);
        insert prd;

        Product_Register__c PRC = new Product_Register__c();
        PRC.Name                   = '国械注进20183222249';
        PRC.MedPrdClass__c         = '';
        PRC.RegisterNoClass_New__c = '';
        PRC.RegisterNoClass_Old__c = '6822';
        PRC.PrdCompanyAddr__c = '名称:奥林巴斯医疗株式会社;住所:日本国东京都涩谷区幡之谷二丁目43番地2号;联系方式:0081-426-42-2667';
        PRC.ClinicalProductCode__c = 'YYYY';
        PRC.ValidTo__c             = Date.today().addDays(22);
        PRC.ValidFrom__c           = Date.today().addDays(-22);
        PRC.Stelsedag__c           = Date.today().addDays(1);
        insert PRC;

        Product_Register__c PRC1 = new Product_Register__c();
        PRC1.Name                   = '国械注进20183222249';
        PRC1.MedPrdClass__c         = '';
        PRC1.RegisterNoClass_New__c = '';
        PRC1.RegisterNoClass_Old__c = '6822';
        PRC1.PrdCompanyAddr__c = '名称:奥林巴斯医疗株式会社;住所:日本国东京都涩谷区幡之谷二丁目43番地2号;联系方式:0081-426-42-2667';
        PRC1.ClinicalProductCode__c = 'YYYY';
        PRC1.ValidTo__c             = Date.today().addDays(22);
        PRC1.ValidFrom__c           = Date.today().addDays(-22);
        insert PRC1;

        Product_Register__c PRC2 = new Product_Register__c();
        PRC2.Name                   = '国械注进20183222249';
        PRC2.MedPrdClass__c         = '';
        PRC2.RegisterNoClass_New__c = '';
        PRC2.RegisterNoClass_Old__c = '6822';
        PRC2.PrdCompanyAddr__c = '名称:奥林巴斯医疗株式会社;住所:日本国东京都涩谷区幡之谷二丁目43番地2号;联系方式:0081-426-42-2667';
        PRC2.ClinicalProductCode__c = 'YYYY';
        PRC2.ValidTo__c             = Date.today().addDays(22);
        PRC2.ValidFrom__c           = Date.today().addDays(-22);
        PRC2.Stelsedag__c           = Date.today();
        insert PRC2;

        Product_Register_Link__c prl = new Product_Register_Link__c();
        prl.Product2__c              = prd.ID;
        prl.Product_Register__c      = PRC.ID;
        insert prl;

        Product_Register_Link__c prl1 = new Product_Register_Link__c();
        prl1.Product2__c              = prd.ID;
        prl1.Product_Register__c      = PRC1.ID;
        insert prl1;

        Product_Register_Link__c prl2 = new Product_Register_Link__c();
        prl2.Product2__c              = prd.ID;
        prl2.Product_Register__c      = PRC2.ID;
        insert prl2;

        PRC1.name = 'v国械注进20183222249';
        update PRC1;
    }
}