高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
@isTest
private class RVS005RestTest {
    @isTest(SeeAllData=true)
    static void testMethod1() {
  
       List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        if (rectCo.size() == 0) {
            return;
        }
 
        List<RecordType> rectContract = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '契約'];
        if (rectCo.size() == 0) {
            return;
        }
        StaticParameter.EscapeNFM007Trigger = true;
        StaticParameter.EscapeOpportunityBefUpdTrigger = true;
        StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true;
        StaticParameter.EscapeSyncOpportunityTrigger = true;
        StaticParameter.EscapeAccountTrigger = true;
        StaticParameter.EscapeSyncProduct2Trigger = true;  
 
        List<Repair__c>  rcs = [select id,SAPRepairNo__c from Repair__c limit 1];
        RVS005Rest.InspectionResults  InspectionResults=new RVS005Rest.InspectionResults();
        RVS005Rest.InspectionResult  InspectionResult=new  RVS005Rest.InspectionResult();
        InspectionResults.InspectionResult=new RVS005Rest.InspectionResult();    
        Datetime  nowDT=Datetime.now();
        String nowStr=nowDT.format('yyyyMMddHHmm');
        InspectionResults.Monitoring  = new NFMUtil.Monitoring();
        InspectionResults.Monitoring.MessageGroupNumber=nowStr +'01';
        InspectionResult.SAPRepairNotificationNo= rcs.get(0).SAPRepairNo__c;
        InspectionResult.RVSDetailNo= 'RVSkey';
        InspectionResult.LocationGroupDesc='test1';
        InspectionResult.DetermineTime='2020/04/05';
        InspectionResult.DetermineDate='2020/04/05';
        InspectionResults.InspectionResult =InspectionResult;
 
        Test.startTest();
          if(!Test.isRunningTest()){
            LogAutoSendSchedule.assignOneMinute();
          }
          NFMUtil.Monitoring Monitoring = InspectionResults.Monitoring;
          BatchIF_Log__c rowData = NFMUtil.saveRowData(Monitoring, 'RVS005Rest',InspectionResults.InspectionResult);
          RVS005Rest.main(rowData.Id);
        Test.stopTest();
    }
 
    static testMethod void testMethod2() {
 
        Test.startTest();
        
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
         //,"InspectionResult":[{"SAPRepairNotificationNo":"","RVSDetailNo":"MSGH","LocationGroupDesc":"SFDC","DetermineDate":"","DetermineTime":"1"}
          String JsonMsg = '{"Monitoring":{"TransmissionDateTime":"201812201320","Text":"","Tag":"MSGH","Sender":"SFDC","Receiver":"SPO","NumberOfRecord":"1","MessageType":"RVS005","MessageGroupNumber":"20180001722190"},"InspectionResult":{"SAPRepairNotificationNo":"","RVSDetailNo":"MSGH","LocationGroupDesc":"SFDC","DetermineDate":"","DetermineTime":"1"}}';
        req.requestURI = 'services/apexrest/RVS005/execute';
        req.httpMethod = 'POST';
        req.requestBody = Blob.valueof(JsonMsg);
        RestContext.request = req;
        RestContext.response= res;
        RVS005Rest.execute();
 
        Test.stopTest();
   
    }
}