Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master into feature/animalBadges #161

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ robot/animal_shelter_starter/results/
.DS_Store

test_results.*
/IlluminatedCloud/
2 changes: 1 addition & 1 deletion cumulusci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ project:
package:
name: Animal Shelter Starter
namespace: animalshelters
api_version: "59.0"
api_version: "60.0"
source_format: sfdx
git:
default_branch: master
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
<c:lightningPrintView recordId="{!v.recordid}" fieldSetName="{!v.fieldSetName}" sObjectTypeName="{!v.sObjectTypeName}"
badgefields="{!v.badgefields}" />

</aura:application>
</aura:application>
4 changes: 2 additions & 2 deletions force-app/main/default/classes/AlertBannerController.cls
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public with sharing class AlertBannerController {
return null;
}

if(Schema.sObjectType.animalshelters__Animal_Alert__c.isAccessible() && Schema.sObjectType.animalshelters__Animal_Alert__c.fields.animalshelters__Alert_Message__c.isAccessible() && Schema.sObjectType.animalshelters__Animal_Alert__c.fields.animalshelters__Start_Date_Time__c.isAccessible() && Schema.sObjectType.animalshelters__Animal_Alert__c.fields.animalshelters__End_Date_Time__c.isAccessible()){
if(Schema.SObjectType.animalshelters__Animal_Alert__c.isAccessible() && Schema.SObjectType.animalshelters__Animal_Alert__c.fields.animalshelters__Alert_Message__c.isAccessible() && Schema.SObjectType.animalshelters__Animal_Alert__c.fields.animalshelters__Start_Date_Time__c.isAccessible() && Schema.SObjectType.animalshelters__Animal_Alert__c.fields.animalshelters__End_Date_Time__c.isAccessible()){

List<animalshelters__Animal_Alert__c> AlertList = [SELECT Id, animalshelters__Alert_Message__c,animalshelters__Start_Date_Time__c FROM animalshelters__Animal_Alert__c WHERE animalshelters__Animal__c = :parentId AND animalshelters__Start_Date_Time__c <= TODAY AND (animalshelters__End_Date_Time__c >= TODAY OR animalshelters__End_Date_Time__c = NULL) WITH SECURITY_ENFORCED LIMIT 20];
List<animalshelters__Animal_Alert__c> AlertList = [SELECT Id, animalshelters__Alert_Message__c,animalshelters__Start_Date_Time__c,animalshelters__End_Date_Time__c,animalshelters__Severity_Level__c,animalshelters__Type__c FROM animalshelters__Animal_Alert__c WHERE animalshelters__Animal__c = :parentId AND animalshelters__Start_Date_Time__c <= TODAY AND (animalshelters__End_Date_Time__c >= TODAY OR animalshelters__End_Date_Time__c = NULL) WITH SECURITY_ENFORCED LIMIT 20];
return AlertList;

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>59.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
5 changes: 3 additions & 2 deletions force-app/main/default/classes/AlertBannerControllerTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
* Ver Date Author Modification
* 1.0 4/30/2020 Stewart Anderson (Salesforce.org) Initial Version
**/
@isTest
@IsTest
public class AlertBannerControllerTest {
static testMethod void testMethod1 () {
@IsTest
static void testMethod1 () {
List<animalshelters__Animal_Alert__c> AlertListTest = AlertBannerController.getRelatedAlertRecords('a003z00000rlhSbAAI');
List<animalshelters__Animal_Alert__c> AlertListTest2 = AlertBannerController.getRelatedAlertRecords(null);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>59.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
8 changes: 4 additions & 4 deletions force-app/main/default/classes/AnimalActionRLClass2.cls
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public with sharing class AnimalActionRLClass2 {
// System.debug('recId = ' + recId);
// System.debug('rTypeName = ' + rTypeName);

if(Schema.sObjectType.animalshelters__Animal_Action__c.isAccessible() && Schema.sObjectType.animalshelters__Animal_Action__c.fields.name.isAccessible() && Schema.sObjectType.animalshelters__Animal_Action__c.fields.animalshelters__Action_Completed__c.isAccessible() && Schema.sObjectType.animalshelters__Animal_Action__c.fields.animalshelters__Date_Time_of_Action__c.isAccessible() && Schema.sObjectType.animalshelters__Animal_Action__c.fields.animalshelters__Description__c.isAccessible() && Schema.sObjectType.animalshelters__Animal_Action__c.fields.RecordTypeId.isAccessible() && Schema.sObjectType.animalshelters__Animal__c.isAccessible()){
if(Schema.SObjectType.animalshelters__Animal_Action__c.isAccessible() && Schema.SObjectType.animalshelters__Animal_Action__c.fields.Name.isAccessible() && Schema.SObjectType.animalshelters__Animal_Action__c.fields.animalshelters__Action_Completed__c.isAccessible() && Schema.SObjectType.animalshelters__Animal_Action__c.fields.animalshelters__Date_Time_of_Action__c.isAccessible() && Schema.SObjectType.animalshelters__Animal_Action__c.fields.animalshelters__Description__c.isAccessible() && Schema.SObjectType.animalshelters__Animal_Action__c.fields.RecordTypeId.isAccessible() && Schema.SObjectType.animalshelters__Animal__c.isAccessible()){
List<animalshelters__Animal_Action__c> animalActions= new List<animalshelters__Animal_Action__c>();
boolean blnFirstTimeRound = false;
for(RecordType rec : [SELECT Id FROM RecordType WHERE sObjectType = 'animalshelters__Animal_Action__c' and Name =:rTypeName])
Boolean blnFirstTimeRound = false;
for(RecordType rec : [SELECT Id FROM RecordType WHERE SobjectType = 'animalshelters__Animal_Action__c' AND Name =:rTypeName])
{
if (!blnFirstTimeRound){
List<animalshelters__Animal_Action__c> y = [SELECT Id, Name, animalshelters__Action_Completed__c, animalshelters__Date_Time_of_Action__c, animalshelters__Description__c
FROM animalshelters__Animal_Action__c
WHERE animalshelters__Animal__c= :recId and RecordTypeId= :rec.Id WITH SECURITY_ENFORCED ];
WHERE animalshelters__Animal__c= :recId AND RecordTypeId= :rec.Id WITH SECURITY_ENFORCED ];
for(animalshelters__Animal_Action__c z : y)
{
animalActions.add(z);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>59.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Ver Date Author Modification
* 1.0 4/30/2020 Stewart Anderson (Salesforce.org) Initial Version
**/
@isTest
@IsTest
public class AnimalActionRLClass2Test {

@IsTest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>59.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
73 changes: 73 additions & 0 deletions force-app/main/default/classes/AnimalBadgeController.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* @File Name : AnimalBadgeController.cls
* @Description :
* @Author : Chris Rolfe (Salesforce)
* @Last Modified By :
* @Last Modified On :
* @Modification Log :
* Ver Date Author Modification
* 1.0 01/04/2024 Chris Rolfe (Salesforce) Initial Version
**/
public with sharing class AnimalBadgeController {

@AuraEnabled(cacheable=true)
public static Map<String, Boolean> getRelatedBadges(Id animalId) {
Map<String, Boolean> badges = new Map<String, Boolean>{
'Alert' => false,
'Condition' => false,
'Nutrition' => false,
'Exercise' => false,
'Treatment' => false,
'Vaccination' => false
};

// Check for Alerts with no end date
if(Schema.sObjectType.animalshelters__Animal_Alert__c.isAccessible() && Schema.sObjectType.animalshelters__Animal_Alert__c.fields.Animalshelters__End_Date_Time__c.isAccessible()) {
List<animalshelters__Animal_Alert__c> alerts = [SELECT Id
FROM animalshelters__Animal_Alert__c
WHERE animalshelters__Animal__c = :animalId
AND animalshelters__End_Date_Time__c = null
WITH SECURITY_ENFORCED];
// System.debug(alerts);
if(!alerts.isEmpty()) {
badges.put('Alert', true);
}
}

// Check for Condiitons that have no end date
if(Schema.sObjectType.animalshelters__Condition__c.isAccessible() && Schema.sObjectType.animalshelters__Condition__c.fields.Animalshelters__End_Date_Time__c.isAccessible()) {
List<animalshelters__Condition__c> conditions = [SELECT Id
FROM animalshelters__Condition__c
WHERE animalshelters__Animal__c = :animalId
AND animalshelters__End_Date_Time__c = null
WITH SECURITY_ENFORCED];
// System.debug(conditions);
if(!conditions.isEmpty()) {
badges.put('Condition', true);
}
}

// Check for Action Records and RecordTypes
if(Schema.sObjectType.animalshelters__Animal_Action__c.isAccessible() && Schema.sObjectType.animalshelters__Animal_Action__c.fields.animalshelters__Treatment_Type__c.isAccessible() && Schema.sObjectType.animalshelters__Animal_Action__c.fields.animalshelters__Action_Completed__c.isAccessible()) {
List<animalshelters__Animal_Action__c> actions = [SELECT Id, RecordType.Name, animalshelters__Treatment_Type__c
FROM animalshelters__Animal_Action__c
WHERE animalshelters__Animal__c = :animalId
AND animalshelters__Action_Completed__c = false
WITH SECURITY_ENFORCED];
// System.debug(actions);
for(animalshelters__Animal_Action__c action : actions) {
if(action.RecordType.Name == 'Nutrition') {
badges.put('Nutrition', true);
} else if(action.RecordType.Name == 'Exercise'){
badges.put('Exercise', true);
} else if(action.RecordType.Name == 'Treatment' && action.animalshelters__Treatment_Type__c == 'Vaccination'){
badges.put('Vaccination', true);
} else if(action.RecordType.Name == 'Treatment' && action.animalshelters__Treatment_Type__c != 'Vaccination'){
badges.put('Treatment', true);
}
}
//System.debug(badges);
}
return badges;
}
}
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>
51 changes: 51 additions & 0 deletions force-app/main/default/classes/AnimalBadgeControllerTest.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
@isTest
private class AnimalBadgeControllerTest {

@IsTest static void testNoBadges() {
// Set Up Test Data
animalshelters__Animal__c testAnimal = new animalshelters__Animal__c(animalshelters__Animal_Name__c = 'Test Animal', animalshelters__Date_of_Arrival__c = Date.today());
insert testAnimal;

//Test with no badges
Test.startTest();
Map<String, Boolean> badges = AnimalBadgeController.getRelatedBadges(testAnimal.Id);
Test.stopTest();

//Verify Results
System.assertEquals(false, badges.get('Alert'), 'Expected no alert');
System.assertEquals(false, badges.get('Condition'), 'Expected no Condition');
System.assertEquals(false, badges.get('Nutrition'), 'Expected no Nutrition');
System.assertEquals(false, badges.get('Exercise'), 'Expected no Exercise');
System.assertEquals(false, badges.get('Treatment'), 'Expected no Treatment');
}

@IsTest static void testWithBadges() {
// Set Up Test Data
animalshelters__Animal__c testAnimal = new animalshelters__Animal__c(animalshelters__Animal_Name__c = 'Test Animal', animalshelters__Date_of_Arrival__c = Date.today());
insert testAnimal;

animalshelters__Animal_Alert__c alert = new animalshelters__Animal_Alert__c(animalshelters__Animal__c = testAnimal.Id, animalshelters__Start_Date_Time__c = Date.today(), animalshelters__Type__c = 'General', animalshelters__Alert_Message__c = 'Test');
animalshelters__Condition__c condition = new animalshelters__Condition__c(animalshelters__Animal__c = testAnimal.Id, animalshelters__Start_Date__c = Date.today());
insert alert;
insert condition;

//Create a dummy record type for Action
Id recordTypeId = Schema.SObjectType.animalshelters__Animal_Action__c.getRecordTypeInfosByName().get('Exercise').getRecordTypeId();
animalshelters__Animal_Action__c action = new animalshelters__Animal_Action__c(animalshelters__Animal__c = testAnimal.Id, animalshelters__Date_Time_of_Action__c= Date.today(), animalshelters__Description__c = 'Test', RecordTypeId = recordTypeId);
insert action;

//Test with Badges
Test.startTest();
Map<String, Boolean> badges = AnimalBadgeController.getRelatedBadges(testAnimal.Id);
Test.stopTest();

//Verify Results
System.assertEquals(true, badges.get('Alert'), 'Expected an alert');
System.assertEquals(true, badges.get('Condition'), 'Expected a Condition');
System.assertEquals(false, badges.get('Nutrition'), 'Expected no Nutrition');
System.assertEquals(true, badges.get('Exercise'), 'Expected an Exercise');
System.assertEquals(false, badges.get('Treatment'), 'Expected no Treatment');

}

}
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>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public with sharing class AnimalShelterFieldsetController {
}
}

@AuraEnabled(cacheable=true)
@AuraEnabled(Cacheable=true)
public static List<FieldSetMemberWrapper> getFieldSet(String sObjectName, String fieldSetName) {
List<FieldSetMemberWrapper> fieldSetMemberWrappers = new List<FieldSetMemberWrapper>();

Expand Down Expand Up @@ -48,7 +48,7 @@ public with sharing class AnimalShelterFieldsetController {
return fieldSetMemberWrappers;
}

@AuraEnabled(cacheable=true)
@AuraEnabled(Cacheable=true)
public static Map<String, List<String>> getBadgeFieldsData(String recordId, String sObjectName, List<String> badgeFieldNames) {

// Check Object and Field Security
Expand Down Expand Up @@ -96,4 +96,4 @@ public with sharing class AnimalShelterFieldsetController {
}
return badgeFieldsData;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* @last modified on : 12-22-2023
* @last modified by : Stewart Anderson
**/
@isTest
@IsTest
private class AnimalShelterFieldsetControllerTest {

@isTest static void testGetFieldSet() {
@IsTest static void testGetFieldSet() {
// Setup test data
// Since Schema and FieldSets cannot be created in test methods,
// we'll assume there's an existing object and field set available.
Expand All @@ -24,7 +24,7 @@ private class AnimalShelterFieldsetControllerTest {
System.assertNotEquals(0, result.size(), 'The result should have elements');
}

@isTest static void testGetBadgeFieldsData() {
@IsTest static void testGetBadgeFieldsData() {
// Setup test data
// Create a record for the sObject you're testing against
animalshelters__Animal__c testRecord = new animalshelters__Animal__c(animalshelters__Animal_Name__c='Test', animalshelters__Date_of_Arrival__c=Datetime.now());
Expand All @@ -46,4 +46,4 @@ private class AnimalShelterFieldsetControllerTest {
System.assertEquals('Anxious', badgeData.get('animalshelters__Behaviours__c')[0], 'The first value should be Anxious');
System.assertEquals('Bad Recall', badgeData.get('animalshelters__Behaviours__c')[1], 'The second value should be Bad Recall');
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>59.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
**/
public with sharing class AnimalShelterGetCustomSettings {

@AuraEnabled(cacheable=true)
@AuraEnabled(Cacheable=true)
public static animalshelters__Animal_Shelter_Settings__c getCustomSettings(){
if (Schema.sObjectType.animalshelters__Animal_Shelter_Settings__c.isAccessible()) {
if (Schema.SObjectType.animalshelters__Animal_Shelter_Settings__c.isAccessible()) {
return animalshelters__Animal_Shelter_Settings__c.getOrgDefaults();
} else {
throw new AuraHandledException('Access Issue: There was an attempt to access Animal Shelter Starter Settings by a user without access.');
Expand All @@ -19,7 +19,7 @@ public with sharing class AnimalShelterGetCustomSettings {

@AuraEnabled
public static void saveCustomSetting(animalshelters__Animal_Shelter_Settings__c customSetting) {
if (Schema.sObjectType.animalshelters__Animal_Shelter_Settings__c.isUpdateable()) {
if (Schema.SObjectType.animalshelters__Animal_Shelter_Settings__c.isUpdateable()) {
update customSetting;
} else {
throw new AuraHandledException('Access Issue: There was an attempt to update Animal Shelter Starter Settings by a user without access.');
Expand Down Expand Up @@ -49,4 +49,4 @@ public with sharing class AnimalShelterGetCustomSettings {
throw new AuraHandledException('Error creating default settings: ' + errMsg);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>59.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ private class AnimalShelterGetCustomSettingsTest {
@IsTest static void testGetCustomSetting() {
// Create a new custom setting record
animalshelters__Animal_Shelter_Settings__c setting = new animalshelters__Animal_Shelter_Settings__c();
setting.animalshelters__Breeds_Migration_Complete__c = True;
setting.animalshelters__Default_Animal_Name__c = False;
setting.animalshelters__Breeds_Migration_Complete__c = true;
setting.animalshelters__Default_Animal_Name__c = false;
setting.animalshelters__Default_Animal_Name_Prefix__c = 'pre';
setting.animalshelters__microchip_api_Token__c = 'TestValue';
insert setting;
Expand All @@ -25,8 +25,8 @@ private class AnimalShelterGetCustomSettingsTest {
@IsTest static void testSaveCustomSetting() {
// Create a new custom setting record
animalshelters__Animal_Shelter_Settings__c setting = new animalshelters__Animal_Shelter_Settings__c();
setting.animalshelters__Breeds_Migration_Complete__c = True;
setting.animalshelters__Default_Animal_Name__c = False;
setting.animalshelters__Breeds_Migration_Complete__c = true;
setting.animalshelters__Default_Animal_Name__c = false;
setting.animalshelters__Default_Animal_Name_Prefix__c = 'pre';
setting.animalshelters__microchip_api_Token__c = 'TestValueNew';
insert setting;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>59.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Loading