• Jared M Neufer
  • NEWBIE
  • 25 Points
  • Member since 2016
  • Senior Lead Consultant
  • Renwell

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies

I am having problem while running below class:
 
@isTest
public with sharing class HandlerTest {

 @isTest static void testScheduleTaskBatch() {
    // Get the information from the CronTrigger API object
    List<CronTrigger> ctBefore = [select Id, CronExpression, TimesTriggered, NextFireTime, State from CronTrigger WHERE CronJobDetail.Name ='SheduledSendTaskBatch' AND State != 'DELETED'];

    System.debug('### ctBefore: ' + ctBefore);

    System.assertEquals(0, ctBefore.size());

    Test.startTest();
      Handler.scheduleTaskBatch(0);
    Test.stopTest();

      List<CronTrigger> ctAfter = [select Id, CronExpression, TimesTriggered, NextFireTime, State from CronTrigger WHERE CronJobDetail.Name = 'SheduledSendTaskBatch' AND State != 'DELETED'];
      System.assertEquals(1, ctAfter.size());
  }

}

It throws below error:

Class HandlerTest Method Name testScheduleTaskBatch Pass/Fail Fail Error Message System.AssertException: Assertion Failed: Expected: 0, Actual: 1 Stack Trace Class.HandlerTest.testScheduleTaskBatch: ' System.assertEquals(0, ctBefore.size());' on this line

I face this assertion error only when if there is any existing Apex Job of name 'SheduledSendTaskBatch' is running in my Org.
But As per my understanding during test class execution the query should return only the batch job that i created in my test class.
I created a Batch Job in Developer console(For Testing purpose in order to debug the issue) like this:
 
SendCMDOTaskBatch m = new SendCMDOTaskBatch();

String sch = '30 0 0 22 12 ?';

String jobID = system.schedule('SheduledSendTaskBatch', sch, m);

at the same time if I run my test class then it throws the assertion error.
Can someone please help how can I avoid this situation?

Is it possible to create a Trigger to decapitalize any letters in Account Name field after an apostrophe if the letter following is an "S"?

Example: St. Paul'S (decapitalize it) so that it would equal St. Paul's.

We had a developer write a code to capitalize all first letters and unfortunately the developer doesn't communicate with us anymore.

 

I'm getting an "Access Denied" error when viewing a custom Visualforce page through a public site.  The visualforce page works fine if the Apex references are removed.   I've added the Apex class and VF pages to the "Public Access Settings" profile. 

The Apex class references Topics and TopicAssignments read-only, but I don't see any way to grant access to those objects, and am not sure if that's even the problem.  
 

Questions:
a) Is there a way to get more verbose error logs for errors that occur on a public SF site? 
b) Do I have to specifically permit read access to Topic&TopicAssignments for a public site, and if so, how is that done?  

Thanks in advance.


I am having problem while running below class:
 
@isTest
public with sharing class HandlerTest {

 @isTest static void testScheduleTaskBatch() {
    // Get the information from the CronTrigger API object
    List<CronTrigger> ctBefore = [select Id, CronExpression, TimesTriggered, NextFireTime, State from CronTrigger WHERE CronJobDetail.Name ='SheduledSendTaskBatch' AND State != 'DELETED'];

    System.debug('### ctBefore: ' + ctBefore);

    System.assertEquals(0, ctBefore.size());

    Test.startTest();
      Handler.scheduleTaskBatch(0);
    Test.stopTest();

      List<CronTrigger> ctAfter = [select Id, CronExpression, TimesTriggered, NextFireTime, State from CronTrigger WHERE CronJobDetail.Name = 'SheduledSendTaskBatch' AND State != 'DELETED'];
      System.assertEquals(1, ctAfter.size());
  }

}

It throws below error:

Class HandlerTest Method Name testScheduleTaskBatch Pass/Fail Fail Error Message System.AssertException: Assertion Failed: Expected: 0, Actual: 1 Stack Trace Class.HandlerTest.testScheduleTaskBatch: ' System.assertEquals(0, ctBefore.size());' on this line

I face this assertion error only when if there is any existing Apex Job of name 'SheduledSendTaskBatch' is running in my Org.
But As per my understanding during test class execution the query should return only the batch job that i created in my test class.
I created a Batch Job in Developer console(For Testing purpose in order to debug the issue) like this:
 
SendCMDOTaskBatch m = new SendCMDOTaskBatch();

String sch = '30 0 0 22 12 ?';

String jobID = system.schedule('SheduledSendTaskBatch', sch, m);

at the same time if I run my test class then it throws the assertion error.
Can someone please help how can I avoid this situation?