Using wild card as a return type in JavaIs Java “pass-by-reference” or “pass-by-value”?Fastest way to determine if an integer's square root is an integerHow do I read / convert an InputStream into a String in Java?When to use LinkedList over ArrayList in Java?How do I generate random integers within a specific range in Java?How do I break out of nested loops in Java?How do I check if a file exists in Java?How to mock void methods with MockitoHow do I convert a String to an int in Java?Creating a memory leak with Java

What quests do you need to stop at before you make an enemy of a faction for each faction?

What drugs were used in England during the High Middle Ages?

Sinning and G-d's will, what's wrong with this logic?

How to calculate the power level of a Commander deck?

Are there mathematical concepts that exist in the fourth dimension, but not in the third dimension?

Was Rosie the Riveter sourced from a Michelangelo painting?

Could this estimate of the size and mass of the Chicxulub Impactor be accurate?

How do I write a vertically-stacked definition of a sequence?

What are some countries where you can be imprisoned for reading or owning a Bible?

Why would image resources loaded from different origins triggering HTTP authentication dialogs be harmful?

Why does 8 bit truecolor use only 2 bits for blue?

What are the solutions of this Diophantine equation?

Why did Boris Johnson call for new elections?

extract specific cheracters from each line

Is Sanskrit really the mother of all languages?

French equivalent of "my cup of tea"

"syntax error near unexpected token" after editing .bashrc

Temporarily simulate being offline programmatically

What can we do about our 9 month old putting fingers down his throat?

Remaining in the US beyond VWP admission period

How could a planet have one hemisphere way warmer than the other without the planet being tidally locked?

Pronounceable encrypted text

Looking for a big fantasy novel about scholarly monks that sort of worship math?

Why does the seven segment display have decimal point at the right?



Using wild card as a return type in Java


Is Java “pass-by-reference” or “pass-by-value”?Fastest way to determine if an integer's square root is an integerHow do I read / convert an InputStream into a String in Java?When to use LinkedList over ArrayList in Java?How do I generate random integers within a specific range in Java?How do I break out of nested loops in Java?How do I check if a file exists in Java?How to mock void methods with MockitoHow do I convert a String to an int in Java?Creating a memory leak with Java






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








0















Mockito.doReturn(true).when(a)
.isTest(Const.A,
Const.B);


In the above code cacheGet method returns a boolean value.(true/false)
I want to use a wildcard for that instead true or false.



Mockito.doReturn(?).when(a)
.isTest(Const.A,
Const.B);


I want to use the wildcard in place where '?' is.



How to do it in Java?










share|improve this question





















  • 2





    I don't understand your question. Either you want to return true when that method gets called, or you want to return false. What would you expect Mockito to do, as a result of you specifying the wildcard?

    – Dawood ibn Kareem
    Mar 28 at 5:04











  • I'm new to Mocking, but I don't get it. What do you expect to do with this? You're telling Mockito to return...what? --- ha! @DawoodibnKareem had the same idea, so I guess even newbie Mockito guy me kinda gets it. Coolio.

    – Steve
    Mar 28 at 5:05












  • ...this begs the question though...is there any way to tell Mockito to return something used or obtained elsewhere in the definition of your mock?

    – Steve
    Mar 28 at 5:07












  • what do you mean by 'wildcard'? Can you show an example?

    – Pavel Smirnov
    Mar 28 at 5:43











  • I want to write a expression valid for both true and false. Some wildcard which can use for either true or false

    – Nishara Kavindi
    Mar 28 at 5:53

















0















Mockito.doReturn(true).when(a)
.isTest(Const.A,
Const.B);


In the above code cacheGet method returns a boolean value.(true/false)
I want to use a wildcard for that instead true or false.



Mockito.doReturn(?).when(a)
.isTest(Const.A,
Const.B);


I want to use the wildcard in place where '?' is.



How to do it in Java?










share|improve this question





















  • 2





    I don't understand your question. Either you want to return true when that method gets called, or you want to return false. What would you expect Mockito to do, as a result of you specifying the wildcard?

    – Dawood ibn Kareem
    Mar 28 at 5:04











  • I'm new to Mocking, but I don't get it. What do you expect to do with this? You're telling Mockito to return...what? --- ha! @DawoodibnKareem had the same idea, so I guess even newbie Mockito guy me kinda gets it. Coolio.

    – Steve
    Mar 28 at 5:05












  • ...this begs the question though...is there any way to tell Mockito to return something used or obtained elsewhere in the definition of your mock?

    – Steve
    Mar 28 at 5:07












  • what do you mean by 'wildcard'? Can you show an example?

    – Pavel Smirnov
    Mar 28 at 5:43











  • I want to write a expression valid for both true and false. Some wildcard which can use for either true or false

    – Nishara Kavindi
    Mar 28 at 5:53













0












0








0


2






Mockito.doReturn(true).when(a)
.isTest(Const.A,
Const.B);


In the above code cacheGet method returns a boolean value.(true/false)
I want to use a wildcard for that instead true or false.



