diff --git a/force-app/main/default/classes/GetChallengesTest.cls b/force-app/main/default/classes/GetChallengesTest.cls deleted file mode 100644 index 955e68e..0000000 --- a/force-app/main/default/classes/GetChallengesTest.cls +++ /dev/null @@ -1,86 +0,0 @@ -@isTest -private class GetChallengesTest { - @isTest - static void testGetChallenges_NoInput() { - // Arrange - List inputs = new List(); - - // Act - List results = GetChallenges.getChallenges(inputs); - - // Assert - System.assertEquals(1, results.size()); - System.assertEquals('No input provided', results[0].message); - System.assertEquals(0, results[0].challenges.size()); - } - - @isTest - static void testGetChallenges_NoResults() { - // Arrange - GetChallenges.ChallengeQueryInput input = new GetChallenges.ChallengeQueryInput(); - input.status = 'NonExistentStatus'; - List inputs = new List{ input }; - - // Act - List results = GetChallenges.getChallenges(inputs); - - // Assert - System.assertEquals(1, results.size()); - System.assertEquals('No challenges found', results[0].message); - System.assertEquals(0, results[0].challenges.size()); - } - - @isTest - static void testGetChallenges_WithResults() { - // Arrange - Challenge__c challenge = new Challenge__c( - Name = 'Test Challenge', - Status__c = 'Draft', - Participants__c = 'John Doe' - ); - insert challenge; - - GetChallenges.ChallengeQueryInput input = new GetChallenges.ChallengeQueryInput(); - input.status = 'Draft'; - input.participantName = 'John'; - List inputs = new List{ input }; - - // Act - List results = GetChallenges.getChallenges(inputs); - - // Assert - System.assertEquals(1, results.size()); - System.assertEquals('Challenges retrieved successfully', results[0].message); - System.assertEquals(1, results[0].challenges.size()); - System.assertEquals('Test Challenge', results[0].challenges[0].Name); - } - - @isTest - static void testGetChallenges_FilterOnParticipants() { - // Arrange - Challenge__c challenge1 = new Challenge__c( - Name = 'Challenge 1', - Status__c = 'Draft', - Participants__c = 'John Doe, Jane Smith' - ); - Challenge__c challenge2 = new Challenge__c( - Name = 'Challenge 2', - Status__c = 'Draft', - Participants__c = 'Alice Smith, Bob Brown' - ); - insert new List{ challenge1, challenge2 }; - - GetChallenges.ChallengeQueryInput input = new GetChallenges.ChallengeQueryInput(); - input.participantName = 'john'; - List inputs = new List{ input }; - - // Act - List results = GetChallenges.getChallenges(inputs); - - // Assert - System.assertEquals(1, results.size()); - System.assertEquals('Challenges retrieved successfully', results[0].message); - System.assertEquals(1, results[0].challenges.size()); - System.assertEquals('Challenge 1', results[0].challenges[0].Name); - } -} diff --git a/force-app/main/default/classes/GetChallengesTest.cls-meta.xml b/force-app/main/default/classes/GetChallengesTest.cls-meta.xml deleted file mode 100644 index 436a726..0000000 --- a/force-app/main/default/classes/GetChallengesTest.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 63.0 - Active - diff --git a/force-app/main/default/classes/actions/GetChallenges.cls b/force-app/main/default/classes/actions/GetChallenges.cls index 0e57bb8..b0b3ca2 100644 --- a/force-app/main/default/classes/actions/GetChallenges.cls +++ b/force-app/main/default/classes/actions/GetChallenges.cls @@ -20,11 +20,11 @@ public with sharing class GetChallenges { public class Output { @InvocableVariable(description='List of Challenge Objects found') - public List challenges; + public List challenges; @InvocableVariable(description='Result message of the search') public String message; - public Output(List challenges, String message) { + public Output(List challenges, String message) { this.challenges = challenges; this.message = message; } @@ -34,12 +34,12 @@ public with sharing class GetChallenges { public static List getChallenges(List inputList) { List results = new List(); if (inputList == null || inputList.isEmpty()) { - results.add(new Output(new List(), 'No input provided')); + results.add(new Output(new List(), 'No input provided')); return results; } Input queryInput = inputList[0]; - List challenges = ChallengeHelper.queryChallenges( + List challenges = ChallengeHelper.queryChallenges( queryInput.status, queryInput.startDate, queryInput.endDate, @@ -49,14 +49,14 @@ public with sharing class GetChallenges { ); // Delegate participant filtering to ChallengeHelper - List filteredChallenges = ChallengeHelper.filterChallengesByParticipant( + List filteredChallenges = ChallengeHelper.filterChallengesByParticipant( challenges, queryInput.participantRole, queryInput.participantName ); if (filteredChallenges.isEmpty()) { - results.add(new Output(new List(), 'No challenges found')); + results.add(new Output(new List(), 'No challenges found')); } else { results.add(new Output(filteredChallenges, 'Challenges retrieved successfully')); } diff --git a/force-app/main/default/classes/helpers/ChallengeHelper.cls b/force-app/main/default/classes/helpers/ChallengeHelper.cls index 11ee003..9e460bb 100644 --- a/force-app/main/default/classes/helpers/ChallengeHelper.cls +++ b/force-app/main/default/classes/helpers/ChallengeHelper.cls @@ -1,5 +1,5 @@ public with sharing class ChallengeHelper { - public static List queryChallenges( + public static List queryChallenges( String status, Date startDate, Date endDate, @@ -7,18 +7,18 @@ public with sharing class ChallengeHelper { String name, String manager ) { - String query = 'SELECT Id, Name, Status__c, Type__c, Description__c, Result__c, SlackChannel__c, StartDate__c, EndDate__c, Manager__c, Manager__r.Name, Participants__c, Reward__c FROM Challenge__c'; + String query = 'SELECT Id, Name, AmyDataKit__Status__c, AmyDataKit__Type__c, AmyDataKit__Description__c, AmyDataKit__Result__c, AmyDataKit__SlackChannel__c, AmyDataKit__StartDate__c, AmyDataKit__EndDate__c, AmyDataKit__Manager__c, AmyDataKit__Manager__r.Name, AmyDataKit__Participants__c, AmyDataKit__Reward__c FROM AmyDataKit__Challenge__c'; List conditions = new List(); // Build query conditions based on input if (status != null) { - conditions.add('Status__c = :status'); + conditions.add('AmyDataKit__Status__c = :status'); } if (startDate != null) { - conditions.add('StartDate__c >= :startDate'); + conditions.add('AmyDataKit__StartDate__c >= :startDate'); } if (endDate != null) { - conditions.add('EndDate__c <= :endDate'); + conditions.add('AmyDataKit__EndDate__c <= :endDate'); } if (id != null) { conditions.add('Id = :id'); @@ -29,7 +29,7 @@ public with sharing class ChallengeHelper { } if (manager != null) { String likeManager = '%' + manager + '%'; - conditions.add('Manager__r.Name LIKE :likeManager'); + conditions.add('AmyDataKit__Manager__r.Name LIKE :likeManager'); } // If no conditions, return empty results @@ -41,8 +41,8 @@ public with sharing class ChallengeHelper { return Database.query(query); } - public static List filterChallengesByParticipant( - List challenges, + public static List filterChallengesByParticipant( + List challenges, String participantRole, String participantName ) { @@ -52,13 +52,15 @@ public with sharing class ChallengeHelper { String participantRoleFilter = participantRole != null ? participantRole.toLowerCase().trim() : null; String participantNameFilter = participantName != null ? participantName.toLowerCase().trim() : null; - List filteredChallenges = new List(); + List filteredChallenges = new List(); - for (Challenge__c challenge : challenges) { + for (AmyDataKit__Challenge__c challenge : challenges) { if ( - challenge.Participants__c != null && - ((participantRoleFilter != null && challenge.Participants__c.toLowerCase().contains(participantRoleFilter)) || - (participantNameFilter != null && challenge.Participants__c.toLowerCase().contains(participantNameFilter))) + challenge.AmyDataKit__Participants__c != null && + ((participantRoleFilter != null && + challenge.AmyDataKit__Participants__c.toLowerCase().contains(participantRoleFilter)) || + (participantNameFilter != null && + challenge.AmyDataKit__Participants__c.toLowerCase().contains(participantNameFilter))) ) { filteredChallenges.add(challenge); } diff --git a/force-app/main/default/classes/helpers/OpportunityHelper.cls b/force-app/main/default/classes/helpers/OpportunityHelper.cls index e3df560..28debec 100644 --- a/force-app/main/default/classes/helpers/OpportunityHelper.cls +++ b/force-app/main/default/classes/helpers/OpportunityHelper.cls @@ -11,7 +11,7 @@ public with sharing class OpportunityHelper { Boolean isClosed, Boolean isWon ) { - String query = 'SELECT Id, Name, Owner.Name, OwnerId, Amount, Type, CloseDate, StageName, Difficulty__c, Description FROM Opportunity'; + String query = 'SELECT Id, Name, Owner.Name, OwnerId, Amount, Type, CloseDate, StageName, AmyDataKit__Difficulty__c, Description FROM Opportunity'; List conditions = new List(); // Build query conditions based on input diff --git a/force-app/main/default/classes/helpers/SlackHelper.cls b/force-app/main/default/classes/helpers/SlackHelper.cls index 5c4ba54..79cbb10 100644 --- a/force-app/main/default/classes/helpers/SlackHelper.cls +++ b/force-app/main/default/classes/helpers/SlackHelper.cls @@ -14,8 +14,8 @@ public with sharing class SlackHelper { ReturnToken result = new ReturnToken(); SlackBotToken__mdt tokenMetadata = [ - SELECT Bot_User_OAuth_Token__c - FROM SlackBotToken__mdt + SELECT AmyDataKit__Bot_User_OAuth_Token__c + FROM AmyDataKit__SlackBotToken__mdt WHERE DeveloperName = :agentName LIMIT 1 ];