/** * This class contains unit tests for validating the behavior of Apex classes * and triggers. * * Unit tests are class methods that verify whether a particular piece * of code is working properly. Unit test methods take no arguments, * commit no data to the database, and are flagged with the testMethod * keyword in the method definition. * * All test methods in an organization are executed whenever Apex code is deployed * to a production organization to confirm correctness, ensure code * coverage, and prevent regressions. All Apex classes are * required to have at least 75% code coverage in order to be deployed * to a production organization. In addition, all triggers must have some code coverage. * * The @isTest class annotation indicates this class only contains test * methods. Classes defined with the @isTest annotation do not count against * the organization size limit for all Apex scripts. * * See the Apex Language Reference for more information about Testing and Code Coverage. */ @isTest private class OpportunityPCLController2Test { static testMethod void myUnitTest() { ControllerUtil.EscapeNFM001Trigger = true; RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp']; List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc]; // Profile p = [select Id from Profile where id =:System.Label.ProfileId_2S6]; // // ユーザー作成 // User hpOwner = new User(SAP_Send_OFF__c = true,Batch_User__c = true,Quote_Correct__c=true,Quote_Special_Operation__c=true, Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); // insert hpOwner; Account acc = new Account(); acc.RecordTypeId = rectCo.Id; acc.Name = 'HP test1'; insert acc; List dept = [select Id, Name from Account where ParentId = :acc.Id and Department_Class_Label__c IN ('消化科', '呼吸科') order by Department_Class_Label__c]; Account depart1 = new Account(); depart1.RecordTypeId = rectDpt[0].Id; depart1.Name = '*'; depart1.Department_Name__c = 'Gastoro Intestin Test'; depart1.ParentId = dept[0].Id; depart1.Department_Class__c = dept[0].Id; depart1.Hospital__c = acc.Id; Account depart2 = new Account(); depart2.RecordTypeId = rectDpt[1].Id; depart2.Name = '*'; depart2.Department_Name__c = '診療科2'; depart2.ParentId = dept[1].Id; depart2.Department_Class__c = dept[1].Id; depart2.Hospital__c = acc.Id; insert new Account[] {depart1, depart2}; RecordType oppVND = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity']; Opportunity opp1 = new Opportunity( Name = 'test opp1', StageName = '引合', CurrencyIsoCode = 'USD', CloseDate = Date.today(), AccountId = depart1.Id, RecordTypeId = oppVND.Id, Closing_Bid_Date__c = Date.today().addDays(-5), Hospital__c = acc.Id, Competitor__c = 'A' ); Opportunity opp2 = new Opportunity( Name = 'test opp2', StageName = '引合', CurrencyIsoCode = 'USD', CloseDate = Date.today(), AccountId = depart2.Id, RecordTypeId = oppVND.Id, Closing_Bid_Date__c = Date.today().addDays(-5), Hospital__c = acc.Id, Competitor__c = 'B' ); System.Test.startTest(); insert new Opportunity[] {opp1, opp2}; PageReference page = new PageReference('/apex/AssetModifyBelongs?hpid='+acc.Id); page.setRedirect(true); System.Test.setCurrentPage(page); OpportunityPCLController2 pcl = new OpportunityPCLController2(); pcl.init(); pcl.cancel(); System.assertEquals(2, pcl.oppRecords.size()); pcl.dateField = 'Closing_Bid_Date__c'; pcl.con1.Birthdate = Date.today().addDays(-7); pcl.con2.Birthdate = Date.today().addDays(-3); pcl.limits = '50'; pcl.text3 = 'S:Competitor__c'; pcl.condition2 = 'notequals'; pcl.condition3 = 'equals'; pcl.value3 = 'A,b,c,b v'; // pcl.OpptyWait=true; pcl.searchOpp(); //System.assertEquals(1, pcl.oppRecords.size()); //System.assertEquals(depart1.Id, pcl.oppRecords[0].rec.AccountId); pcl.text3 = ''; pcl.searchOpp(); pcl.sortKey = '2'; pcl.sortTable(); System.assertEquals(2, pcl.oppRecords.size()); //System.assertEquals('B', pcl.oppRecords[1].rec.Competitor__c); pcl.oppRecords[1].rec.Competitor__c = 'A1'; // ソートの確認 pcl.saveType = '2'; // pcl.OpptyWait=true; pcl.save(); System.Test.stopTest(); //System.assertEquals(depart2.Id, pcl.oppRecords[0].rec.AccountId); } static testMethod void myUnitTest2() { RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp']; List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc]; Profile p = [select Id from Profile where id =:System.Label.ProfileId_2S6]; // ユーザー作成 User hpOwner = new User(SAP_Send_OFF__c = true,Batch_User__c = true,Quote_Correct__c=true,Quote_Special_Operation__c=true, Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); insert hpOwner; system.runAs(hpOwner){ Account acc = new Account(); acc.RecordTypeId = rectCo.Id; acc.Name = 'HP test1'; acc.OCM_Category__c = 'L'; insert acc; List dept = [select Id, Name from Account where ParentId = :acc.Id and Department_Class_Label__c IN ('消化科', '呼吸科') order by Department_Class_Label__c]; Account depart1 = new Account(); depart1.RecordTypeId = rectDpt[0].Id; depart1.Name = '*'; depart1.Department_Name__c = 'Gastoro Intestin Test'; depart1.ParentId = dept[0].Id; depart1.Department_Class__c = dept[0].Id; depart1.Hospital__c = acc.Id; Account depart2 = new Account(); depart2.RecordTypeId = rectDpt[1].Id; depart2.Name = '*'; depart2.Department_Name__c = '診療科2'; depart2.ParentId = dept[1].Id; depart2.Department_Class__c = dept[1].Id; depart2.Hospital__c = acc.Id; insert new Account[] {depart1, depart2}; RecordType oppVND = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity']; Opportunity opp1 = new Opportunity( Name = 'test opp1', StageName = '引合', CurrencyIsoCode = 'USD', CloseDate = Date.today(), AccountId = depart1.Id, RecordTypeId = oppVND.Id, Closing_Bid_Date__c = Date.today().addDays(-5), Hospital__c = acc.Id, Sales_Root__c = 'OCM直接販売', Competitor__c = 'A' ); Opportunity opp2 = new Opportunity( Name = 'test opp2', StageName = '引合', CurrencyIsoCode = 'USD', CloseDate = Date.today(), AccountId = depart2.Id, RecordTypeId = oppVND.Id, Closing_Bid_Date__c = Date.today().addDays(-5), Hospital__c = acc.Id, Sales_Root__c = 'OCM直接販売', Competitor__c = 'B' ); insert new Opportunity[] {opp1, opp2}; Statu_Achievements__c sta1 = new Statu_Achievements__c(); sta1.Statu_Achievements_Ext__c = 'opp1:SoNo1'; sta1.Name = 'SoNo1'; sta1.Opportunity__c = opp1.Id; sta1.ReturnFlag__c = false; sta1.OverviewStatus__c = 'OverviewStatus__c'; sta1.ContractNO__c = 'ContractNO1'; sta1.ContractReceivedDate__c = null; sta1.FirstApproveDate__c = null; sta1.LastApproveDate__c = null; sta1.SoLatestDeliveryDate__c = null; sta1.DeliveryDate__c = null; sta1.InstallDate__c = null; sta1.Collection_Day_Invoice__c = System.today(); sta1.CurrencyIsoCode = opp1.CurrencyIsoCode; sta1.ContractAmount__c = 0; sta1.PaymentAmount__c = 0; sta1.PaymentRate__c = '0'; sta1.DeliveryStatus__c = 'DeliveryStatus__c'; sta1.AssignmentStatus__c = 'AssignmentStatus__c'; sta1.PaymentStatus__c = 'PaymentStatus__c'; sta1.InstallStatus__c = 'InstallStatus__c'; sta1.AuthorizationNo__c = 'AuthorizationNo__c'; sta1.ContractApplicationNo__c = 'ContractApplicationNo__c'; sta1.PaymentTerms__c = 'PaymentTerms__c'; sta1.UnshippedAmount__c = 582.01; sta1.SalesChannel__c = 'SalesChannel__c'; sta1.SoLatestDeliveryDate__c = Date.today().addDays(5); Statu_Achievements__c sta2 = new Statu_Achievements__c(); sta2.Statu_Achievements_Ext__c = 'opp2:SoNo2'; sta2.Name = 'SoNo2'; sta2.Opportunity__c = opp2.Id; sta2.ReturnFlag__c = false; sta2.OverviewStatus__c = 'OverviewStatus__c'; sta2.ContractNO__c = 'ContractNO2'; sta2.ContractReceivedDate__c = null; sta2.FirstApproveDate__c = null; sta2.LastApproveDate__c = null; sta2.SoLatestDeliveryDate__c = null; sta2.DeliveryDate__c = null; sta2.InstallDate__c = null; sta2.Collection_Day_Invoice__c = System.today(); sta2.CurrencyIsoCode = opp2.CurrencyIsoCode; sta2.ContractAmount__c = 0; sta2.PaymentAmount__c = 0; sta2.PaymentRate__c = '0'; sta2.DeliveryStatus__c = 'DeliveryStatus__c'; sta2.AssignmentStatus__c = 'AssignmentStatus__c'; sta2.PaymentStatus__c = 'PaymentStatus__c'; sta2.InstallStatus__c = 'InstallStatus__c'; sta2.AuthorizationNo__c = 'AuthorizationNo__c'; sta2.ContractApplicationNo__c = 'ContractApplicationNo__c'; sta2.PaymentTerms__c = 'PaymentTerms__c'; sta2.UnshippedAmount__c = 0; sta2.SalesChannel__c = 'SalesChannel__c'; sta2.SoLatestDeliveryDate__c = Date.today().addDays(5); insert new Statu_Achievements__c[] {sta1, sta2}; PageReference page = new PageReference('/apex/AssetModifyBelongs?uid=' +hpOwner.Id+'&hpid='+acc.Id); page.setRedirect(true); System.Test.setCurrentPage(page); OpportunityPCLController2 pcl = new OpportunityPCLController2(); pcl.init(); pcl.cancel(); System.assertEquals(2, pcl.oppRecords.size()); pcl.dateField = 'Closing_Bid_Date__c'; pcl.con1.Birthdate = Date.today().addDays(-7); pcl.con2.Birthdate = Date.today().addDays(-3); pcl.limits = '50'; pcl.text3 = 'S:Competitor__c'; pcl.condition3 = 'contains'; pcl.condition2 = 'notcontains'; pcl.value3 = 'A b v,,'; pcl.OpptyWait=true; pcl.searchOpp(); //System.assertEquals(1, pcl.oppRecords.size()); //System.assertEquals(depart1.Id, pcl.oppRecords[0].rec.AccountId); pcl.text3 = ''; pcl.searchOpp(); pcl.sortKey = '2'; pcl.sortTable(); // System.assertEquals(2, pcl.oppRecords.size()); //System.assertEquals('B', pcl.oppRecords[1].rec.Competitor__c); // pcl.oppRecords[1].rec.Competitor__c = 'A1'; // ソートの確認 // pcl.saveType = '2'; // pcl.OpptyWait=true; // pcl.save(); // System.Test.stopTest(); //System.assertEquals(depart2.Id, pcl.oppRecords[0].rec.AccountId); } } static testMethod void myUnitTest3() { RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp']; List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc]; Profile p = [select Id from Profile where id =:System.Label.ProfileId_2S6]; // ユーザー作成 User hpOwner = new User(SAP_Send_OFF__c = true,Batch_User__c = true,Quote_Correct__c=true,Quote_Special_Operation__c=true, Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); insert hpOwner; system.runAs(hpOwner){ Account acc = new Account(); acc.RecordTypeId = rectCo.Id; acc.Name = 'HP test1'; acc.OCM_Category__c = 'L'; insert acc; List dept = [select Id, Name from Account where ParentId = :acc.Id and Department_Class_Label__c IN ('消化科', '呼吸科') order by Department_Class_Label__c]; Account depart1 = new Account(); depart1.RecordTypeId = rectDpt[0].Id; depart1.Name = '*'; depart1.Department_Name__c = 'Gastoro Intestin Test'; depart1.ParentId = dept[0].Id; depart1.Department_Class__c = dept[0].Id; depart1.Hospital__c = acc.Id; Account depart2 = new Account(); depart2.RecordTypeId = rectDpt[1].Id; depart2.Name = '*'; depart2.Department_Name__c = '診療科2'; depart2.ParentId = dept[1].Id; depart2.Department_Class__c = dept[1].Id; depart2.Hospital__c = acc.Id; insert new Account[] {depart1, depart2}; RecordType oppVND = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity']; Opportunity opp1 = new Opportunity( Name = 'test opp1', StageName = '引合', CurrencyIsoCode = 'USD', CloseDate = Date.today(), AccountId = depart1.Id, RecordTypeId = oppVND.Id, Closing_Bid_Date__c = Date.today().addDays(-5), Hospital__c = acc.Id, Sales_Root__c = 'OCM直接販売', Competitor__c = 'A' ); Opportunity opp2 = new Opportunity( Name = 'test opp2', StageName = '引合', CurrencyIsoCode = 'USD', CloseDate = Date.today(), AccountId = depart2.Id, RecordTypeId = oppVND.Id, Closing_Bid_Date__c = Date.today().addDays(-5), Hospital__c = acc.Id, Sales_Root__c = 'OCM直接販売', Competitor__c = 'B' ); insert new Opportunity[] {opp1, opp2}; Statu_Achievements__c sta1 = new Statu_Achievements__c(); sta1.Statu_Achievements_Ext__c = 'opp1:SoNo1'; sta1.Name = 'SoNo1'; sta1.Opportunity__c = opp1.Id; sta1.ReturnFlag__c = false; sta1.OverviewStatus__c = 'OverviewStatus__c'; sta1.ContractNO__c = 'ContractNO1'; sta1.ContractReceivedDate__c = null; sta1.FirstApproveDate__c = null; sta1.LastApproveDate__c = null; sta1.SoLatestDeliveryDate__c = null; sta1.DeliveryDate__c = null; sta1.InstallDate__c = null; sta1.Collection_Day_Invoice__c = System.today(); sta1.CurrencyIsoCode = opp1.CurrencyIsoCode; sta1.ContractAmount__c = 0; sta1.PaymentAmount__c = 0; sta1.PaymentRate__c = '0'; sta1.DeliveryStatus__c = 'DeliveryStatus__c'; sta1.AssignmentStatus__c = 'AssignmentStatus__c'; sta1.PaymentStatus__c = 'PaymentStatus__c'; sta1.InstallStatus__c = 'InstallStatus__c'; sta1.AuthorizationNo__c = 'AuthorizationNo__c'; sta1.ContractApplicationNo__c = 'ContractApplicationNo__c'; sta1.PaymentTerms__c = 'PaymentTerms__c'; sta1.UnshippedAmount__c = 582.01; sta1.SalesChannel__c = 'SalesChannel__c'; sta1.SoLatestDeliveryDate__c = Date.today().addDays(5); Statu_Achievements__c sta2 = new Statu_Achievements__c(); sta2.Statu_Achievements_Ext__c = 'opp2:SoNo2'; sta2.Name = 'SoNo2'; sta2.Opportunity__c = opp2.Id; sta2.ReturnFlag__c = false; sta2.OverviewStatus__c = 'OverviewStatus__c'; sta2.ContractNO__c = 'ContractNO2'; sta2.ContractReceivedDate__c = null; sta2.FirstApproveDate__c = null; sta2.LastApproveDate__c = null; sta2.SoLatestDeliveryDate__c = null; sta2.DeliveryDate__c = null; sta2.InstallDate__c = null; sta2.Collection_Day_Invoice__c = System.today(); sta2.CurrencyIsoCode = opp2.CurrencyIsoCode; sta2.ContractAmount__c = 0; sta2.PaymentAmount__c = 0; sta2.PaymentRate__c = '0'; sta2.DeliveryStatus__c = 'DeliveryStatus__c'; sta2.AssignmentStatus__c = 'AssignmentStatus__c'; sta2.PaymentStatus__c = 'PaymentStatus__c'; sta2.InstallStatus__c = 'InstallStatus__c'; sta2.AuthorizationNo__c = 'AuthorizationNo__c'; sta2.ContractApplicationNo__c = 'ContractApplicationNo__c'; sta2.PaymentTerms__c = 'PaymentTerms__c'; sta2.UnshippedAmount__c = 0; sta2.SalesChannel__c = 'SalesChannel__c'; sta2.SoLatestDeliveryDate__c = Date.today().addDays(5); insert new Statu_Achievements__c[] {sta1, sta2}; PageReference page = new PageReference('/apex/AssetModifyBelongs?uid=' +hpOwner.Id+'&hpid='+acc.Id); page.setRedirect(true); System.Test.setCurrentPage(page); OpportunityPCLController2 pcl = new OpportunityPCLController2(); pcl.init(); pcl.cancel(); System.assertEquals(2, pcl.oppRecords.size()); pcl.dateField = 'Closing_Bid_Date__c'; pcl.con1.Birthdate = Date.today().addDays(-7); pcl.con2.Birthdate = Date.today().addDays(-3); pcl.limits = '50'; pcl.text3 = 'S:Competitor__c'; pcl.condition2 = 'notcontains'; pcl.condition3 = 'contains'; pcl.value3 = ''; pcl.OpptyWait=true; pcl.searchOpp(); //System.assertEquals(1, pcl.oppRecords.size()); //System.assertEquals(depart1.Id, pcl.oppRecords[0].rec.AccountId); pcl.text3 = ''; pcl.searchOpp(); pcl.sortKey = '2'; pcl.sortTable(); // System.assertEquals(2, pcl.oppRecords.size()); //System.assertEquals('B', pcl.oppRecords[1].rec.Competitor__c); // pcl.oppRecords[1].rec.Competitor__c = 'A1'; // ソートの確認 // pcl.saveType = '2'; // pcl.OpptyWait=true; // pcl.save(); // System.Test.stopTest(); //System.assertEquals(depart2.Id, pcl.oppRecords[0].rec.AccountId); } } static testMethod void myUnitTest4() { RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp']; List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc]; Profile p = [select Id from Profile where id =:System.Label.ProfileId_2S6]; // ユーザー作成 User hpOwner = new User(SAP_Send_OFF__c = true,Batch_User__c = true,Quote_Correct__c=true,Quote_Special_Operation__c=true, Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); insert hpOwner; system.runAs(hpOwner){ Account acc = new Account(); acc.RecordTypeId = rectCo.Id; acc.Name = 'HP test1'; acc.OCM_Category__c = 'L'; insert acc; List dept = [select Id, Name from Account where ParentId = :acc.Id and Department_Class_Label__c IN ('消化科', '呼吸科') order by Department_Class_Label__c]; Account depart1 = new Account(); depart1.RecordTypeId = rectDpt[0].Id; depart1.Name = '*'; depart1.Department_Name__c = 'Gastoro Intestin Test'; depart1.ParentId = dept[0].Id; depart1.Department_Class__c = dept[0].Id; depart1.Hospital__c = acc.Id; Account depart2 = new Account(); depart2.RecordTypeId = rectDpt[1].Id; depart2.Name = '*'; depart2.Department_Name__c = '診療科2'; depart2.ParentId = dept[1].Id; depart2.Department_Class__c = dept[1].Id; depart2.Hospital__c = acc.Id; insert new Account[] {depart1, depart2}; RecordType oppVND = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity']; Opportunity opp1 = new Opportunity( Name = 'test opp1', StageName = '引合', CurrencyIsoCode = 'USD', CloseDate = Date.today(), AccountId = depart1.Id, RecordTypeId = oppVND.Id, Closing_Bid_Date__c = Date.today().addDays(-5), Hospital__c = acc.Id, Sales_Root__c = 'OCM直接販売', Competitor__c = 'A' ); Opportunity opp2 = new Opportunity( Name = 'test opp2', StageName = '引合', CurrencyIsoCode = 'USD', CloseDate = Date.today(), AccountId = depart2.Id, RecordTypeId = oppVND.Id, Closing_Bid_Date__c = Date.today().addDays(-5), Hospital__c = acc.Id, Sales_Root__c = 'OCM直接販売', Competitor__c = 'B' ); insert new Opportunity[] {opp1, opp2}; Statu_Achievements__c sta1 = new Statu_Achievements__c(); sta1.Statu_Achievements_Ext__c = 'opp1:SoNo1'; sta1.Name = 'SoNo1'; sta1.Opportunity__c = opp1.Id; sta1.ReturnFlag__c = false; sta1.OverviewStatus__c = 'OverviewStatus__c'; sta1.ContractNO__c = 'ContractNO1'; sta1.ContractReceivedDate__c = null; sta1.FirstApproveDate__c = null; sta1.LastApproveDate__c = null; sta1.SoLatestDeliveryDate__c = null; sta1.DeliveryDate__c = null; sta1.InstallDate__c = null; sta1.Collection_Day_Invoice__c = System.today(); sta1.CurrencyIsoCode = opp1.CurrencyIsoCode; sta1.ContractAmount__c = 0; sta1.PaymentAmount__c = 0; sta1.PaymentRate__c = '0'; sta1.DeliveryStatus__c = 'DeliveryStatus__c'; sta1.AssignmentStatus__c = 'AssignmentStatus__c'; sta1.PaymentStatus__c = 'PaymentStatus__c'; sta1.InstallStatus__c = 'InstallStatus__c'; sta1.AuthorizationNo__c = 'AuthorizationNo__c'; sta1.ContractApplicationNo__c = 'ContractApplicationNo__c'; sta1.PaymentTerms__c = 'PaymentTerms__c'; sta1.UnshippedAmount__c = 582.01; sta1.SalesChannel__c = 'SalesChannel__c'; sta1.SoLatestDeliveryDate__c = Date.today().addDays(5); Statu_Achievements__c sta2 = new Statu_Achievements__c(); sta2.Statu_Achievements_Ext__c = 'opp2:SoNo2'; sta2.Name = 'SoNo2'; sta2.Opportunity__c = opp2.Id; sta2.ReturnFlag__c = false; sta2.OverviewStatus__c = 'OverviewStatus__c'; sta2.ContractNO__c = 'ContractNO2'; sta2.ContractReceivedDate__c = null; sta2.FirstApproveDate__c = null; sta2.LastApproveDate__c = null; sta2.SoLatestDeliveryDate__c = null; sta2.DeliveryDate__c = null; sta2.InstallDate__c = null; sta2.Collection_Day_Invoice__c = System.today(); sta2.CurrencyIsoCode = opp2.CurrencyIsoCode; sta2.ContractAmount__c = 0; sta2.PaymentAmount__c = 0; sta2.PaymentRate__c = '0'; sta2.DeliveryStatus__c = 'DeliveryStatus__c'; sta2.AssignmentStatus__c = 'AssignmentStatus__c'; sta2.PaymentStatus__c = 'PaymentStatus__c'; sta2.InstallStatus__c = 'InstallStatus__c'; sta2.AuthorizationNo__c = 'AuthorizationNo__c'; sta2.ContractApplicationNo__c = 'ContractApplicationNo__c'; sta2.PaymentTerms__c = 'PaymentTerms__c'; sta2.UnshippedAmount__c = 0; sta2.SalesChannel__c = 'SalesChannel__c'; sta2.SoLatestDeliveryDate__c = Date.today().addDays(5); insert new Statu_Achievements__c[] {sta1, sta2}; PageReference page = new PageReference('/apex/AssetModifyBelongs?uid=' +hpOwner.Id+'&hpid='+acc.Id); page.setRedirect(true); System.Test.setCurrentPage(page); OpportunityPCLController2 pcl = new OpportunityPCLController2(); pcl.init(); pcl.cancel(); System.assertEquals(2, pcl.oppRecords.size()); pcl.dateField = 'Closing_Bid_Date__c'; pcl.con1.Birthdate = Date.today().addDays(-7); pcl.con2.Birthdate = Date.today().addDays(-3); pcl.limits = '50'; pcl.text3 = 'S:Competitor__c'; pcl.condition2 = 'contains'; pcl.condition3 = 'notcontains'; pcl.value3 = 'Aa'; pcl.OpptyWait=true; pcl.searchOpp(); //System.assertEquals(1, pcl.oppRecords.size()); //System.assertEquals(depart1.Id, pcl.oppRecords[0].rec.AccountId); pcl.text3 = ''; pcl.searchOpp(); pcl.sortKey = '2'; pcl.sortTable(); // System.assertEquals(2, pcl.oppRecords.size()); //System.assertEquals('B', pcl.oppRecords[1].rec.Competitor__c); // pcl.oppRecords[1].rec.Competitor__c = 'A1'; // ソートの確認 // pcl.saveType = '2'; // pcl.OpptyWait=true; // pcl.save(); // System.Test.stopTest(); //System.assertEquals(depart2.Id, pcl.oppRecords[0].rec.AccountId); } } }