Add file templates for IntelliJ
This commit is contained in:
+1
-1
@@ -770,5 +770,5 @@ To configure the Code Styling in IntelliJ follow these steps
|
|||||||
|
|
||||||
- Open Preferences Dialog log (Mainmenu: InteliJ -> Preferences)
|
- Open Preferences Dialog log (Mainmenu: InteliJ -> Preferences)
|
||||||
- Goto Editor -> Code Style -> Apex
|
- Goto Editor -> Code Style -> Apex
|
||||||
- Import the [ApexStyleGuide.xml](./docs/ApexStyleGuide.xml)
|
- Import the [ApexStyleGuide.xml](dev-tools/assets/intelliJ/ApexStyleGuide.xml)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
public inherited sharing class ${NAME}
|
||||||
|
extends SObjects
|
||||||
|
implements I${NAME}
|
||||||
|
{
|
||||||
|
public static I${NAME} newInstance(List<${SObject_API_Name}> records)
|
||||||
|
{
|
||||||
|
return (I${NAME}) Application.Domain.newInstance(records);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static I${NAME} newInstance(Set<Id> ids)
|
||||||
|
{
|
||||||
|
return (I${NAME}) Application.Domain.newInstance(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ${NAME}(List<${SObject_API_Name}> records)
|
||||||
|
{
|
||||||
|
super(records, Schema.${SObject_API_Name}.SObjectType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<${SObject_API_Name}> get${NAME}()
|
||||||
|
{
|
||||||
|
return (List<${SObject_API_Name}>) getRecords();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Constructor implements fflib_IDomainConstructor
|
||||||
|
{
|
||||||
|
public fflib_SObjects construct(List<Object> records)
|
||||||
|
{
|
||||||
|
return new ${NAME}((List<SObject>) records);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
#parse("AepApexClassMeta.xml")
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
public interface I${NAME}
|
||||||
|
extends fflib_ISObjects
|
||||||
|
{
|
||||||
|
List<${SObject_API_Name}> get${NAME}();
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
#parse("AepApexClassMeta.xml")
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
@IsTest
|
||||||
|
private class ${NAME}Test
|
||||||
|
{
|
||||||
|
@IsTest
|
||||||
|
static void testNewInstanceWithIds()
|
||||||
|
{
|
||||||
|
final Id id = fflib_IDGenerator.generate(Schema.${SObject_API_Name}.SObjectType);
|
||||||
|
final Set<Id> ids = new Set<Id>{ id };
|
||||||
|
final List<${SObject_API_Name}> records = new List<${SObject_API_Name}>{ new ${SObject_API_Name}(Id = id) };
|
||||||
|
|
||||||
|
fflib_ApexMocks mocks = new fflib_ApexMocks();
|
||||||
|
I${NAME}Selector selectorMock = (I${NAME}Selector) mocks.mock(I${NAME}Selector.class);
|
||||||
|
|
||||||
|
mocks.startStubbing();
|
||||||
|
mocks.when(selectorMock.selectSObjectsById(ids)).thenReturn(records);
|
||||||
|
mocks.stopStubbing();
|
||||||
|
|
||||||
|
Application.Selector.setMock(Schema.${SObject_API_Name}.SObjectType, selectorMock);
|
||||||
|
|
||||||
|
System.Test.startTest();
|
||||||
|
I${NAME} result = ${NAME}.newInstance(ids);
|
||||||
|
System.Test.stopTest();
|
||||||
|
|
||||||
|
System.assertEquals(records, result.get${NAME}());
|
||||||
|
}
|
||||||
|
|
||||||
|
@IsTest
|
||||||
|
static void testNewInstanceWithRecords()
|
||||||
|
{
|
||||||
|
final List<${SObject_API_Name}> records = new List<${SObject_API_Name}>{ new ${SObject_API_Name}(Id = fflib_IDGenerator.generate(Schema.${SObject_API_Name}.SObjectType)) };
|
||||||
|
|
||||||
|
System.Test.startTest();
|
||||||
|
I${NAME} result = ${NAME}.newInstance(records);
|
||||||
|
System.Test.stopTest();
|
||||||
|
|
||||||
|
System.assertEquals(records, result.get${NAME}());
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
#parse("AepApexClassMeta.xml")
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
public virtual inherited sharing class ${NAME}
|
||||||
|
extends fflib_SObjectSelector
|
||||||
|
implements I${NAME}
|
||||||
|
{
|
||||||
|
public static I${NAME} newInstance()
|
||||||
|
{
|
||||||
|
return (I${NAME}) Application.Selector.newInstance(Schema.${SObject_API_Name}.SObjectType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IContactsSelector newWithoutSharingInstance()
|
||||||
|
{
|
||||||
|
return (IContactsSelector) Application.ElevatedSelector.newInstance(Schema.${SObject_API_Name}.SObjectType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IContactsSelector newInheritedSharingInstance()
|
||||||
|
{
|
||||||
|
return (IContactsSelector) Application.NoSharingSelector.newInstance(Schema.${SObject_API_Name}.SObjectType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ${NAME}()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ${NAME}(Boolean includeFieldSetFields, Boolean enforceCRUD, Boolean enforceFLS)
|
||||||
|
{
|
||||||
|
super(includeFieldSetFields, enforceCRUD, enforceFLS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Schema.SObjectField> getSObjectFieldList()
|
||||||
|
{
|
||||||
|
return new List<Schema.SObjectField>
|
||||||
|
{
|
||||||
|
${SObject_API_Name}.Id
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public Schema.SObjectType getSObjectType()
|
||||||
|
{
|
||||||
|
return Schema.${SObject_API_Name}.SObjectType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual List<${SObject_API_Name}> selectById(Set<Id> idSet)
|
||||||
|
{
|
||||||
|
return (List<${SObject_API_Name}>) selectSObjectsById(idSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public with sharing class WithSharing extends ${NAME}
|
||||||
|
{
|
||||||
|
// Constructor that will enforce CRUD and FLS
|
||||||
|
public WithSharing()
|
||||||
|
{
|
||||||
|
super(true, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override List<${SObject_API_Name}> selectById(Set<Id> idSet)
|
||||||
|
{
|
||||||
|
return super.selectById(idSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public without sharing class WithoutSharing extends ${NAME}
|
||||||
|
{
|
||||||
|
// Constructor that will enforce CRUD and FLS
|
||||||
|
public WithoutSharing()
|
||||||
|
{
|
||||||
|
super(true, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override List<${SObject_API_Name}> selectById(Set<Id> idSet)
|
||||||
|
{
|
||||||
|
return super.selectById(idSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
#parse("AepApexClassMeta.xml")
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
public interface I${NAME}
|
||||||
|
extends fflib_ISObjectSelector
|
||||||
|
{
|
||||||
|
List<${SObject_API_Name}> selectById(Set<Id> idSet);
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
#parse("AepApexClassMeta.xml")
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
public with sharing class ${NAME}
|
||||||
|
{
|
||||||
|
public static void doSomething()
|
||||||
|
{
|
||||||
|
service().doSomething();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static I${NAME} service()
|
||||||
|
{
|
||||||
|
return (I${NAME}) Application.Service.newInstance(I${NAME}.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ${NAME}Exception extends Exception {}
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
#parse("AEPE ApexClassMeta.xml")
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
public inherited sharing class ${NAME}Impl
|
||||||
|
implements I${NAME}
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Method doSomething
|
||||||
|
*/
|
||||||
|
public void doSomething()
|
||||||
|
{
|
||||||
|
// doSomething
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
#parse("AEPE ApexClassMeta.xml")
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
public interface I${NAME}
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Method doSomething
|
||||||
|
*/
|
||||||
|
void doSomething();
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
@IsTest
|
||||||
|
private class ${NAME}Test
|
||||||
|
{
|
||||||
|
@IsTest
|
||||||
|
static void testBehavior()
|
||||||
|
{
|
||||||
|
|
||||||
|
System.Test.startTest();
|
||||||
|
${NAME}.doSomething();
|
||||||
|
System.Test.stopTest();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
#parse("AEPE ApexClassMeta.xml")
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
#parse("AEPE ApexClassMeta.xml")
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>52.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
Reference in New Issue
Block a user