Solved

assert statement in junit for Map object

Posted on 2013-12-17
9
235 Views
Last Modified: 2014-02-07
@RunWith(SpringJUnit4ClassRunner.class)

@ContextConfiguration(classes=DifConfig.class, loader=AnnotationConfigContextLoader.class)
public class TestVendor {

	private Logger logger=Logger.getLogger(VendorService.class);

	@Inject
	transient private VendorService vendorService;
	@Test
	public void testVendorList() {

		Map<String, String> vendorList = vendorService.getVendorList();
		
	}
            

Open in new window



>>Map<String, String> vendorList = vendorService.getVendorList();


what kind of Assert statment i can write around above map object(vendorList ) which comes as result of get method call(getVendorList) on business service class(vendorService)

please advise
Any links resources ideas highly appreciated. Thanks in advance
0
Comment
Question by:gudii9
  • 6
  • 3
9 Comments
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 39725458
As I said in your other question, you will need to give us some idea about what "VendorService" is and what it does!

But in general, it will be in this form...
assertEquals("Expected value goes here", vendorList.get("key that returns the actual value to be tested"));

Open in new window

You need to put the appropriate values in the 2 strings in that statement. This 100% depends on what VendorService is, we can't tell you what to put in there. (Not without seeing the code/data associated with VendorService)
0
 
LVL 7

Author Comment

by:gudii9
ID: 39738609
Let us assume VendorService just has vendor information like VendorName, VendorNumber,VendorAddress, VendorPhone.
when some one search on Vendor number we can display that in search page
0
 
LVL 7

Author Comment

by:gudii9
ID: 39780681
please advise
0
 
LVL 35

Expert Comment

by:mccarl
ID: 39781017
What *exactly* is in the Map  vendorList after this line of code?
Map<String, String> vendorList = vendorService.getVendorList();

Open in new window

0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 7

Author Comment

by:gudii9
ID: 39797801
i just made up above test  case. I do not have anything after that line. Can we assume some kind of vedor details itself in the map? please advise
0
 
LVL 7

Author Comment

by:gudii9
ID: 39816240
What *exactly* is in the Map  vendorList after this line of code?

Open in new window


Are you expecting like what kind of vendor information like phone number, address or middle name etc details. Can you please advise
0
 
LVL 7

Author Comment

by:gudii9
ID: 39829777
Please advise
0
 
LVL 35

Assisted Solution

by:mccarl
mccarl earned 500 total points
ID: 39832254
What *exactly* is in the Map  vendorList after this line of code?
What I am asking, is if you put the following line of code just after the line where you retrieve your vendorList in the above junit testcase...
System.out.println(vendorList);

Open in new window

..what is the output that you get?
0
 
LVL 7

Author Comment

by:gudii9
ID: 39837297
I do not have actual map object since i just assumed this map myself. Is there is a way you can point to some link which discusses on writing assert statement on some sample map object. please advise
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now