Mockito.doReturn(?).when(a)
.isTest(Const.A,
Const.B);


I want to use the wildcard in place where '?' is.



How to do it in Java?










share|improve this question
















Mockito.doReturn(true).when(a)
.isTest(Const.A,
Const.B);


In the above code cacheGet method returns a boolean value.(true/false)
I want to use a wildcard for that instead true or false.



Mockito.doReturn(?).when(a)
.isTest(Const.A,
Const.B);


I want to use the wildcard in place where '?' is.



How to do it in Java?







java mockito






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 26 at 6:49







Nishara Kavindi

















asked Mar 28 at 4:58









Nishara KavindiNishara Kavindi

328 bronze badges




328 bronze badges










  • 2





    I don't understand your question. Either you want to return true when that method gets called, or you want to return false. What would you expect Mockito to do, as a result of you specifying the wildcard?

    – Dawood ibn Kareem
    Mar 28 at 5:04











  • I'm new to Mocking, but I don't get it. What do you expect to do with this? You're telling Mockito to return...what? --- ha! @DawoodibnKareem had the same idea, so I guess even newbie Mockito guy me kinda gets it. Coolio.

    – Steve
    Mar 28 at 5:05












  • ...this begs the question though...is there any way to tell Mockito to return something used or obtained elsewhere in the definition of your mock?

    – Steve
    Mar 28 at 5:07












  • what do you mean by 'wildcard'? Can you show an example?

    – Pavel Smirnov
    Mar 28 at 5:43











  • I want to write a expression valid for both true and false. Some wildcard which can use for either true or false

    – Nishara Kavindi
    Mar 28 at 5:53












  • 2





    I don't understand your question. Either you want to return true when that method gets called, or you want to return false. What would you expect Mockito to do, as a result of you specifying the wildcard?

    – Dawood ibn Kareem
    Mar 28 at 5:04











  • I'm new to Mocking, but I don't get it. What do you expect to do with this? You're telling Mockito to return...what? --- ha! @DawoodibnKareem had the same idea, so I guess even newbie Mockito guy me kinda gets it. Coolio.

    – Steve
    Mar 28 at 5:05












  • ...this begs the question though...is there any way to tell Mockito to return something used or obtained elsewhere in the definition of your mock?

    – Steve
    Mar 28 at 5:07












  • what do you mean by 'wildcard'? Can you show an example?

    – Pavel Smirnov
    Mar 28 at 5:43











  • I want to write a expression valid for both true and false. Some wildcard which can use for either true or false

    – Nishara Kavindi
    Mar 28 at 5:53







2




2





I don't understand your question. Either you want to return true when that method gets called, or you want to return false. What would you expect Mockito to do, as a result of you specifying the wildcard?

– Dawood ibn Kareem
Mar 28 at 5:04





I don't understand your question. Either you want to return true when that method gets called, or you want to return false. What would you expect Mockito to do, as a result of you specifying the wildcard?

– Dawood ibn Kareem
Mar 28 at 5:04













I'm new to Mocking, but I don't get it. What do you expect to do with this? You're telling Mockito to return...what? --- ha! @DawoodibnKareem had the same idea, so I guess even newbie Mockito guy me kinda gets it. Coolio.

– Steve
Mar 28 at 5:05






I'm new to Mocking, but I don't get it. What do you expect to do with this? You're telling Mockito to return...what? --- ha! @DawoodibnKareem had the same idea, so I guess even newbie Mockito guy me kinda gets it. Coolio.

– Steve
Mar 28 at 5:05














...this begs the question though...is there any way to tell Mockito to return something used or obtained elsewhere in the definition of your mock?

– Steve
Mar 28 at 5:07






...this begs the question though...is there any way to tell Mockito to return something used or obtained elsewhere in the definition of your mock?

– Steve
Mar 28 at 5:07














what do you mean by 'wildcard'? Can you show an example?

– Pavel Smirnov
Mar 28 at 5:43





what do you mean by 'wildcard'? Can you show an example?

– Pavel Smirnov
Mar 28 at 5:43













I want to write a expression valid for both true and false. Some wildcard which can use for either true or false

– Nishara Kavindi
Mar 28 at 5:53





I want to write a expression valid for both true and false. Some wildcard which can use for either true or false

– Nishara Kavindi
Mar 28 at 5:53












2 Answers
2






active

oldest

votes


















1
















try this



String wildcard="";



if(true)



wildcard = //wildcard for true





else



wildcard = //wildcard for false








