Solved

assert statement in junit for Map object

Posted on 2013-12-17
9
238 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
The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jar file executable 12 58
expectj telnet failing 5 45
Delete Android all or certain applications data programmatically 9 64
Java Eclipse Loop 3 20
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
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 …

809 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