Skip to content

Commit e366958

Browse files
Added tests for the new getSobjectLocalName
1 parent 9534a6f commit e366958

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

framework/default/ortoo-core/default/classes/utils/tests/SobjectUtilsTest.cls

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ private without sharing class SobjectUtilsTest
116116
System.assertEquals( 'Contact', returnedName, 'getSobjectName, when given an SObjectType, will return the API name of it' );
117117
}
118118

119+
@isTest
120+
private static void getSobjectName_whenGivenAnSobjectTypeInLocalNamespace_willReturnTheFullApiNameOfIt() // NOPMD: Test method name format
121+
{
122+
String returnedName = SobjectUtils.getSobjectName( Application_Configuration__mdt.sobjectType );
123+
ortoo_Asserts.assertEndsWith( '__Application_Configuration__mdt', returnedName, 'getSobjectName, when given an SObjectType in the local namespace, will return the fully qualified API name of it' );
124+
}
125+
119126
@isTest
120127
private static void getSobjectName_whenGivenANullSobjectType_willThrowAnException() // NOPMD: Test method name format
121128
{
@@ -136,6 +143,33 @@ private without sharing class SobjectUtilsTest
136143
ortoo_Asserts.assertContains( 'Attempted to get the name of a null SObjectType', exceptionMessage, 'getSobjectName, when given a null SobjectType, will throw an exception' );
137144
}
138145

146+
@isTest
147+
private static void getSobjectLocalName_whenGivenAnSobjectTypeInLocalNamespace_willReturnTheShortApiNameOfIt() // NOPMD: Test method name format
148+
{
149+
String returnedName = SobjectUtils.getSobjectLocalName( Application_Configuration__mdt.sobjectType );
150+
System.assertEquals( 'Application_Configuration__mdt', returnedName, 'getSobjectLocalName, when given an SObjectType in the local namespace, will return the local API name of it' );
151+
}
152+
153+
@isTest
154+
private static void getSobjectLocalName_whenGivenANullSobjectType_willThrowAnException() // NOPMD: Test method name format
155+
{
156+
SobjectType nullType = null;
157+
158+
Test.startTest();
159+
String exceptionMessage;
160+
try
161+
{
162+
SobjectUtils.getSobjectLocalName( nullType );
163+
}
164+
catch ( Contract.RequiresException e )
165+
{
166+
exceptionMessage = e.getMessage();
167+
}
168+
Test.stopTest();
169+
170+
ortoo_Asserts.assertContains( 'Attempted to get the local name of a null SObjectType', exceptionMessage, 'getSobjectLocalName, when given a null SobjectType, will throw an exception' );
171+
}
172+
139173
@isTest
140174
private static void isCreateable_whenCalled_willReturnIsCreatableOfThatSobject() // NOPMD: Test method name format
141175
{

0 commit comments

Comments
 (0)