You need to sign in to do that
Don't have an account?

Test Class code coverage missing some code
Hi Experts,
Below peace of apex code not covered in test class. Please anybody help me.
@RemoteAction
global static String createNewUbeRelationship(RelationshipUtil.Relationship uuRelationship, String requestorId, String responderId)
{
SavePoint savePoint = Database.setSavePoint();
String message = '';
try
{
if(uuRelationship != null && requestorId != null && responderId != null)
{
Trading_Partner_Relationship__c newUURelationship =
new Trading_Partner_Relationship__c( Name = uuRelationship.name,
Requestor__c = requestorId,
Responder__c = responderId,
Status__c = 'Pending',//uuRelationship.relationshipStatus,
Type__c = uuRelationship.relationshipType);
Data.create(newUURelationship);
MessengerUURelationship.insertNonUniversalId(newUURelationship.Id, uuRelationship.nonUniversalIds);
set<String> uuRelationshiptags = new set<String>();
uuRelationshiptags.addAll( uuRelationship.tags );
MessengerUURelationship.insertRelationshipAttributesTags(newUURelationship.Id, uuRelationshiptags);
MessengerUURelationship.sendInFuture(new Set<Id>{ newUURelationship.Id });
message = 'Reciprocal Trading Partner Relationship created successfully.';
} else message = 'Error';
} catch (Exception e)
{
Database.rollback(savePoint);
Util.log(e);
message = 'Error: ' + e.getMessage() + ' -- ' + e.getStackTraceString();
}
return message;
}
}
Thanks in advance
Below peace of apex code not covered in test class. Please anybody help me.
@RemoteAction
global static String createNewUbeRelationship(RelationshipUtil.Relationship uuRelationship, String requestorId, String responderId)
{
SavePoint savePoint = Database.setSavePoint();
String message = '';
try
{
if(uuRelationship != null && requestorId != null && responderId != null)
{
Trading_Partner_Relationship__c newUURelationship =
new Trading_Partner_Relationship__c( Name = uuRelationship.name,
Requestor__c = requestorId,
Responder__c = responderId,
Status__c = 'Pending',//uuRelationship.relationshipStatus,
Type__c = uuRelationship.relationshipType);
Data.create(newUURelationship);
MessengerUURelationship.insertNonUniversalId(newUURelationship.Id, uuRelationship.nonUniversalIds);
set<String> uuRelationshiptags = new set<String>();
uuRelationshiptags.addAll( uuRelationship.tags );
MessengerUURelationship.insertRelationshipAttributesTags(newUURelationship.Id, uuRelationshiptags);
MessengerUURelationship.sendInFuture(new Set<Id>{ newUURelationship.Id });
message = 'Reciprocal Trading Partner Relationship created successfully.';
} else message = 'Error';
} catch (Exception e)
{
Database.rollback(savePoint);
Util.log(e);
message = 'Error: ' + e.getMessage() + ' -- ' + e.getStackTraceString();
}
return message;
}
}
Thanks in advance
Thanks for quick response. I have used below test class code
@isTest
private static void test_createNewUbeRelationship() {
System.runAs(UserTest.createICIXAdminUser()){
Account account = new Account(ICIX_ID__c = '106', Name = 'Org 1', Email_Group__c = 'Requestor', Creator_UBE_Id__c = String.valueOf(Math.abs(Crypto.getRandomInteger()))); insert account;
Account account2 = new Account(ICIX_ID__c = '107', Name = 'Org 2', Email_Group__c = 'Responder', Creator_UBE_Id__c = String.valueOf(Math.abs(Crypto.getRandomInteger()))); insert account2;
Trading_Partner_Relationship__c tpr = new Trading_Partner_Relationship__c(Requestor__c = account.id, Hub_ID__c = 'c198de16-0b1a-a69f-6379-29d5585841a1', Status__c = 'Active', Synchronized__c = true, Responder__c = account2.id, Type__c = 'Supplier'); insert tpr;
RelationshipUtil.KeyValue ru = new RelationshipUtil.KeyValue('key1','value1');
RelationshipUtil.Relationship rur = new RelationshipUtil.Relationship();
rur.IdSF = 'test';
rur.name = 'test';
rur.relationshipStatus = 'Active';
rur.relationshipType = 'Form';
rur.nonUniversalIds = new List<RelationshipUtil.KeyValue>{ru};
rur.attributes = new List<RelationshipUtil.KeyValue>{ru};
Test.startTest();
RequestApproveController.createNewUbeRelationship(rur /*, requestorId, responderId*/);
Test.stopTest();
}
}
Please let us know if this will help you
Thanks
Amit Chaudhary