| | |
| | | public static User user2 = new User(); |
| | | public static Contact contact2 = new Contact(); |
| | | public static Contact contact = new Contact(); |
| | | |
| | | static testMethod void testMethod1() { |
| | | AgencyOppUpdHandler.testI(); |
| | | } |
| | | |
| | | static testMethod void test_method() { |
| | | // 取引先 |
| | |
| | | System.assertEquals(10, accTestList.size()); |
| | | System.assertEquals('test1医院', accTestList[0].Name); |
| | | |
| | | //经销商医院データを作る |
| | | aHosLink.Name = 'test1经销商医院'; |
| | | aHosLink.Hospital__c = account1.Id; |
| | | aHosLink.Agency__c = account2.Id; |
| | | insert aHosLink; |
| | | |
| | | |
| | | //取引先責任者 |
| | | contact2.AccountId = account2.Id; |
| | |
| | | |
| | | //System.assertEquals('test1经销商', co.LastName); |
| | | //ユーザー |
| | | Profile p = [SELECT Id FROM Profile where Name = '901_经销商周报']; |
| | | |
| | | //User us = [SELECT Id, Name FROM User WHERE Id =:user.Id]; |
| | | //System.assertEquals('test_user@example.com', user.Email); |
| | | User thisUser= [select Id from User where Id=:UserInfo.getUserId()]; |
| | | System.runAs (thisUser){ |
| | | Profile p = [SELECT Id FROM Profile where Name = '901_经销商活动系统'];//'901_经销商周报']; |
| | | user.ProfileId = p.Id; |
| | | user.ContactId = contact2.Id; |
| | | user.FirstName = 'ユーザー'; |
| | |
| | | user.Alias = 'テユ'; |
| | | user.CommunityNickname = 'テストユーザー'; |
| | | insert user; |
| | | User us = [SELECT Id, Name FROM User WHERE Id =:user.Id]; |
| | | System.assertEquals('test_user@example.com', user.Email); |
| | | |
| | | //经销商医院データを作る |
| | | aHosLink.Name = 'test1经销商医院'; |
| | | aHosLink.Hospital__c = account1.Id; |
| | | aHosLink.Agency__c = account2.Id; |
| | | aHosLink.Agency_Campaign_Obj__c =true; |
| | | aHosLink.OwnerId = user.Id; |
| | | insert aHosLink; |
| | | |
| | | Id rtId = [select Id,DeveloperName from RecordType where IsActive = true and SobjectType = 'Agency_Opportunity__c' and DeveloperName = 'Opportunity'].Id; |
| | | agency_Opp.RecordTypeId = rtId; |
| | |
| | | opp.Agency_Opportunity__c = agency_Opp.Id; |
| | | opp.Name = 'test询价'; |
| | | opp.StageName = '目標'; |
| | | opp.CloseDate = Date.newInstance(2222, 7, 15); |
| | | opp.CloseDate = Date.newInstance(2023, 7, 15); |
| | | |
| | | Test.startTest(); |
| | | insert opp; |
| | |
| | | Test.stopTest(); |
| | | Opportunity opptest = [SELECT Id, Name FROM Opportunity WHERE Id =:opp.Id]; |
| | | System.assertEquals('::test询价', opptest.Name); |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | System.assertEquals(10, accTestList.size()); |
| | | System.assertEquals('test1医院', accTestList[0].Name); |
| | | |
| | | //经销商医院データを作る |
| | | aHosLink.Name = 'test1经销商医院'; |
| | | aHosLink.Hospital__c = account1.Id; |
| | | aHosLink.Agency__c = account2.Id; |
| | | insert aHosLink; |
| | | |
| | | |
| | | //取引先責任者 |
| | | contact2.AccountId = account2.Id; |
| | |
| | | |
| | | //System.assertEquals('test1经销商', co.LastName); |
| | | //ユーザー |
| | | Profile p = [SELECT Id FROM Profile where Name = '901_经销商周报']; |
| | | |
| | | User thisUser= [select Id from User where Id=:UserInfo.getUserId()]; |
| | | System.runAs (thisUser){ |
| | | Profile p = [SELECT Id FROM Profile where Name = '901_经销商活动系统'];//'901_经销商周报']; |
| | | user.ProfileId = p.Id; |
| | | user.ContactId = contact2.Id; |
| | | user.FirstName = 'ユーザー'; |
| | |
| | | insert user; |
| | | User us = [SELECT Id, Name FROM User WHERE Id =:user.Id]; |
| | | System.assertEquals('test_user@example.com', user.Email); |
| | | |
| | | //经销商医院データを作る |
| | | aHosLink.Name = 'test1经销商医院'; |
| | | aHosLink.Hospital__c = account1.Id; |
| | | aHosLink.Agency__c = account2.Id; |
| | | aHosLink.Agency_Campaign_Obj__c =true; |
| | | aHosLink.OwnerId = user.Id; |
| | | insert aHosLink; |
| | | Id rtId = [select Id,DeveloperName from RecordType where IsActive = true and SobjectType = 'Agency_Opportunity__c' and DeveloperName = 'Opportunity'].Id; |
| | | agency_Opp.RecordTypeId = rtId; |
| | | agency_Opp.Name = '引合1'; |
| | |
| | | opp.StageName = '目標'; |
| | | //opp.AgencyOpp_FromOCM__c = true; |
| | | opp.SAP_Send_OK__c = false; |
| | | opp.CloseDate = Date.newInstance(2222, 7, 15); |
| | | opp.CloseDate = Date.newInstance(2023, 7, 15); |
| | | |
| | | Test.startTest(); |
| | | insert opp; |
| | |
| | | Test.stopTest(); |
| | | Opportunity opptest = [SELECT Id, Name FROM Opportunity WHERE Id =:opp.Id]; |
| | | System.assertEquals('::test询价', opptest.Name); |
| | | } |
| | | } |
| | | |
| | | //Opportunity Owner変更 OCSM_Owner__cも変更 |
| | |
| | | |
| | | //System.assertEquals('test1经销商', co.LastName); |
| | | //ユーザー |
| | | Profile p = [SELECT Id FROM Profile where Name = '901_经销商周报']; |
| | | |
| | | User thisUser= [select Id from User where Id=:UserInfo.getUserId()]; |
| | | System.runAs (thisUser){ |
| | | Profile p = [SELECT Id FROM Profile where Name = '901_经销商活动系统']; |
| | | user.ProfileId = p.Id; |
| | | user.ContactId = contact2.Id; |
| | | user.FirstName = 'ユーザー'; |
| | |
| | | , ProfileId = adminP1.id); |
| | | |
| | | insert new List<User> {user, user2}; |
| | | |
| | | //经销商医院データを作る |
| | | aHosLink.Name = 'test1经销商医院'; |
| | | aHosLink.Hospital__c = account1.Id; |
| | | aHosLink.Agency__c = account2.Id; |
| | | aHosLink.OwnerId = user.Id; |
| | | aHosLink.Agency_Campaign_Obj__c =true; |
| | | insert aHosLink; |
| | | |
| | | Id rtId = [select Id,DeveloperName from RecordType where IsActive = true and SobjectType = 'Agency_Opportunity__c' and DeveloperName = 'Opportunity'].Id; |
| | |
| | | opp.Name = 'test询价'; |
| | | opp.StageName = '目標'; |
| | | opp.SAP_Send_OK__c = false; |
| | | opp.CloseDate = Date.newInstance(2222, 7, 15); |
| | | opp.CloseDate = Date.newInstance(2023, 7, 15); |
| | | opp.SAP_Send_OK__c = true; |
| | | insert opp; |
| | | |
| | | Test.startTest(); |
| | | //updAgencyOpportunityMap |
| | | opp.Agency_Opportunity__c = agency_Opp.Id; |
| | | update opp; |
| | | // opp.Agency_Opportunity__c = agency_Opp.Id; |
| | | // update opp; |
| | | |
| | | agency_Opp.NewOpportunity_Agency_Apply_Status__c = '批准'; |
| | | agency_Opp.Change_To_Opportunity__c = opp.Id; |
| | | update agency_Opp; |
| | | |
| | | //Owner変更 |
| | | opp.owner_not_automatically_update__c = true; |
| | | opp.OwnerId = user2.Id; |
| | | update opp; |
| | | //opp.owner_not_automatically_update__c = true; |
| | | //opp.OwnerId = user2.Id; |
| | | //update opp; |
| | | Test.stopTest(); |
| | | |
| | | Agency_Opportunity__c agencyopportunity = [SELECT |
| | | Id,Name,OCSM_Owner__c,Change_To_Opportunity__c, Department_Class_Opp__c |
| | | FROM Agency_Opportunity__c WHERE Id =: agency_Opp.Id]; |
| | | System.assertNotEquals(agencyopportunity.Department_Class_Opp__c, null); |
| | | System.assertEquals(user2.Id, opp.OwnerId); |
| | | System.assertEquals(user2.Id, agencyopportunity.OCSM_Owner__c); |
| | | //System.assertEquals(user2.Id, opp.OwnerId); |
| | | //System.assertEquals(user2.Id, agencyopportunity.OCSM_Owner__c); |
| | | |
| | | String rowCause = Schema.Agency_Opportunity__Share.RowCause.OCSM_Owner_c_User__c; |
| | | List<Agency_Opportunity__Share> agencyopportunityShare = [SELECT |
| | |
| | | AND RowCause = :rowCause]; |
| | | System.assertEquals(1, agencyopportunityShare.size()); |
| | | System.assertEquals('OCSM_Owner_c_User__c', agencyopportunityShare[0].RowCause); |
| | | System.assertEquals(user2.Id, agencyopportunityShare[0].UserOrGroupId); |
| | | //System.assertEquals(user2.Id, agencyopportunityShare[0].UserOrGroupId); |
| | | } |
| | | } |
| | | } |