• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

How to check equality of map in assertequals()

 
Ranch Hand
Posts: 157
Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am trying to test below method, which is throwing NPE. Please advice whats the cause of it.


Test case :

Exception is :

Thanks
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the error is happing on line 131. So it makes it much easier for people to help you if you tell us which line in getConfigProps corresponds to that line. Something on that line is null that shouldn't be. There won't be many candidates.

Without knowing the line, my first guess would be line 13 of the listing. What is the value of cryptoSupport on that line? When do you set it to anything other than null? You create a CryptoSupport mock in the test method, but it doesn't seem to get passed into the SalesforceLeadSearch1 object.
 
Marshal
Posts: 5003
319
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, can you indicate what line is 131 in your SalesforceLeadSearch1 class? You can do it with the code tags in the editor, just add the "firstline" param as I've shown below.

[code=java:firstline[24]]
  System.out.println("Hello World!");
[/code]

Or you can just tell us which line it is.
 
vivek dhiman
Ranch Hand
Posts: 157
Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Line 131 is Line 13 of listing
Here cryptoSupport is null.
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

vivek dhiman wrote:Line 131 is Line 13 of listing


It would seem cryptoSupport is null
 
vivek dhiman
Ranch Hand
Posts: 157
Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is function in SalesforceLeadSearch1.


I am trying to bind this with SalesforceLeadSearch1 object with below code.


Now NPE has been gone but still test gets fails.
 
Maneesh Godbole
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Confirm it is cryptoSupport which is null
2) Put in a null check OR
3) Ensure the object is not null
 
vivek dhiman
Ranch Hand
Posts: 157
Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes cryptoSupport was null, but i bind is with class object as mentioned above, now i can see this inside method Mock for CryptoSupport, hashCode: 777355268. Now there is no NPE. but collection are fail to compare as follows :
 
Tim Cooke
Marshal
Posts: 5003
319
IntelliJ IDE Python Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check the capitalisation on the map keys.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic