From 0c259e4e25011eca6a0a79a2f91899e89a6505e4 Mon Sep 17 00:00:00 2001 From: Wim Velzeboer Date: Fri, 3 Sep 2021 19:59:59 +0100 Subject: [PATCH] Add file templates for IntelliJ --- Apex-Styleguide.md | 2 +- .../assets/intelliJ}/ApexStyleGuide.xml | 0 .../fileTemplates/AEPE - Domain Structure.cls | 32 ++++++++ ...in Structure.cls.child.0༏ext༏.cls-meta.xml | 1 + .../AEPE - Domain Structure.cls.child.1.cls | 5 ++ ...in Structure.cls.child.2༏ext༏.cls-meta.xml | 1 + .../AEPE - Domain Structure.cls.child.3.cls | 38 ++++++++++ ...in Structure.cls.child.4༏ext༏.cls-meta.xml | 1 + .../AEPE - Selector Structure.cls | 75 +++++++++++++++++++ ...or Structure.cls.child.0༏ext༏.cls-meta.xml | 1 + .../AEPE - Selector Structure.cls.child.1.cls | 5 ++ ...or Structure.cls.child.2༏ext༏.cls-meta.xml | 1 + .../AEPE - Service Structure.cls | 14 ++++ ...ce Structure.cls.child.0༏ext༏.cls-meta.xml | 1 + .../AEPE - Service Structure.cls.child.1.cls | 11 +++ ...ce Structure.cls.child.2༏ext༏.cls-meta.xml | 1 + .../AEPE - Service Structure.cls.child.3.cls | 7 ++ .../AEPE - Service Structure.cls.child.4.cls | 13 ++++ ...ce Structure.cls.child.5༏ext༏.cls-meta.xml | 1 + ...ce Structure.cls.child.6༏ext༏.cls-meta.xml | 1 + .../includes/AEPE ApexClassMeta.xml | 5 ++ 21 files changed, 215 insertions(+), 1 deletion(-) rename {docs => dev-tools/assets/intelliJ}/ApexStyleGuide.xml (100%) create mode 100644 dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls create mode 100644 dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls.child.0༏ext༏.cls-meta.xml create mode 100644 dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls.child.1.cls create mode 100644 dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls.child.2༏ext༏.cls-meta.xml create mode 100644 dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls.child.3.cls create mode 100644 dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls.child.4༏ext༏.cls-meta.xml create mode 100644 dev-tools/assets/intelliJ/fileTemplates/AEPE - Selector Structure.cls create mode 100644 dev-tools/assets/intelliJ/fileTemplates/AEPE - Selector Structure.cls.child.0༏ext༏.cls-meta.xml create mode 100644 dev-tools/assets/intelliJ/fileTemplates/AEPE - Selector Structure.cls.child.1.cls create mode 100644 dev-tools/assets/intelliJ/fileTemplates/AEPE - Selector Structure.cls.child.2༏ext༏.cls-meta.xml create mode 100644 dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls create mode 100644 dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.0༏ext༏.cls-meta.xml create mode 100644 dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.1.cls create mode 100644 dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.2༏ext༏.cls-meta.xml create mode 100644 dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.3.cls create mode 100644 dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.4.cls create mode 100644 dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.5༏ext༏.cls-meta.xml create mode 100644 dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.6༏ext༏.cls-meta.xml create mode 100644 dev-tools/assets/intelliJ/fileTemplates/includes/AEPE ApexClassMeta.xml diff --git a/Apex-Styleguide.md b/Apex-Styleguide.md index f5bfbac..836fb22 100644 --- a/Apex-Styleguide.md +++ b/Apex-Styleguide.md @@ -770,5 +770,5 @@ To configure the Code Styling in IntelliJ follow these steps - Open Preferences Dialog log (Mainmenu: InteliJ -> Preferences) - Goto Editor -> Code Style -> Apex -- Import the [ApexStyleGuide.xml](./docs/ApexStyleGuide.xml) +- Import the [ApexStyleGuide.xml](dev-tools/assets/intelliJ/ApexStyleGuide.xml) diff --git a/docs/ApexStyleGuide.xml b/dev-tools/assets/intelliJ/ApexStyleGuide.xml similarity index 100% rename from docs/ApexStyleGuide.xml rename to dev-tools/assets/intelliJ/ApexStyleGuide.xml diff --git a/dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls new file mode 100644 index 0000000..e72ac51 --- /dev/null +++ b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls @@ -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 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 records) + { + return new ${NAME}((List) records); + } + } +} diff --git a/dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls.child.0༏ext༏.cls-meta.xml b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls.child.0༏ext༏.cls-meta.xml new file mode 100644 index 0000000..62371ec --- /dev/null +++ b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls.child.0༏ext༏.cls-meta.xml @@ -0,0 +1 @@ +#parse("AepApexClassMeta.xml") \ No newline at end of file diff --git a/dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls.child.1.cls b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls.child.1.cls new file mode 100644 index 0000000..4334312 --- /dev/null +++ b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls.child.1.cls @@ -0,0 +1,5 @@ +public interface I${NAME} + extends fflib_ISObjects +{ + List<${SObject_API_Name}> get${NAME}(); +} \ No newline at end of file diff --git a/dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls.child.2༏ext༏.cls-meta.xml b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls.child.2༏ext༏.cls-meta.xml new file mode 100644 index 0000000..62371ec --- /dev/null +++ b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls.child.2༏ext༏.cls-meta.xml @@ -0,0 +1 @@ +#parse("AepApexClassMeta.xml") \ No newline at end of file diff --git a/dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls.child.3.cls b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls.child.3.cls new file mode 100644 index 0000000..063a037 --- /dev/null +++ b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls.child.3.cls @@ -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 ids = new Set{ 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}()); + } +} \ No newline at end of file diff --git a/dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls.child.4༏ext༏.cls-meta.xml b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls.child.4༏ext༏.cls-meta.xml new file mode 100644 index 0000000..62371ec --- /dev/null +++ b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Domain Structure.cls.child.4༏ext༏.cls-meta.xml @@ -0,0 +1 @@ +#parse("AepApexClassMeta.xml") \ No newline at end of file diff --git a/dev-tools/assets/intelliJ/fileTemplates/AEPE - Selector Structure.cls b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Selector Structure.cls new file mode 100644 index 0000000..96d8b41 --- /dev/null +++ b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Selector Structure.cls @@ -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 getSObjectFieldList() + { + return new List + { + ${SObject_API_Name}.Id + }; + } + + public Schema.SObjectType getSObjectType() + { + return Schema.${SObject_API_Name}.SObjectType; + } + + public virtual List<${SObject_API_Name}> selectById(Set 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 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 idSet) + { + return super.selectById(idSet); + } + } +} \ No newline at end of file diff --git a/dev-tools/assets/intelliJ/fileTemplates/AEPE - Selector Structure.cls.child.0༏ext༏.cls-meta.xml b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Selector Structure.cls.child.0༏ext༏.cls-meta.xml new file mode 100644 index 0000000..62371ec --- /dev/null +++ b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Selector Structure.cls.child.0༏ext༏.cls-meta.xml @@ -0,0 +1 @@ +#parse("AepApexClassMeta.xml") \ No newline at end of file diff --git a/dev-tools/assets/intelliJ/fileTemplates/AEPE - Selector Structure.cls.child.1.cls b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Selector Structure.cls.child.1.cls new file mode 100644 index 0000000..a7e4edd --- /dev/null +++ b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Selector Structure.cls.child.1.cls @@ -0,0 +1,5 @@ +public interface I${NAME} + extends fflib_ISObjectSelector +{ + List<${SObject_API_Name}> selectById(Set idSet); +} \ No newline at end of file diff --git a/dev-tools/assets/intelliJ/fileTemplates/AEPE - Selector Structure.cls.child.2༏ext༏.cls-meta.xml b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Selector Structure.cls.child.2༏ext༏.cls-meta.xml new file mode 100644 index 0000000..62371ec --- /dev/null +++ b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Selector Structure.cls.child.2༏ext༏.cls-meta.xml @@ -0,0 +1 @@ +#parse("AepApexClassMeta.xml") \ No newline at end of file diff --git a/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls new file mode 100644 index 0000000..42e399d --- /dev/null +++ b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls @@ -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 {} +} \ No newline at end of file diff --git a/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.0༏ext༏.cls-meta.xml b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.0༏ext༏.cls-meta.xml new file mode 100644 index 0000000..625df1f --- /dev/null +++ b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.0༏ext༏.cls-meta.xml @@ -0,0 +1 @@ +#parse("AEPE ApexClassMeta.xml") \ No newline at end of file diff --git a/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.1.cls b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.1.cls new file mode 100644 index 0000000..a6c6e40 --- /dev/null +++ b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.1.cls @@ -0,0 +1,11 @@ +public inherited sharing class ${NAME}Impl + implements I${NAME} +{ + /** + * Method doSomething + */ + public void doSomething() + { + // doSomething + } +} \ No newline at end of file diff --git a/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.2༏ext༏.cls-meta.xml b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.2༏ext༏.cls-meta.xml new file mode 100644 index 0000000..625df1f --- /dev/null +++ b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.2༏ext༏.cls-meta.xml @@ -0,0 +1 @@ +#parse("AEPE ApexClassMeta.xml") \ No newline at end of file diff --git a/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.3.cls b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.3.cls new file mode 100644 index 0000000..90caabe --- /dev/null +++ b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.3.cls @@ -0,0 +1,7 @@ +public interface I${NAME} +{ + /** + * Method doSomething + */ + void doSomething(); +} \ No newline at end of file diff --git a/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.4.cls b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.4.cls new file mode 100644 index 0000000..00d187b --- /dev/null +++ b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.4.cls @@ -0,0 +1,13 @@ +@IsTest +private class ${NAME}Test +{ + @IsTest + static void testBehavior() + { + + System.Test.startTest(); + ${NAME}.doSomething(); + System.Test.stopTest(); + + } +} \ No newline at end of file diff --git a/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.5༏ext༏.cls-meta.xml b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.5༏ext༏.cls-meta.xml new file mode 100644 index 0000000..625df1f --- /dev/null +++ b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.5༏ext༏.cls-meta.xml @@ -0,0 +1 @@ +#parse("AEPE ApexClassMeta.xml") \ No newline at end of file diff --git a/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.6༏ext༏.cls-meta.xml b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.6༏ext༏.cls-meta.xml new file mode 100644 index 0000000..625df1f --- /dev/null +++ b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Service Structure.cls.child.6༏ext༏.cls-meta.xml @@ -0,0 +1 @@ +#parse("AEPE ApexClassMeta.xml") \ No newline at end of file diff --git a/dev-tools/assets/intelliJ/fileTemplates/includes/AEPE ApexClassMeta.xml b/dev-tools/assets/intelliJ/fileTemplates/includes/AEPE ApexClassMeta.xml new file mode 100644 index 0000000..dd61d1f --- /dev/null +++ b/dev-tools/assets/intelliJ/fileTemplates/includes/AEPE ApexClassMeta.xml @@ -0,0 +1,5 @@ + + + 52.0 + Active +