How to mock list method using MockitoHow do I test a private function or a class that has private methods, fields or inner classes?How do I read / convert an InputStream into a String in Java?How do I generate random integers within a specific range in Java?How to make mock to void methods with mockitoHow to deserialize a list using GSON or another JSON library in Java?How do I convert a String to an int in Java?Testing Private method using mockitoHow to verify that a specific method was not called using Mockito?Use Mockito to mock some methods but not othersMocking static methods with Mockito

Taking the numerator and the denominator

Strange behavior in TikZ draw command

How to preserve electronics (computers, ipads, phones) for hundreds of years?

Put the phone down / Put down the phone

Trouble reading roman numeral notation with flats

Has the laser at Magurele, Romania reached the tenth of the Sun power?

Air travel with refrigerated insulin

How do I lift the insulation blower into the attic?

Is there any common country to visit for persons holding UK and Schengen visas?

Amorphous proper classes in MK

Hashing password to increase entropy

Magnifying glass in hyperbolic space

Why is indicated airspeed rather than ground speed used during the takeoff roll?

What properties make a magic weapon befit a Rogue more than a DEX-based Fighter?

Exposing a company lying about themselves in a tightly knit industry (videogames) : Is my career at risk on the long run?

Should a narrator ever describe things based on a character's view instead of facts?

Would a primitive species be able to learn English from reading books alone?

Why doesn't Gödel's incompleteness theorem apply to false statements?

What is this high flying aircraft over Pennsylvania?

Reasons for having MCU pin-states default to pull-up/down out of reset

1 John in Luther’s Bibel

Why does a 97 / 92 key piano exist by Bosendorfer?

What is it called when someone votes for an option that's not their first choice?

What is the period/term used describe Giuseppe Arcimboldo's style of painting?



How to mock list method using Mockito


How do I test a private function or a class that has private methods, fields or inner classes?How do I read / convert an InputStream into a String in Java?How do I generate random integers within a specific range in Java?How to make mock to void methods with mockitoHow to deserialize a list using GSON or another JSON library in Java?How do I convert a String to an int in Java?Testing Private method using mockitoHow to verify that a specific method was not called using Mockito?Use Mockito to mock some methods but not othersMocking static methods with Mockito













0















I have a service class which calls Repository method and which returns a List. Now I want to mock it. My unit test scenario would be following:



  • Add some mock objects to mock repository

  • Query service class which returns the list of mocked objects

  • Assert List size

My repository class:



import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface FoodRepository extends CrudRepository<Food, Long>

@Query(value = "SELECT * FROM FOOD WHERE FRESH = 1", nativeQuery = true)
public List<Food> getMostFreshestFoods();



My service class:



import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FoodService

@Autowired
private FoodRepository foodRepository;

public List<Food> getMostFreshestFoods()
return foodRepository.getMostFreshestFoods();




My object class:



public class Food 

private Long id;

private String foodName;

private boolean fresh;

public Long getId()
return id;


public void setId(Long id)
this.id = id;


public String getFoodName()
return foodName;


public void setFoodName(String foodName)
this.foodName = foodName;


public boolean isFresh()
return fresh;


public void setFresh(boolean fresh)
this.fresh = fresh;




And my test class:



import myapp.Food;
import myapp.FoodRepository;
import myapp.FoodService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;

import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.verify;

@RunWith(MockitoJUnitRunner.class)
public class FoodTest

@Mock
private FoodRepository foodRepository;

@InjectMocks
private FoodService foodService;

@Captor
private ArgumentCaptor<Food> foodArgumentCaptor;

@Test
public void testFreshestFoods()

Food food = new Food();
food.setFoodName("Meat");
food.setFresh(true);
foodRepository.save(food);
verify(foodRepository).save(foodArgumentCaptor.capture());
assertThat(foodArgumentCaptor.getValue().getId(), is(notNullValue()));

// Above I added mock data to database to query list from Service class method,
// but I do not know how to do it. Using return always gives error

// I want to do the following: Query the list from FoodService class and it should
// return size 1 (the fake object (added above) )







But since I am new to Mockito, it is a bit difficult to me. I would like to know how can I get the list from FoodService class and it should return the fake object made in test class.