share|improve this answer
































    1
















    Your code



    Mockito.doReturn(true).when(cacheAdaptorCore)
    .cacheGet(OMSConst.DEFAULT_TENANCY_CODE,
    OMSConst.APP_PARAM_DECIMAL_FORMATTER,
    CACHE_NAMES.SYS_PARAMS_CACHE_CORE);


    tells Mockito, "Hey Mockito, if, during the following test, somehow the method cacheAdapterCore.cacheGet() is called with the parameters OMSConst..., do not really call the method, but instead make the code believe that the method returns true."



    Now try the same sentence with "... make the code believe that the method returns ???"



    See, it makes no sense.



    If you want to do different tests and for some you want the method to return true, and for others you want it to return false, then you have to write separate test methods and within them, tell Mockito to return true resp. false.






    share|improve this answer





























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      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',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );














      draft saved

      draft discarded
















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55390452%2fusing-wild-card-as-a-return-type-in-java%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1
















      try this



      String wildcard="";



      if(true)



      wildcard = //wildcard for true





      else



      wildcard = //wildcard for false








      share|improve this answer





























        1
















        try this



        String wildcard="";



        if(true)



        wildcard = //wildcard for true





        else



        wildcard = //wildcard for false








        share|improve this answer



























          1














          1










          1









          try this



          String wildcard="";



          if(true)



          wildcard = //wildcard for true





          else



          wildcard = //wildcard for false








          share|improve this answer













          try this



          String wildcard="";



          if(true)



          wildcard = //wildcard for true





          else



          wildcard = //wildcard for false









          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 28 at 5:59









          Rajeev RanjanRajeev Ranjan

          1902 silver badges13 bronze badges




          1902 silver badges13 bronze badges


























              1
















              Your code



              Mockito.doReturn(true).when(cacheAdaptorCore)
              .cacheGet(OMSConst.DEFAULT_TENANCY_CODE,
              OMSConst.APP_PARAM_DECIMAL_FORMATTER,
              CACHE_NAMES.SYS_PARAMS_CACHE_CORE);


              tells Mockito, "Hey Mockito, if, during the following test, somehow the method cacheAdapterCore.cacheGet() is called with the parameters OMSConst..., do not really call the method, but instead make the code believe that the method returns true."



              Now try the same sentence with "... make the code believe that the method returns ???"



              See, it makes no sense.



              If you want to do different tests and for some you want the method to return true, and for others you want it to return false, then you have to write separate test methods and within them, tell Mockito to return true resp. false.






              share|improve this answer































                1
















                Your code



                Mockito.doReturn(true).when(cacheAdaptorCore)
                .cacheGet(OMSConst.DEFAULT_TENANCY_CODE,
                OMSConst.APP_PARAM_DECIMAL_FORMATTER,
                CACHE_NAMES.SYS_PARAMS_CACHE_CORE);


                tells Mockito, "Hey Mockito, if, during the following test, somehow the method cacheAdapterCore.cacheGet() is called with the parameters OMSConst..., do not really call the method, but instead make the code believe that the method returns true."



                Now try the same sentence with "... make the code believe that the method returns ???"



                See, it makes no sense.



                If you want to do different tests and for some you want the method to return true, and for others you want it to return false, then you have to write separate test methods and within them, tell Mockito to return true resp. false.






                share|improve this answer





























                  1














                  1










                  1









                  Your code



                  Mockito.doReturn(true).when(cacheAdaptorCore)
                  .cacheGet(OMSConst.DEFAULT_TENANCY_CODE,
                  OMSConst.APP_PARAM_DECIMAL_FORMATTER,
                  CACHE_NAMES.SYS_PARAMS_CACHE_CORE);


                  tells Mockito, "Hey Mockito, if, during the following test, somehow the method cacheAdapterCore.cacheGet() is called with the parameters OMSConst..., do not really call the method, but instead make the code believe that the method returns true."



                  Now try the same sentence with "... make the code believe that the method returns ???"



                  See, it makes no sense.



                  If you want to do different tests and for some you want the method to return true, and for others you want it to return false, then you have to write separate test methods and within them, tell Mockito to return true resp. false.






                  share|improve this answer















                  Your code



                  Mockito.doReturn(true).when(cacheAdaptorCore)
                  .cacheGet(OMSConst.DEFAULT_TENANCY_CODE,
                  OMSConst.APP_PARAM_DECIMAL_FORMATTER,
                  CACHE_NAMES.SYS_PARAMS_CACHE_CORE);


                  tells Mockito, "Hey Mockito, if, during the following test, somehow the method cacheAdapterCore.cacheGet() is called with the parameters OMSConst..., do not really call the method, but instead make the code believe that the method returns true."



                  Now try the same sentence with "... make the code believe that the method returns ???"



                  See, it makes no sense.



                  If you want to do different tests and for some you want the method to return true, and for others you want it to return false, then you have to write separate test methods and within them, tell Mockito to return true resp. false.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Aug 26 at 6:55









                  Dino

                  2,5293 gold badges16 silver badges39 bronze badges




                  2,5293 gold badges16 silver badges39 bronze badges










                  answered Mar 28 at 6:16









                  RidcullyRidcully

                  19.4k7 gold badges56 silver badges73 bronze badges




                  19.4k7 gold badges56 silver badges73 bronze badges































                      draft saved

                      draft discarded















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55390452%2fusing-wild-card-as-a-return-type-in-java%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                      SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                      은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현