It can't see my Queue: “Expected: 0, Actual: 1”

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
1
down vote

favorite












System.AssertException: Assertion Failed: Expected: 0, Actual: 1
How can I fix it?



Group testGroup = new Group(Name = 'XXX', Type = 'Queue');
insert testGroup;
List<Obj__c> oList = [SELECT OwnerId FROM Obj__c WHERE OwnerId =: testGroup.Id];
System.assertEquals(oList.size(), 1);


testGroup.Id is not null.










share|improve this question























  • your Group insertion might have failed, add a assert before query to see if you have a group id.
    – Raul
    2 hours ago










  • I have group Id.
    – ÐœÐ¾Ð½Ñ‚е Кристо
    2 hours ago










  • You haven't assigned any records to the ownership of the Queue. That query should return no results.
    – David Reed
    2 hours ago






  • 1




    The first parameter in assertEquals is the expected value. Please stick to that to avoid future debugging headaches.
    – Programmatic
    1 hour ago
















up vote
1
down vote

favorite












System.AssertException: Assertion Failed: Expected: 0, Actual: 1
How can I fix it?



Group testGroup = new Group(Name = 'XXX', Type = 'Queue');
insert testGroup;
List<Obj__c> oList = [SELECT OwnerId FROM Obj__c WHERE OwnerId =: testGroup.Id];
System.assertEquals(oList.size(), 1);


testGroup.Id is not null.










share|improve this question























  • your Group insertion might have failed, add a assert before query to see if you have a group id.
    – Raul
    2 hours ago










  • I have group Id.
    – ÐœÐ¾Ð½Ñ‚е Кристо
    2 hours ago










  • You haven't assigned any records to the ownership of the Queue. That query should return no results.
    – David Reed
    2 hours ago






  • 1




    The first parameter in assertEquals is the expected value. Please stick to that to avoid future debugging headaches.
    – Programmatic
    1 hour ago












up vote
1
down vote

favorite









up vote
1
down vote

favorite











System.AssertException: Assertion Failed: Expected: 0, Actual: 1
How can I fix it?



Group testGroup = new Group(Name = 'XXX', Type = 'Queue');
insert testGroup;
List<Obj__c> oList = [SELECT OwnerId FROM Obj__c WHERE OwnerId =: testGroup.Id];
System.assertEquals(oList.size(), 1);


testGroup.Id is not null.










share|improve this question















System.AssertException: Assertion Failed: Expected: 0, Actual: 1
How can I fix it?



Group testGroup = new Group(Name = 'XXX', Type = 'Queue');
insert testGroup;
List<Obj__c> oList = [SELECT OwnerId FROM Obj__c WHERE OwnerId =: testGroup.Id];
System.assertEquals(oList.size(), 1);


testGroup.Id is not null.







unit-test queue






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 hours ago

























asked 2 hours ago









Монте Кристо

184




184











  • your Group insertion might have failed, add a assert before query to see if you have a group id.
    – Raul
    2 hours ago










  • I have group Id.
    – ÐœÐ¾Ð½Ñ‚е Кристо
    2 hours ago










  • You haven't assigned any records to the ownership of the Queue. That query should return no results.
    – David Reed
    2 hours ago






  • 1




    The first parameter in assertEquals is the expected value. Please stick to that to avoid future debugging headaches.
    – Programmatic
    1 hour ago
















  • your Group insertion might have failed, add a assert before query to see if you have a group id.
    – Raul
    2 hours ago










  • I have group Id.
    – ÐœÐ¾Ð½Ñ‚е Кристо
    2 hours ago










  • You haven't assigned any records to the ownership of the Queue. That query should return no results.
    – David Reed
    2 hours ago






  • 1




    The first parameter in assertEquals is the expected value. Please stick to that to avoid future debugging headaches.
    – Programmatic
    1 hour ago















your Group insertion might have failed, add a assert before query to see if you have a group id.
– Raul
2 hours ago




your Group insertion might have failed, add a assert before query to see if you have a group id.
– Raul
2 hours ago












I have group Id.
– ÐœÐ¾Ð½Ñ‚е Кристо
2 hours ago




I have group Id.
– ÐœÐ¾Ð½Ñ‚е Кристо
2 hours ago












You haven't assigned any records to the ownership of the Queue. That query should return no results.
– David Reed
2 hours ago




You haven't assigned any records to the ownership of the Queue. That query should return no results.
– David Reed
2 hours ago




1




1




The first parameter in assertEquals is the expected value. Please stick to that to avoid future debugging headaches.
– Programmatic
1 hour ago




The first parameter in assertEquals is the expected value. Please stick to that to avoid future debugging headaches.
– Programmatic
1 hour ago










2 Answers
2






active

oldest

votes

















up vote
3
down vote













You haven't inserted any records in to the queue yet, so 0 is the expected value. Instead, you need to follow the following steps: insert the Group, insert a QueueSObject, then insert at least one Obj__c record with that OwnerId. Please note that the the Group and QueueSObject must be created inside a System.runAs block, because they are considered Setup Objects.



Here's a demo from a unit test I wrote recently:



@isTest static void test() {
Group g = new Group(Name='TestQueue',Type='Queue');
System.runas(new User(Id=UserInfo.getUserId()))
insert g;
insert new QueueSobject(QueueId=g.id, SObjectType='Lead');

insert new lead(lastname='test',company='test');
insert new lead(lastname='testqueue',company='testqueue',ownerid=g.Id);
...





share|improve this answer



























    up vote
    0
    down vote













    Obj__c insert is missing, no records in it.



    Need to insert obj__c with ownerId set as the testGroup.Id






    share|improve this answer




















      Your Answer







      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "459"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f232774%2fit-cant-see-my-queue-expected-0-actual-1%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      3
      down vote













      You haven't inserted any records in to the queue yet, so 0 is the expected value. Instead, you need to follow the following steps: insert the Group, insert a QueueSObject, then insert at least one Obj__c record with that OwnerId. Please note that the the Group and QueueSObject must be created inside a System.runAs block, because they are considered Setup Objects.



      Here's a demo from a unit test I wrote recently:



      @isTest static void test() {
      Group g = new Group(Name='TestQueue',Type='Queue');
      System.runas(new User(Id=UserInfo.getUserId()))
      insert g;
      insert new QueueSobject(QueueId=g.id, SObjectType='Lead');

      insert new lead(lastname='test',company='test');
      insert new lead(lastname='testqueue',company='testqueue',ownerid=g.Id);
      ...





      share|improve this answer
























        up vote
        3
        down vote













        You haven't inserted any records in to the queue yet, so 0 is the expected value. Instead, you need to follow the following steps: insert the Group, insert a QueueSObject, then insert at least one Obj__c record with that OwnerId. Please note that the the Group and QueueSObject must be created inside a System.runAs block, because they are considered Setup Objects.



        Here's a demo from a unit test I wrote recently:



        @isTest static void test() {
        Group g = new Group(Name='TestQueue',Type='Queue');
        System.runas(new User(Id=UserInfo.getUserId()))
        insert g;
        insert new QueueSobject(QueueId=g.id, SObjectType='Lead');

        insert new lead(lastname='test',company='test');
        insert new lead(lastname='testqueue',company='testqueue',ownerid=g.Id);
        ...





        share|improve this answer






















          up vote
          3
          down vote










          up vote
          3
          down vote









          You haven't inserted any records in to the queue yet, so 0 is the expected value. Instead, you need to follow the following steps: insert the Group, insert a QueueSObject, then insert at least one Obj__c record with that OwnerId. Please note that the the Group and QueueSObject must be created inside a System.runAs block, because they are considered Setup Objects.



          Here's a demo from a unit test I wrote recently:



          @isTest static void test() {
          Group g = new Group(Name='TestQueue',Type='Queue');
          System.runas(new User(Id=UserInfo.getUserId()))
          insert g;
          insert new QueueSobject(QueueId=g.id, SObjectType='Lead');

          insert new lead(lastname='test',company='test');
          insert new lead(lastname='testqueue',company='testqueue',ownerid=g.Id);
          ...





          share|improve this answer












          You haven't inserted any records in to the queue yet, so 0 is the expected value. Instead, you need to follow the following steps: insert the Group, insert a QueueSObject, then insert at least one Obj__c record with that OwnerId. Please note that the the Group and QueueSObject must be created inside a System.runAs block, because they are considered Setup Objects.



          Here's a demo from a unit test I wrote recently:



          @isTest static void test() {
          Group g = new Group(Name='TestQueue',Type='Queue');
          System.runas(new User(Id=UserInfo.getUserId()))
          insert g;
          insert new QueueSobject(QueueId=g.id, SObjectType='Lead');

          insert new lead(lastname='test',company='test');
          insert new lead(lastname='testqueue',company='testqueue',ownerid=g.Id);
          ...






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 hours ago









          sfdcfox

          227k10175389




          227k10175389






















              up vote
              0
              down vote













              Obj__c insert is missing, no records in it.



              Need to insert obj__c with ownerId set as the testGroup.Id






              share|improve this answer
























                up vote
                0
                down vote













                Obj__c insert is missing, no records in it.



                Need to insert obj__c with ownerId set as the testGroup.Id






                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  Obj__c insert is missing, no records in it.



                  Need to insert obj__c with ownerId set as the testGroup.Id






                  share|improve this answer












                  Obj__c insert is missing, no records in it.



                  Need to insert obj__c with ownerId set as the testGroup.Id







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 2 hours ago









                  sfdcFanBoy

                  2,82932458




                  2,82932458



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f232774%2fit-cant-see-my-queue-expected-0-actual-1%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Comments

                      Popular posts from this blog

                      Long meetings (6-7 hours a day): Being “babysat” by supervisor

                      Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                      Confectionery