0

This is related to Lightning Specialist Superbadge step 6 - Automate fulfillment cancellation actions.

The task is when fulfillment is Cancelled, the related OpportunityLineItem unitprice (i.e., salesprice) should be same as the Fulfillment's Deposit. Simple. I manually checked this (after setting up process builder) and is working fine, but when the trailhead app checks, it fails with the error : System.AssertException: Assertion Failed: Same value.

ISSUE: Now, if I see the debug logs (captured when Salesforce trailhead checks this). In below snippet (from debug logs) see the last 2 lines.

There is assertEquals which checks deposit and unitprice - Match.
But assertNotEqual is also checking deposit and unitPrice. It fails here. Both the values will be same, the assertNotEqual is failing because both the values are same!

Execute Anonymous: OpportunityLineItem oli1 = new OpportunityLineItem(OpportunityId=opp.Id, UnitPrice=2, quantity=1,pricebookentryid=pbe.Id, servicedate = date.newInstance(2050, 1, 1), explorer__c = sam.id);
Execute Anonymous: OpportunityLineItem oli2 = new OpportunityLineItem(OpportunityId=opp.Id, UnitPrice=2, quantity=1,pricebookentryid=pbe.Id, servicedate = date.newInstance(2010, 1, 1), explorer__c = sam.id);

Execute Anonymous: // make sure the deposit matches the unit price
Execute Anonymous: System.assertEquals(f1.deposit__c, oli1.unitprice); // one way in the future
Execute Anonymous: System.assertNotEquals(f2.deposit__c, oli2.unitprice); // one way in the past

How to fix this? Is this a bug?

  • I think we need to see more of your test? – Adrian Larson Jul 11 '16 at 4:52
  • 1
    The log says one assert is checking the f1 and oli1 SObjects and the other the different f2 and oli2 SObjects - seems reasonable. Are you making a wrong assumption when you do your manual test or not covering all the cases? – Keith C Jul 11 '16 at 7:26
  • @KeithC : Yes, you covered it right! Both oli1 and oli2 look absolutely same, until I realized there is a slight change in dates there. I added the code. Thanks, it is solved though now – sfdcFanBoy Jul 12 '16 at 2:47
2

Not a bug per-se, this is exactly the point of assertNotEquals... if the parameters ARE NOT EQUAL it returns true. Else, it returns false.

You answered yourself in your question:

"Both the values will be same, the assertNotEqual is failing because both the values are same!"

Exactly right, as it should.

See the docs for more information: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_system.htm

But if you are asking "is this a bug w/ the trailhead validator", then perhaps it may be. You don't control their assertions, the assertions they have hardcoded into their validation engine when you click and check your answer after finishing a trailhead module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.