Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Adding elements to mocked list

 
Ranch Hand
Posts: 113
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to unit test the method responsible for adding to map categorized books.



BookSerivceSource is an interface. This interface is implemented by two classes. I'm gonna provide just one, as the second is really similiar.

EmpikSource (one of implementation)



JsoupConnector:




Properties class:




While debugging the test I see that the sources size is 0. How should I add mocked object to the sources list or could you tell me if there is better way to do this?

Test



If adding elements to the list is bad choice, how it should be done?

Greetings,
Peter
 
Master Rancher
Posts: 4703
49
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you have mocked out the List then there isn't really a List sat behind it at all.
Why don't you just use a real List?
 
must Janik
Ranch Hand
Posts: 113
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave Tolls wrote:Since you have mocked out the List then there isn't really a List sat behind it at all.
Why don't you just use a real List?



You mean that I should pass the list via constructor?
 
Dave Tolls
Master Rancher
Posts: 4703
49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's the only thing that's autowired in then that would be simplest.
 
An elephant? An actual elephant. Into the apartment. How is the floor still here. Hold this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic