Skip to content

Commit

Permalink
Merge branch 'master' into v420Source
Browse files Browse the repository at this point in the history
  • Loading branch information
ericrsmith35 authored Jun 18, 2024
2 parents c67b5c9 + 28883e2 commit 788a602
Show file tree
Hide file tree
Showing 57 changed files with 568 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>61.0</apiVersion>
<status>Active</status>
</ApexClass>
16 changes: 16 additions & 0 deletions flow_action_components/ApprovalChecker/LockCheckerTest.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@isTest
private class LockCheckerTest {
@isTest
static void testIsLocked() {
// Create test data
Account acc = new Account(Name='Test Account');
insert acc;

// Call the method to be tested
List<Boolean> result = LockChecker.isLocked(new List<Id>{acc.Id});

// Perform assertions
System.assertEquals(1, result.size(), 'Result should have only one entry');
System.assertEquals(false, result[0], 'The test account should not be locked');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>61.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ global without sharing class FindCommonAndUniqueRecords {

for(sObject sourceRecord : sourceRecordCollection){
//if it is, we add it to the common record collection and remove it from the target map. We do this
String sourceFieldValue = sourceRecord.get(request.sourceUniqueID).toString();
String sourceFieldValue = String.valueOf(sourceRecord.get(request.sourceUniqueID));

if (targetMap.containsKey(sourceFieldValue)){
result.sourceCommonRecordCollection.add(sourceRecord);
Expand All @@ -106,7 +106,7 @@ global without sharing class FindCommonAndUniqueRecords {
// we loop over the 'Target' collection to see if the record is in the 'Source' collection'.
for(sObject targetRecord : targetRecordCollection){
//if it is, we add it to the common record collection and remove it from the target map. We do this
String targetFieldValue = targetRecord.get(request.targetUniqueID).toString();
String targetFieldValue = String.valueOf(targetRecord.get(request.targetUniqueID));

if (sourceMap.containsKey(targetFieldValue)){
result.targetCommonRecordCollection.add(targetRecord);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public class FindCommonAndUniqueRecordsTest {
accounts.add(account3);
insert accounts;

accounts[2].ParentId=accounts[0].Id;
update accounts;

List<Contact> contacts = new List<Contact>();

Contact contact1 = new Contact(
Expand Down Expand Up @@ -63,6 +66,24 @@ public class FindCommonAndUniqueRecordsTest {
System.assertEquals(2, results[0].sourceCommonRecordCollection.size(), 'sourceCommon failed');
}

@IsTest
static void testCompareRecordswithNullUniqueIds() {
List<Account> accountsInSource = [Select Id, ParentId from Account];

List<FindCommonAndUniqueRecords.Request> flowRequests = new List<FindCommonAndUniqueRecords.Request>();
FindCommonAndUniqueRecords.Request flowRequest = new FindCommonAndUniqueRecords.Request();
flowRequest.sourceRecordCollection = accountsInSource;
flowRequest.targetRecordCollection = accountsInSource;
flowRequest.sourceUniqueID = 'Id';
flowRequest.targetUniqueID = 'ParentId';
flowRequests.add(flowRequest);
Test.startTest();
List<FindCommonAndUniqueRecords.Result> results = FindCommonAndUniqueRecords.compareRecords(flowRequests);
Test.stopTest();
System.assertEquals(2, results[0].sourceUniqueRecordCollection.size(), 'sourceUnique failed');
System.assertEquals(1, results[0].sourceCommonRecordCollection.size(), 'sourceCommon failed');
}

@IsTest
static void testEmptyCollection() {
List<Account> accountsInSource = [Select Id from Account];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* Derek Camp - 9/5/23 - v1.0.0
* Initial Release
*
* Eric Smith - 3/18/24 - v1.0.1
* Fix intermittant test class bug (index out of bounds)
* Available in Collection Processor package v3.2.2 and later
*
**/
global inherited sharing class ReturnNRandomRecords {
Expand Down Expand Up @@ -72,7 +75,7 @@ global inherited sharing class ReturnNRandomRecords {
} else {
// Generate a list of random numbers
while (randomNumbers.size() < recordCount) {
Integer randomNumber = ( (Integer)Math.round(Math.random() * inputCollection.size()) -1 );
Integer randomNumber = (Integer)Math.round(Math.random() * (inputCollection.size()-1));
if( !randomNumbers.contains(randomNumber) ) {
randomNumbers.add(randomNumber);
}
Expand Down
5 changes: 3 additions & 2 deletions flow_action_components/CollectionProcessors/sfdx-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "48.0",
"sourceApiVersion": "60.0",
"packageAliases": {
"FlowBaseComponents": "04tf4000003RQxcAAG",
"FlowActionsBasePack@3.0.0-0": "04t8b000001Eh4YAAS",
Expand All @@ -42,6 +42,7 @@
"CollectionActionsL@3.0.0-0": "04t5G000003rUvQQAU",
"CollectionActionsL@3.0.1-0": "04t5G000003rUvaQAE",
"CollectionActionsL@3.1.0": "04t5G000004J7KcQAK",
"CollectionActionsL@3.2.0": "04t5G000004XZirQAG"
"CollectionActionsL@3.2.0": "04t5G000004XZirQAG",
"CollectionActionsL@3.2.1": "04t5G000004XZj6QAG"
}
}
12 changes: 12 additions & 0 deletions flow_action_components/ConvertTextToBase64/.forceignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# List files or directories below to ignore them when running force:source:push, force:source:pull, and force:source:status
# More information: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm
#

package.xml

# LWC configuration files
**/jsconfig.json
**/.eslintrc.json

# LWC Jest
**/__tests__/**
4 changes: 4 additions & 0 deletions flow_action_components/ConvertTextToBase64/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run precommit
18 changes: 18 additions & 0 deletions flow_action_components/ConvertTextToBase64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Salesforce DX Project: Next Steps

Now that you’ve created a Salesforce DX project, what’s next? Here are some documentation resources to get you started.

## How Do You Plan to Deploy Your Changes?

Do you want to deploy a set of changes, or create a self-contained application? Choose a [development model](https://developer.salesforce.com/tools/vscode/en/user-guide/development-models).

## Configure Your Salesforce DX Project

The `sfdx-project.json` file contains useful configuration information for your project. See [Salesforce DX Project Configuration](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm) in the _Salesforce DX Developer Guide_ for details about this file.

## Read All About It

- [Salesforce Extensions Documentation](https://developer.salesforce.com/tools/vscode/)
- [Salesforce CLI Setup Guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm)
- [Salesforce DX Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_intro.htm)
- [Salesforce CLI Command Reference](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference.htm)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"orgName": "Demo company",
"edition": "Developer",
"features": ["EnableSetPasswordInApi"],
"settings": {
"lightningExperienceSettings": {
"enableS1DesktopEnabled": true
},
"mobileSettings": {
"enableS1EncryptedStoragePref2": false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"plugins": ["@salesforce/eslint-plugin-aura"],
"extends": ["plugin:@salesforce/eslint-plugin-aura/recommended"],
"rules": {
"vars-on-top": "off",
"no-unused-expressions": "off"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* Invocable Apex Action for Flow: ConvertTextToBase64
*
* Created By: Eric Smith
*
* Description: This component is designed to be used in a Flow to convert a text string to Base64
*
* Custom Property Editor: N/A
*
* CPE Supporting Components: N/A
*
* 04/03/24 - Eric Smith - Version 1.0.0
*
**/

global with sharing class ConvertTextToBase64 {

/* Flow Action */
@invocableMethod(label='Convert Text to Base64'
iconName='slds:standard:data_transforms'
category='Util'
description='Convert a Text String to Base64 - By Eric Smith')

global static List<Results> ConvertTextToBase64(List<Requests> requestList) {

/* Prepare Response */
Results response = new Results();
List<Results> responseWrapper = new List<Results>();

/* Process Inputs */
for (Requests req : requestList) {

/* Get Input Values */
String textValue = req.textInput;

/* Perform Action(s) */

// Base64 the Text
String base64Value = EncodingUtil.Base64Encode(Blob.valueOf(textValue));

/* TODO: Convert the other direction
// Text the Base64
// Blob blobValue = EncodingUtil.base64Decode(base64Value);
// String stringValue = blobValue.toString();
*/

/* Prepare Output */
response.base64Output = base64Value;

/* Process Outputs */
responseWrapper.add(response);
}

/* Return Results */
return responseWrapper;

}

/* Input parameters for the Apex action */
global class Requests {

@InvocableVariable(label='Text Value for Conversion'
description='Text value to be converted into Base64')
global String textInput;

}

/* Output parameters of the Apex action */
global class Results {
@InvocableVariable(label='Base64 Value'
description='The converted Base64 value')
global String base64Output;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>59.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* This class contains unit tests for validating the behavior of Apex classes
* and triggers.
*
* Unit tests are class methods that verify whether a particular piece
* of code is working properly. Unit test methods take no arguments,
* commit no data to the database, and are flagged with the testMethod
* keyword in the method definition.
*
* All test methods in an org are executed whenever Apex code is deployed
* to a production org to confirm correctness, ensure code
* coverage, and prevent regressions. All Apex classes are
* required to have at least 75% code coverage in order to be deployed
* to a production org. In addition, all triggers must have some code coverage.
*
* The @isTest class annotation indicates this class only contains test
* methods. Classes defined with the @isTest annotation do not count against
* the org size limit for all Apex scripts.
*
* See the Apex Language Reference for more information about Testing and Code Coverage.
*/

@isTest
public with sharing class ConvertTextToBase64Test {

@isTest
public static void myUnitTest() {

ConvertTextToBase64.Requests request = new ConvertTextToBase64.Requests();
List<ConvertTextToBase64.Requests> requestList = new List<ConvertTextToBase64.Requests>();
request.textInput = '[FIELD_10] = "01865467"';

requestList.add(request);

List<ConvertTextToBase64.Results> responseList = ConvertTextToBase64.ConvertTextToBase64(requestList);

System.assertNotEquals(responseList[0].base64Output.length(), 0);
System.assertEquals(responseList[0].base64Output, 'W0ZJRUxEXzEwXSA9ICIwMTg2NTQ2NyI=');

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>59.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": ["@salesforce/eslint-config-lwc/recommended"],
"overrides": [
{
"files": ["*.test.js"],
"rules": {
"@lwc/lwc/no-unexpected-wire-adapter-usages": "off"
},
"env": {
"node": true
}
}
]
}
6 changes: 6 additions & 0 deletions flow_action_components/ConvertTextToBase64/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { jestConfig } = require('@salesforce/sfdx-lwc-jest/config');

module.exports = {
...jestConfig,
modulePathIgnorePatterns: ['<rootDir>/.localdevserver']
};
36 changes: 36 additions & 0 deletions flow_action_components/ConvertTextToBase64/manifest/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>ApexClass</name>
</types>
<types>
<members>*</members>
<name>ApexComponent</name>
</types>
<types>
<members>*</members>
<name>ApexPage</name>
</types>
<types>
<members>*</members>
<name>ApexTestSuite</name>
</types>
<types>
<members>*</members>
<name>ApexTrigger</name>
</types>
<types>
<members>*</members>
<name>AuraDefinitionBundle</name>
</types>
<types>
<members>*</members>
<name>LightningComponentBundle</name>
</types>
<types>
<members>*</members>
<name>StaticResource</name>
</types>
<version>59.0</version>
</Package>
Loading

0 comments on commit 788a602

Please sign in to comment.