share|improve this question


























    0















    I have a service class which calls Repository method and which returns a List. Now I want to mock it. My unit test scenario would be following:



    • Add some mock objects to mock repository

    • Query service class which returns the list of mocked objects

    • Assert List size

    My repository class:



    import org.springframework.data.jpa.repository.Query;
    import org.springframework.data.repository.CrudRepository;

    import java.util.List;

    public interface FoodRepository extends CrudRepository<Food, Long>

    @Query(value = "SELECT * FROM FOOD WHERE FRESH = 1", nativeQuery = true)
    public List<Food> getMostFreshestFoods();



    My service class:



    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;

    import java.util.List;

    @Service
    public class FoodService

    @Autowired
    private FoodRepository foodRepository;

    public List<Food> getMostFreshestFoods()
    return foodRepository.getMostFreshestFoods();




    My object class:



    public class Food 

    private Long id;

    private String foodName;

    private boolean fresh;

    public Long getId()
    return id;


    public void setId(Long id)
    this.id = id;


    public String getFoodName()
    return foodName;


    public void setFoodName(String foodName)
    this.foodName = foodName;


    public boolean isFresh()
    return fresh;


    public void setFresh(boolean fresh)
    this.fresh = fresh;




    And my test class:



    import myapp.Food;
    import myapp.FoodRepository;
    import myapp.FoodService;
    import org.junit.Test;
    import org.junit.runner.RunWith;
    import org.mockito.ArgumentCaptor;
    import org.mockito.Captor;
    import org.mockito.InjectMocks;
    import org.mockito.Mock;
    import org.mockito.junit.MockitoJUnitRunner;

    import static org.hamcrest.core.Is.is;
    import static org.hamcrest.core.IsNull.notNullValue;
    import static org.junit.Assert.assertThat;
    import static org.mockito.Mockito.verify;

    @RunWith(MockitoJUnitRunner.class)
    public class FoodTest

    @Mock
    private FoodRepository foodRepository;

    @InjectMocks
    private FoodService foodService;

    @Captor
    private ArgumentCaptor<Food> foodArgumentCaptor;

    @Test
    public void testFreshestFoods()

    Food food = new Food();
    food.setFoodName("Meat");
    food.setFresh(true);
    foodRepository.save(food);
    verify(foodRepository).save(foodArgumentCaptor.capture());
    assertThat(foodArgumentCaptor.getValue().getId(), is(notNullValue()));

    // Above I added mock data to database to query list from Service class method,
    // but I do not know how to do it. Using return always gives error

    // I want to do the following: Query the list from FoodService class and it should
    // return size 1 (the fake object (added above) )







    But since I am new to Mockito, it is a bit difficult to me. I would like to know how can I get the list from FoodService class and it should return the fake object made in test class.










    share|improve this question
























      0












      0








      0








      I have a service class which calls Repository method and which returns a List. Now I want to mock it. My unit test scenario would be following:



      • Add some mock objects to mock repository

      • Query service class which returns the list of mocked objects

      • Assert List size

      My repository class:



      import org.springframework.data.jpa.repository.Query;
      import org.springframework.data.repository.CrudRepository;

      import java.util.List;

      public interface FoodRepository extends CrudRepository<Food, Long>

      @Query(value = "SELECT * FROM FOOD WHERE FRESH = 1", nativeQuery = true)
      public List<Food> getMostFreshestFoods();



      My service class:



      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.stereotype.Service;

      import java.util.List;

      @Service
      public class FoodService

      @Autowired
      private FoodRepository foodRepository;

      public List<Food> getMostFreshestFoods()
      return foodRepository.getMostFreshestFoods();




      My object class:



      public class Food 

      private Long id;

      private String foodName;

      private boolean fresh;

      public Long getId()
      return id;


      public void setId(Long id)
      this.id = id;


      public String getFoodName()
      return foodName;


      public void setFoodName(String foodName)
      this.foodName = foodName;


      public boolean isFresh()
      return fresh;


      public void setFresh(boolean fresh)
      this.fresh = fresh;




      And my test class:



      import myapp.Food;
      import myapp.FoodRepository;
      import myapp.FoodService;
      import org.junit.Test;
      import org.junit.runner.RunWith;
      import org.mockito.ArgumentCaptor;
      import org.mockito.Captor;
      import org.mockito.InjectMocks;
      import org.mockito.Mock;
      import org.mockito.junit.MockitoJUnitRunner;

      import static org.hamcrest.core.Is.is;
      import static org.hamcrest.core.IsNull.notNullValue;
      import static org.junit.Assert.assertThat;
      import static org.mockito.Mockito.verify;

      @RunWith(MockitoJUnitRunner.class)
      public class FoodTest

      @Mock
      private FoodRepository foodRepository;

      @InjectMocks
      private FoodService foodService;

      @Captor
      private ArgumentCaptor<Food> foodArgumentCaptor;

      @Test
      public void testFreshestFoods()

      Food food = new Food();
      food.setFoodName("Meat");
      food.setFresh(true);
      foodRepository.save(food);
      verify(foodRepository).save(foodArgumentCaptor.capture());
      assertThat(foodArgumentCaptor.getValue().getId(), is(notNullValue()));

      // Above I added mock data to database to query list from Service class method,
      // but I do not know how to do it. Using return always gives error

      // I want to do the following: Query the list from FoodService class and it should
      // return size 1 (the fake object (added above) )







      But since I am new to Mockito, it is a bit difficult to me. I would like to know how can I get the list from FoodService class and it should return the fake object made in test class.










      share|improve this question














      I have a service class which calls Repository method and which returns a List. Now I want to mock it. My unit test scenario would be following:



      • Add some mock objects to mock repository

      • Query service class which returns the list of mocked objects

      • Assert List size

      My repository class:



      import org.springframework.data.jpa.repository.Query;
      import org.springframework.data.repository.CrudRepository;

      import java.util.List;

      public interface FoodRepository extends CrudRepository<Food, Long>

      @Query(value = "SELECT * FROM FOOD WHERE FRESH = 1", nativeQuery = true)
      public List<Food> getMostFreshestFoods();



      My service class:



      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.stereotype.Service;

      import java.util.List;

      @Service
      public class FoodService

      @Autowired
      private FoodRepository foodRepository;

      public List<Food> getMostFreshestFoods()
      return foodRepository.getMostFreshestFoods();




      My object class:



      public class Food 

      private Long id;

      private String foodName;

      private boolean fresh;

      public Long getId()
      return id;


      public void setId(Long id)
      this.id = id;


      public String getFoodName()
      return foodName;


      public void setFoodName(String foodName)
      this.foodName = foodName;


      public boolean isFresh()
      return fresh;


      public void setFresh(boolean fresh)
      this.fresh = fresh;




      And my test class:



      import myapp.Food;
      import myapp.FoodRepository;
      import myapp.FoodService;
      import org.junit.Test;
      import org.junit.runner.RunWith;
      import org.mockito.ArgumentCaptor;
      import org.mockito.Captor;
      import org.mockito.InjectMocks;
      import org.mockito.Mock;
      import org.mockito.junit.MockitoJUnitRunner;

      import static org.hamcrest.core.Is.is;
      import static org.hamcrest.core.IsNull.notNullValue;
      import static org.junit.Assert.assertThat;
      import static org.mockito.Mockito.verify;

      @RunWith(MockitoJUnitRunner.class)
      public class FoodTest

      @Mock
      private FoodRepository foodRepository;

      @InjectMocks
      private FoodService foodService;

      @Captor
      private ArgumentCaptor<Food> foodArgumentCaptor;

      @Test
      public void testFreshestFoods()

      Food food = new Food();
      food.setFoodName("Meat");
      food.setFresh(true);
      foodRepository.save(food);
      verify(foodRepository).save(foodArgumentCaptor.capture());
      assertThat(foodArgumentCaptor.getValue().getId(), is(notNullValue()));

      // Above I added mock data to database to query list from Service class method,
      // but I do not know how to do it. Using return always gives error

      // I want to do the following: Query the list from FoodService class and it should
      // return size 1 (the fake object (added above) )







      But since I am new to Mockito, it is a bit difficult to me. I would like to know how can I get the list from FoodService class and it should return the fake object made in test class.







      java unit-testing mockito






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 7 at 1:09









      Omaja7Omaja7

      468




      468






















          1 Answer
          1






          active

          oldest

          votes


















          1














          I believe what you are looking for is below. You don't need to do a normal workflow to test with Mockito. Another way to say is you don't add things to your DB then expect to get them back. Mockito doesn't know databases. It takes over a class (the mocked one) and returns things you tell it to or throws exceptions or just does nothing. The idea is to isolate the class under test. So in your case, pretend the data is in the repository and just mock returning it. Hope that makes sense.



          import org.junit.Test;
          import org.junit.runner.RunWith;
          import org.mockito.ArgumentCaptor;
          import org.mockito.Captor;
          import org.mockito.InjectMocks;
          import org.mockito.Mock;
          import org.mockito.runners.MockitoJUnitRunner;

          import java.util.List;

          import static java.util.Arrays.asList;
          import static org.junit.Assert.assertEquals;
          import static org.mockito.Mockito.verify;
          import static org.mockito.Mockito.when;

          @RunWith(MockitoJUnitRunner.class)
          public class FoodTest

          @Mock
          private FoodRepository foodRepository;

          @InjectMocks
          private FoodService foodService;

          @Captor
          private ArgumentCaptor<Food> foodArgumentCaptor;

          @Test
          public void testFreshestFoods()

          Food food = new Food();
          food.setFoodName("Meat");
          food.setFresh(true);

          // not needed
          //foodRepository.save(food);
          //verify(foodRepository).save(foodArgumentCaptor.capture());
          //assertThat(foodArgumentCaptor.getValue().getId(), is(notNullValue()));

          when(foodRepository.getMostFreshestFoods()).thenReturn(asList(food));

          List<Food> actual = foodService.getMostFreshestFoods();

          assertEquals(food, actual.get(0));
          verify(foodRepository).getMostFreshestFoods();







          share|improve this answer























          • Okay. I guess it makes sense to me. But thank you for your input and I grant you an upvote.

            – Omaja7
            Mar 7 at 7:36










          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/3.0/"u003ecc by-sa 3.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%2f55034575%2fhow-to-mock-list-method-using-mockito%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          I believe what you are looking for is below. You don't need to do a normal workflow to test with Mockito. Another way to say is you don't add things to your DB then expect to get them back. Mockito doesn't know databases. It takes over a class (the mocked one) and returns things you tell it to or throws exceptions or just does nothing. The idea is to isolate the class under test. So in your case, pretend the data is in the repository and just mock returning it. Hope that makes sense.



          import org.junit.Test;
          import org.junit.runner.RunWith;
          import org.mockito.ArgumentCaptor;
          import org.mockito.Captor;
          import org.mockito.InjectMocks;
          import org.mockito.Mock;
          import org.mockito.runners.MockitoJUnitRunner;

          import java.util.List;

          import static java.util.Arrays.asList;
          import static org.junit.Assert.assertEquals;
          import static org.mockito.Mockito.verify;
          import static org.mockito.Mockito.when;

          @RunWith(MockitoJUnitRunner.class)
          public class FoodTest

          @Mock
          private FoodRepository foodRepository;

          @InjectMocks
          private FoodService foodService;

          @Captor
          private ArgumentCaptor<Food> foodArgumentCaptor;

          @Test
          public void testFreshestFoods()

          Food food = new Food();
          food.setFoodName("Meat");
          food.setFresh(true);

          // not needed
          //foodRepository.save(food);
          //verify(foodRepository).save(foodArgumentCaptor.capture());
          //assertThat(foodArgumentCaptor.getValue().getId(), is(notNullValue()));

          when(foodRepository.getMostFreshestFoods()).thenReturn(asList(food));

          List<Food> actual = foodService.getMostFreshestFoods();

          assertEquals(food, actual.get(0));
          verify(foodRepository).getMostFreshestFoods();







          share|improve this answer























          • Okay. I guess it makes sense to me. But thank you for your input and I grant you an upvote.

            – Omaja7
            Mar 7 at 7:36















          1














          I believe what you are looking for is below. You don't need to do a normal workflow to test with Mockito. Another way to say is you don't add things to your DB then expect to get them back. Mockito doesn't know databases. It takes over a class (the mocked one) and returns things you tell it to or throws exceptions or just does nothing. The idea is to isolate the class under test. So in your case, pretend the data is in the repository and just mock returning it. Hope that makes sense.



          import org.junit.Test;
          import org.junit.runner.RunWith;
          import org.mockito.ArgumentCaptor;
          import org.mockito.Captor;
          import org.mockito.InjectMocks;
          import org.mockito.Mock;
          import org.mockito.runners.MockitoJUnitRunner;

          import java.util.List;

          import static java.util.Arrays.asList;
          import static org.junit.Assert.assertEquals;
          import static org.mockito.Mockito.verify;
          import static org.mockito.Mockito.when;

          @RunWith(MockitoJUnitRunner.class)
          public class FoodTest

          @Mock
          private FoodRepository foodRepository;

          @InjectMocks
          private FoodService foodService;

          @Captor
          private ArgumentCaptor<Food> foodArgumentCaptor;

          @Test
          public void testFreshestFoods()

          Food food = new Food();
          food.setFoodName("Meat");
          food.setFresh(true);

          // not needed
          //foodRepository.save(food);
          //verify(foodRepository).save(foodArgumentCaptor.capture());
          //assertThat(foodArgumentCaptor.getValue().getId(), is(notNullValue()));

          when(foodRepository.getMostFreshestFoods()).thenReturn(asList(food));

          List<Food> actual = foodService.getMostFreshestFoods();

          assertEquals(food, actual.get(0));
          verify(foodRepository).getMostFreshestFoods();







          share|improve this answer























          • Okay. I guess it makes sense to me. But thank you for your input and I grant you an upvote.

            – Omaja7
            Mar 7 at 7:36













          1












          1








          1







          I believe what you are looking for is below. You don't need to do a normal workflow to test with Mockito. Another way to say is you don't add things to your DB then expect to get them back. Mockito doesn't know databases. It takes over a class (the mocked one) and returns things you tell it to or throws exceptions or just does nothing. The idea is to isolate the class under test. So in your case, pretend the data is in the repository and just mock returning it. Hope that makes sense.



          import org.junit.Test;
          import org.junit.runner.RunWith;
          import org.mockito.ArgumentCaptor;
          import org.mockito.Captor;
          import org.mockito.InjectMocks;
          import org.mockito.Mock;
          import org.mockito.runners.MockitoJUnitRunner;

          import java.util.List;

          import static java.util.Arrays.asList;
          import static org.junit.Assert.assertEquals;
          import static org.mockito.Mockito.verify;
          import static org.mockito.Mockito.when;

          @RunWith(MockitoJUnitRunner.class)
          public class FoodTest

          @Mock
          private FoodRepository foodRepository;

          @InjectMocks
          private FoodService foodService;

          @Captor
          private ArgumentCaptor<Food> foodArgumentCaptor;

          @Test
          public void testFreshestFoods()

          Food food = new Food();
          food.setFoodName("Meat");
          food.setFresh(true);

          // not needed
          //foodRepository.save(food);
          //verify(foodRepository).save(foodArgumentCaptor.capture());
          //assertThat(foodArgumentCaptor.getValue().getId(), is(notNullValue()));

          when(foodRepository.getMostFreshestFoods()).thenReturn(asList(food));

          List<Food> actual = foodService.getMostFreshestFoods();

          assertEquals(food, actual.get(0));
          verify(foodRepository).getMostFreshestFoods();







          share|improve this answer













          I believe what you are looking for is below. You don't need to do a normal workflow to test with Mockito. Another way to say is you don't add things to your DB then expect to get them back. Mockito doesn't know databases. It takes over a class (the mocked one) and returns things you tell it to or throws exceptions or just does nothing. The idea is to isolate the class under test. So in your case, pretend the data is in the repository and just mock returning it. Hope that makes sense.



          import org.junit.Test;
          import org.junit.runner.RunWith;
          import org.mockito.ArgumentCaptor;
          import org.mockito.Captor;
          import org.mockito.InjectMocks;
          import org.mockito.Mock;
          import org.mockito.runners.MockitoJUnitRunner;

          import java.util.List;

          import static java.util.Arrays.asList;
          import static org.junit.Assert.assertEquals;
          import static org.mockito.Mockito.verify;
          import static org.mockito.Mockito.when;

          @RunWith(MockitoJUnitRunner.class)
          public class FoodTest

          @Mock
          private FoodRepository foodRepository;

          @InjectMocks
          private FoodService foodService;

          @Captor
          private ArgumentCaptor<Food> foodArgumentCaptor;

          @Test
          public void testFreshestFoods()

          Food food = new Food();
          food.setFoodName("Meat");
          food.setFresh(true);

          // not needed
          //foodRepository.save(food);
          //verify(foodRepository).save(foodArgumentCaptor.capture());
          //assertThat(foodArgumentCaptor.getValue().getId(), is(notNullValue()));

          when(foodRepository.getMostFreshestFoods()).thenReturn(asList(food));

          List<Food> actual = foodService.getMostFreshestFoods();

          assertEquals(food, actual.get(0));
          verify(foodRepository).getMostFreshestFoods();








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 7 at 2:28









          DCTIDDCTID

          15915




          15915












          • Okay. I guess it makes sense to me. But thank you for your input and I grant you an upvote.

            – Omaja7
            Mar 7 at 7:36

















          • Okay. I guess it makes sense to me. But thank you for your input and I grant you an upvote.

            – Omaja7
            Mar 7 at 7:36
















          Okay. I guess it makes sense to me. But thank you for your input and I grant you an upvote.

          – Omaja7
          Mar 7 at 7:36





          Okay. I guess it makes sense to me. But thank you for your input and I grant you an upvote.

          – Omaja7
          Mar 7 at 7:36



















          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%2f55034575%2fhow-to-mock-list-method-using-mockito%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

          Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

          Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

          Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved