@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();
   
    }
}