Solved

assert statement in junit for Map object

Posted on 2013-12-17
9
236 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
topping1 challenge 7 73
mockito example issue 8 64
split string containing \r\n in Java 46 38
HTTPSessionBindingListernter not configured in deployment descriptor 2 40
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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 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…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

863 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

26 Experts available now in Live!

Get 1:1 Help Now