| | |
| | | @isTest |
| | | private class AttachmentTriggerTest { |
| | | @TestSetup |
| | | static void setup(){ |
| | | TestDataUtility.CreatePIPolicyConfigurations(new string[]{'Agency_Contact__c','Contact'}); |
| | | } |
| | | |
| | | |
| | | @isTest |
| | | static void test_method_one() { |
| | |
| | | contact2.LastName = 'test1经销商'; |
| | | insert contact2; |
| | | |
| | | Test.setMock(HttpCalloutMock.class, new HttpMock()); |
| | | |
| | | List<Agency_Contact__c> lra = new List<Agency_Contact__c>(); |
| | | lra.add(new Agency_Contact__c( |
| | | Aws_Data_Id__c = '123456' |
| | | )); |
| | | |
| | | System.Test.startTest(); |
| | | AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c'); |
| | | AWSServiceTool2.EncryptPushFuture(null,null); |
| | | //insert att1; |
| | | Attachment att = new Attachment( |
| | | Name = 'test', |
| | |
| | | } |
| | | @isTest |
| | | static void test_method_6() { |
| | | List<RecordType> rectC = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; |
| | | if (rectC.size() == 0) { |
| | | return; |
| | | User thisUser = [select Id from User where Id = :UserInfo.getUserId() ]; |
| | | System.runAs ( thisUser ){ |
| | | List<RecordType> rectC = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; |
| | | if (rectC.size() == 0) { |
| | | return; |
| | | } |
| | | Account act1 = new Account(); |
| | | act1.Name = 'TestAccount01'; |
| | | act1.RecordTypeId = rectC[0].Id; |
| | | |
| | | upsert act1; |
| | | |
| | | List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '契約']; |
| | | if (rectCo.size() == 0) { |
| | | return; |
| | | } |
| | | Account act2 = new Account(); |
| | | act2.Name = 'TestAccount02'; |
| | | act2.Business_Assistant__c = getUser().id; |
| | | act2.RecordTypeId = rectCo[0].Id; |
| | | act2.ParentId = act1.Id; |
| | | |
| | | upsert act2; |
| | | |
| | | Consumable_order__c co = new Consumable_order__c(); |
| | | co.Name = 'TestCo'; |
| | | co.Order_status__c = '草案中'; |
| | | co.Order_effective_contact__c = act2.id; |
| | | |
| | | insert co; |
| | | System.Test.startTest(); |
| | | |
| | | Attachment att = new Attachment( |
| | | Name = 'test', |
| | | ParentId = co.Id, |
| | | Body = EncodingUtil.base64Decode('test') |
| | | ); |
| | | |
| | | insert att; |
| | | |
| | | delete att; |
| | | |
| | | System.Test.stopTest(); |
| | | } |
| | | Account act1 = new Account(); |
| | | act1.Name = 'TestAccount01'; |
| | | act1.RecordTypeId = rectC[0].Id; |
| | | |
| | | upsert act1; |
| | | |
| | | List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '契約']; |
| | | if (rectCo.size() == 0) { |
| | | return; |
| | | } |
| | | Account act2 = new Account(); |
| | | act2.Name = 'TestAccount02'; |
| | | act2.Business_Assistant__c = getUser().id; |
| | | act2.RecordTypeId = rectCo[0].Id; |
| | | act2.ParentId = act1.Id; |
| | | |
| | | upsert act2; |
| | | |
| | | Consumable_order__c co = new Consumable_order__c(); |
| | | co.Name = 'TestCo'; |
| | | co.Order_status__c = '草案中'; |
| | | co.Order_effective_contact__c = act2.id; |
| | | |
| | | insert co; |
| | | System.Test.startTest(); |
| | | |
| | | Attachment att = new Attachment( |
| | | Name = 'test', |
| | | ParentId = co.Id, |
| | | Body = EncodingUtil.base64Decode('test') |
| | | ); |
| | | |
| | | insert att; |
| | | |
| | | delete att; |
| | | |
| | | System.Test.stopTest(); |
| | | |
| | | } |
| | | |
| | | @isTest |
| | |
| | | } |
| | | |
| | | // MZY SWAG-BXXBKA 2021-02-19 end |
| | | |
| | | class HttpMock implements HttpCalloutMock{ |
| | | public HTTPResponse respond(HTTPRequest request) { |
| | | // 创建一个假的回应 |
| | | System.debug('------------------------------------------------------'); |
| | | HttpResponse response = new HttpResponse(); |
| | | string body = ''; |
| | | system.debug(request.getEndpoint()); |
| | | if(request.getEndpoint().contains('token')){ |
| | | system.debug('url=token'); |
| | | response.setHeader('Content-Type', 'application/json'); |
| | | body='{ "message": "", "object": "freqfewqfewewfewfew", "status": "", "success": true, "timestamp": 0, "txId": "" }'; |
| | | } else if(request.getEndpoint().contains('insert')){ |
| | | system.debug('url=Insert'); |
| | | response.setHeader('Content-Type', 'application/json'); |
| | | body='{ "message": "", "object": [ { "dataId": "123456", "directShippmentAddress": "", "directShippmentAddressEncrypt": "", "isDelete": 0, "phoneNumber": "", "phoneNumberEncrypt": "", "sfRecordId": "a2R1m0000007BPD" } ], "status": "", "success": true, "timestamp": 0, "txId": "" }'; |
| | | } else if(request.getEndpoint().contains('update')){ |
| | | system.debug('url=update'); |
| | | response.setHeader('Content-Type', 'application/json'); |
| | | body='{ "message": "", "object": [ { "dataId": "123456", "directShippmentAddress": "", "directShippmentAddressEncrypt": "", "isDelete": 0, "phoneNumber": "", "phoneNumberEncrypt": "", "sfRecordId": "a2R1m0000007BPD" } ], "status": "", "success": true, "timestamp": 0, "txId": "" }'; |
| | | } else{ |
| | | |
| | | } |
| | | |
| | | response.setBody(body); |
| | | response.setStatus('OK'); |
| | | response.setStatusCode(200); |
| | | return response; |
| | | // } |
| | | } |
| | | } |
| | | |
| | | } |