Solved

assert statement in junit for Map object

Posted on 2013-12-17
9
244 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 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
Containers and Docker for Everyone

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

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

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

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

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 had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

688 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