?
Solved

assert statement in junit for Map object

Posted on 2013-12-17
9
Medium Priority
?
247 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 36

Accepted Solution

by:
mccarl earned 2000 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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 36

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
 
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 36

Assisted Solution

by:mccarl
mccarl earned 2000 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

A new era in Cloud training has arrived.

A day that will go down in Cloud history.. But are you ready for it? Will you accept this Cloud challenge?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
A solution for Fortify Path Manipulation.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

770 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