When I am accessing my class to test the methods, I am getting exceptions every time I try to define a new object and use the newly defined object.
Tests in error:
UserInformationControllerTest.deleteUser:83 » NullPointer
UserInformationControllerTest.getUserInfo:27 » NullPointer
UserInformationControllerTest.updateUserInfo:68 » NullPointer
UserOrderControllerTest.createUserOrder:60 » NoSuchElement
UserOrderControllerTest.getUserOrder:47 » NullPointer
UserOrderControllerTest.updateUserOrder:85 » NullPointer
My assignment is to make 4 happy cases and 4 unhappy cases for each class
I am thoroughly confused.
My test class for UserInformation
private HashMap<Integer,UserInformation> userInformationHashMap;
#Test
public void getUserInfo(){
UserInformationController userInformationController = new UserInformationController();
this.userInformationHashMap = new HashMap<>();
int user0 = 0;
int user1 = 1;
UserInformation userInformation0 = new UserInformation("Doug","Jones", "djones#gmail.com","17073");
UserInformation userInformation1 = new UserInformation("Natalie","Peirce", "nataliepeirce12#yahoo.com","dynamicrabbit");
this.userInformationHashMap.put(user0,userInformation0);
this.userInformationHashMap.put(user1,userInformation1);
userInformationController.getUserInfo(user0);
userInformationController.getUserInfo(user1);
Assert.assertEquals(userInformationController.getUserInfo(user0),userInformationController.getUserInfo(user1)); //False
Assert.assertNotEquals(user0,user1); //True
}
#Test
public void createUser(){
UserInformationController userInformationController = new UserInformationController();
this.userInformationHashMap = new HashMap<>();
UserInformation userInformation0 = new UserInformation("Troy","Green","tjg217#verizon.com","2012hummingbirds");
UserInformation userInformation1 = new UserInformation("Sierra", "West","themostimportantwest#msn.com","shadeyglasses77");
int user0 = userInformationController.createUser(userInformation0);//Can you tell me why this does not work
int user1 = userInformationController.createUser(userInformation1);//Can you tell me why this does not work
this.userInformationHashMap.put(user0, userInformation0);
this.userInformationHashMap.put(user1, userInformation1);
Assert.assertNotEquals(this.userInformationHashMap.get(user0),this.userInformationHashMap.get(user1)); //True
Assert.assertNotNull(this.userInformationHashMap.get(user0)); //False
}
#Test
public void updateUserInfo(){
UserInformationController userInformationController = new UserInformationController();
this.userInformationHashMap = new HashMap<>();
int userId = 0;
UserInformation userInformation = new UserInformation("Nicole", "Rigby", "sexygirl69#babellon.com","throwmethemoney");
UserInformation newUserInformation = new UserInformation("Kitty", "Morgan", "ilovecats#cats.com","cats");
this.userInformationHashMap.put(userId,userInformation);
Assert.assertEquals(this.userInformationHashMap.get(userId),userInformation); //True
userInformationController.updateUserInfo(userId,newUserInformation); //Can you tell me why this does not work
Assert.assertNotEquals(this.userInformationHashMap.get(userId),newUserInformation); //False
}
#Test
public void deleteUser(){
UserInformationController userInformationController = new UserInformationController();
this.userInformationHashMap = new HashMap<>();
int user = 0;
UserInformation userInformation = new UserInformation("Camryn","Resele","smartcookie#email.com","28564088");
this.userInformationHashMap.put(user,userInformation);
userInformationController.deleteUser(user);
Assert.assertNull(this.userInformationHashMap.get(user)); //True
Assert.assertTrue(this.userInformationHashMap.containsKey(user)); //False
}
}
UserInformationController
private HashMap<Integer,UserInformation> userInformationHashMap;
/**
* Default json constructor`enter code here`
* #return new user object
*/
#GetMapping(path = "/defaultUserInformation")
public UserInformation test()
{
return new UserInformation("fname", "lname", "email", "pass");
}
/**
* Gets the users information
* #return users information
*/
#GetMapping (path = "/userInfo")
public UserInformation getUserInfo(#RequestParam ("id") int id){
return userInformationHashMap.get(id);
}
/**
* Sets the users information
* #param userInformation userInformation model
* #return users key
*/
#PostMapping (path = "/createUser")
public int createUser(#RequestBody UserInformation userInformation){
if(this.userInformationHashMap == null){
this.userInformationHashMap = new HashMap<>();
}
int maxKey = 0;
if(this.userInformationHashMap.size() != 0){
maxKey = Collections.max(this.userInformationHashMap.keySet()) + 1;
}
this.userInformationHashMap.put(maxKey,userInformation);
return maxKey;
}
#PutMapping (path = "/updateUserInfo")
public void updateUserInfo(#RequestParam ("id") int id, #RequestBody UserInformation userInformation) {
if (this.userInformationHashMap.containsKey(id)) {
this.userInformationHashMap.put(id, userInformation);
}
}
#DeleteMapping (path = "/deleteUser")
public void deleteUser(#RequestParam ("id") int id){
this.userInformationHashMap.remove(id);
}
}
userInformationHashMap within UserInformationController is never initialized, this is why you're getting the NullPointerExceptions.
You're initializing the HashMap in the createUser endpoint and it's never being called within the test.
The createUser endpoint I can't see where it's failing, but anyway this code should really be reorganized because it has many points of failure. The HashMapshould really be initialized when the Bean is created, and you should revisit the way you are calculating the Key.
Also for Controller testing purposes, you should be using MockMvc instead of calling controller methods directly.
Related
I am trying to write a test of a service method. Most of the logic performed in their is covered by tests of those methods. I am mostly trying to see if the correct repository calls are being performed.The method returns the id of the receipt/bon it just created.
I can train the mocks of the repository with the calls being performed in the service. But my test keeps failing, because the service call is unable to return an id value (long). This is because the id is generated by performing the save method followed by the flush. I cannot seem to train my mocks to do this right.
This is the only error eccuring, that it cannot perform the service call, because it returns a null value instead of an id.
How can I mock the repository correct so testing my method will not fail on not having an id?
method:
#Override
#Transactional
public long addBonAndProducts(Boninfo boninfo) {
Consignatiebon bon = new Consignatiebon(boninfo.getGebruiker(), LocalDate.now(), boninfo.getOpmbon(), boninfo.getSolden());
LocalDate dateUit = this.createCorrectDateOut(bon.getDatumIn(), bon.getSolden());
bon.setDatumUit(dateUit);
//creates correct bonnr - logic tested elswhere
String currentLetterBon = this.findCurrentLetter();
Integer numberToInsert = this.findMostRecentBoncode(currentLetterBon);
bon.setBonCode(currentLetterBon, (numberToInsert + 1));
consignatiebonRepository.save(bon);
consignatiebonRepository.flush();
for(var product:boninfo.getLijstproducten()) {
product.setConsignatiebon(bon);
if(!(product.getStatus()==Status.STOCK)) {
product.setDatumUit(dateUit);
}
//creates correct articlenr - logi tested elswhere
String currentLetter = this.findCurrentLetter();
Integer numberToInsertBon = this.findMostRecentArtikelcode(currentLetter);
product.setArtikelCode(currentLetter, (numberToInsertBon + 1));
productRepository.save(product);
productRepository.flush();
long idProduct = product.getProductId();
bon.add(product);
}
consignatiebonRepository.save(bon);
consignatiebonRepository.flush();
bon.setTotalPieces();
bon.setTotalValueBon();
// these values are correct
System.out.println("inside function pieces: " + bon.getTotalPieces());
System.out.println("inside function pieces: " + bon.getTotalPrice());
consignatiebonRepository.save(bon);
// in the test, this is outputted as null, cause the flush method doesn't get performed
System.out.println("inside function pieces: " + bon.getIdConsignatiebon());
return bon.getIdConsignatiebon();
}
test:
#ExtendWith(MockitoExtension.class)
class ProductServiceTest {
private DefaultProductService productService;
private Kleur kleur;
private Maat maat;
private Merk merk;
private Eigenschap eigenschap;
private Product product;
private Product productTwo;
private Product productThree;
private Adres adres;
private Gebruiker gebruiker;
private Consignatiebon consignatiebon;
private Consignatiebon consignatiebonToFill;
#Mock
private ProductRepository productRepository;
#Mock
private GebruikerRepository gebruikerRepository;
#Mock
private ConsignatiebonRepository consignatiebonRepository;
#Mock
private WoocommerceApi woocommerceApi;
#Mock
private Mailing mailing;
#BeforeEach
void beforeEach() {
productService = new DefaultProductService(productRepository, consignatiebonRepository, gebruikerRepository,
woocommerceApi, mailing);
kleur = new Kleur("testkleur");
maat = new Maat("testmaat");
merk = new Merk("testmerk");
eigenschap = new Eigenschap("testclustereigenschap", "testsubeigenschap");
adres = new Adres("teststraat", "testhuisnummer", "testpostcode", "testgemeente", "testland");
gebruiker = new Gebruiker("testvoornaam","testnaam", "testriziv", "testmail#hotmail.be", true,
"testtelefoonnr", adres, Gebruikersrol.TESTLEVERANCIER, "testopmerking");
consignatiebon = new Consignatiebon(gebruiker, LocalDate.of(2020, 1, 1), "testopmerking", true);
product = new Product(gebruiker, consignatiebon, eigenschap, kleur, merk, maat, Soort.DAMES,
"testbeschrijving", BigDecimal.valueOf(10), BigDecimal.valueOf(25), Status.TEKOOP, false, true);
productTwo = new Product(gebruiker, consignatiebon, eigenschap, kleur, merk, maat, Soort.DAMES,
"testbeschrijvingTwo", BigDecimal.valueOf(10), BigDecimal.valueOf(25), Status.TEKOOP, false, true);
productThree = new Product(gebruiker, consignatiebon, eigenschap, kleur, merk, maat, Soort.DAMES,
"testbeschrijvingThree", BigDecimal.valueOf(10), BigDecimal.valueOf(25), Status.TEKOOP, false, true);
}
#Test
void addBonAndProducts() {
when(consignatiebonRepository.save(Mockito.any(Consignatiebon.class))).thenAnswer(i -> i.getArguments()[0]);
when(productRepository.save(Mockito.any(Product.class))).thenAnswer(i -> i.getArguments()[0]);
// when(productService.addBonAndProducts(Mockito.any(Boninfo.class))).thenReturn(1L);
List<Product> productlist = new ArrayList<>();
productlist.add(product);
productlist.add(productTwo);
productlist.add(productThree);
Boninfo testboninfo = new Boninfo(productlist, gebruiker, "testopmerkingbon", true);
productService.addBonAndProducts(testboninfo);
verify(consignatiebonRepository, times(3)).save(consignatiebon);
verify(productRepository, times(1)).save(product);
verify(productRepository, times(1)).save(productTwo);
verify(productRepository, times(1)).save(productThree);
}
}
am trying to implement depends on methods
i have given depends on login as agent for booking an appointment but its showing non exist method
ihave given #data provider and depends on method
this is login test case
public class TC001_Login extends ProjectSpecificMethods{
#BeforeTest
public void setValues() {
testCaseName = "Login";
testDescription = "This test is to verify whether user able to login and logout";
nodes = "login";
authors = "manoj";
category = "Smoke";
}
#Test(priority = 0)
public void loginAsAgent() throws InterruptedException, IOException {
new LoginPage(driver, node)
.enterUserName()
.enterPassword()
.enterCaptchAndClickLogin()
.clickOnLogout()
.verifyLogout();
}
}
this is appointment booking test case
public class TC003_BookAppointment extends ProjectSpecificMethods {
#BeforeTest
public void setValues() {
testCaseName = "bookappointment";
testDescription = "booking an appointment";
nodes = "appointment,appointment1";
authors = "manoj";
category = "Smoke";
dataSheetName = "ScheduleAppointment";
sheetName = "TestData";
}
#Test(dataProvider = "fetchData",dependsOnMethods = {"loginAsAgent"})
public void bookappointment(String visatype,String VscCode,String noofapplicants,String date,String path) throws IOException, Exception {
new LoginPage(driver, node)
.enterUserName()
.enterPassword()
.enterCaptchAndClickLogin()
.clickGroupScheduling()
.selectVisaType(visatype)
.selectVscCenter(VscCode)
.selectNumberOfApplicants(noofapplicants)
.enterCaptcha()
.selectDate_Normal(date)
.selectTime()
.confirmSlot_Normal()
.submitScheduling_Normal()
.generatePassportNumber()
.uploadexcel(path)
.clickUploadexcel()
.clickConsentcheckbox()
.clickSaveApplicantDetais()
.downloadAppointmentslip()
.downloadGroupSchedulingForm()
.verifyGroupid();
}
}
tried to give classname.methodname but not working
I know that in Java a method can return only one return type... But if there is any possiblity to this, kindly let me know. From the below method I am trying to return a list if condition satisfies else i am trying to return an error message.
Here is my code:
#RequestMapping(value = "/getcompanies", method = RequestMethod.POST)
public List<CompanyMaster> getCompanies(#RequestBody UserDetails user) {
String OrgLoginId = user.getOrgLoginId();
String password = user.getuPassword();
String checkLoginId = null;
String uPassword = null;
String encPassword = null;
String loginId = null;
String checkAuthorized = null;
// String loginId=userService.getLoginId(OrgLoginId);
List<Object[]> CheckIdPassword = userService.checkLoginId(OrgLoginId);
List<Object[]> results = CheckIdPassword;
for (Object[] obj : results) {
checkLoginId = obj[0].toString();
if (null == obj[1]) {
uPassword = "";
} else {
uPassword = obj[1].toString();
}
loginId = obj[2].toString();
}
checkAuthorized = loginId.substring(0, 3);
if (null != password) {
MD5 md5 = new MD5();
encPassword = md5.getPassword(password);
}
if (checkLoginId == null) {
return "Incorrect loginId..Please enter valid loginId";
} else if (encPassword.equals(uPassword)) {
if (checkAuthorized.equals("STE")) {
List<CompanyMaster> companyList = userService.getCompanyList(OrgLoginId);
return companyList;
} else {
return "You are not Authorized";
}
} else {
return "Incorrect Password";
}
Yes its possible, create a custom Exception say 'MyAppException' and throw that exception with the error message you want.
Write your logic in a try{}catch block and throw the exception in catch so that the response has the error message
public List<CompanyMaster> getCompanies(#RequestBody UserDetails user) throws MyAppppException
{
try
{
//your logic which throws error
return companyList;
}
catch( final MyAppException we )
{
throw new MyAppException("User not found", HttpStatus.NOT_FOUND);
}
}
Refer this link
https://www.codejava.net/java-core/exception/how-to-create-custom-exceptions-in-java
You can achieve this by creating a new presenter Class which contains List and status of type String and change the return type of getCompanies method to presenter class like
public CompaniesPresenter getCompanies()
And your CompaniesPresenter class should look like
public class CompaniesPresenter {
private List<CompanyMaster> companyMaster;
private string status;
//default constructor
public CompaniesPresenter(){
}
//parameterized constructor to return only string in exception case
public CompaniesPresenter(Stirng status){
this.status = status;
}
//parametirized constructor to return success case
public CompaniesPresenter(List<CompanyMaster> companyMaster, Stirng status){
this.companyMaster = companyMaster;
this.status = status;
}
//getters and setters
}
This is how your updated method lokks like
#RequestMapping(value = "/getcompanies", method = RequestMethod.POST)
public CompaniesPresenter getCompanies(#RequestBody UserDetails user) {
String OrgLoginId = user.getOrgLoginId();
String password = user.getuPassword();
String checkLoginId = null;
String uPassword = null;
String encPassword = null;
String loginId = null;
String checkAuthorized = null;
// String loginId=userService.getLoginId(OrgLoginId);
List<Object[]> CheckIdPassword = userService.checkLoginId(OrgLoginId);
List<Object[]> results = CheckIdPassword;
for (Object[] obj : results) {
checkLoginId = obj[0].toString();
if (null == obj[1]) {
uPassword = "";
} else {
uPassword = obj[1].toString();
}
loginId = obj[2].toString();
}
checkAuthorized = loginId.substring(0, 3);
if (null != password) {
MD5 md5 = new MD5();
encPassword = md5.getPassword(password);
}
if (checkLoginId == null) {
return new CompaniesPresenter("Incorrect loginId..Please enter valid loginId");
} else if (encPassword.equals(uPassword)) {
if (checkAuthorized.equals("STE")) {
List<CompanyMaster> companyList = userService.getCompanyList(OrgLoginId);
return new CompaniesPresenter(companyList,"success");
} else {
return new CompaniesPresenter("You are not Authorized");
}
} else {
return new CompaniesPresenter("Incorrect Password");
}
This is not tested please make sure for any compilation errors
vavr's Either class would be a good choice.
The usage of custom exception is most reasonable solution. However, creating custom exception for just one case is not ideal always.
Another solution is to return empty List from your method, check if the List is empty in your servlet (or wherever you are invoking this method from), and show error message there.
It seems like you want to return multiple error messages for different cases. In this case, custom exception is recommended solution. If you don't like custom exceptions, you can return List<Object> and populate error message as the first element in the list. In the place where this List is obtained, check if the first element is instanceOf String or CompanyMaster. Based on what it is, you can perform your operations. This is a weird but possible solution (only if you don't like custom exceptions).
You need to understand the problem first. You are mixing two things here, first authorization, does the user has correct privileges to get company details, second giving the company details itself. Let's understand the first problem when a user tries to access "/getcompanies" endpoint will you let him in if does not have access, in REST world your security model should take care of it. I would use spring security to achieve this. My recommendation would be to explore on "interceptor" and solve the problem of invalid user. This will make your other problem easy as your "/getcompanies" endpoint can focus only on getting the details and return it (SRP).
I'm getting problem with accessing variables with getter & setter on multiple classes. I looked up this one but I'm too confused.
I have 3 type users: Admin (Position No: 0 in mysql table), Manager (Position No: 1), Clerk (Position No:2).
I have SeeReportsAndFeedbacks class. I want to show all reports by selecting rows with position_no = 0 and 1 to admin and manager, 2 to clerk. It's already done with if statement.
So clerk can see only see reports that with position_no=2
manager can see only see reports that with position_no=0 and 1
admin can see only see reports that with position_no=0 and 1
Please help me. I'm stucked here for a long time. What are wrong with my getter setters?
If i set on Login_Form, and call get it shows correct in girisyap() function but if i call get in other class named SeeReportsAndFeedbacks it shows first initial value from Users () constructor instead of set value on girisyap() function on Login_Form.
tip value takes position_no from mysql db as string, new1 value is parsing (converting) string to int for if statement
screenshot
GIST
Users Class
public class Users {
private int id;
private String username;
private String fullname;
private String password;
private String phone;
private String gender;
private byte[] image;
private int position_no;
public Users () {
setPno(1); //firsst initialize
//getFullname();
}
public Users (int uid ,String uname, String fname, String upassword, String uphone, String ugender, byte[] uimage, int pno){
this.id = uid;
this.username = uname;
this.fullname = fname;
this.password = upassword;
this.phone = uphone;
this.gender =ugender;
this.image =uimage;
this.position_no = pno;
}
public Users (int pno){
setPno(pno);
}
public int getPno(){
return position_no;
}
public void setPno(int pno){
this.position_no = pno;
}}
SeeReportsAndFeedbacks class (i removed not-related funcs or some other gui things for the question.
public class SeeReportsAndFeedbacks { // extends javax.swing.JFrame
//CLIENT client = new CLIENT();
int new1 = 9999; //testing something
int PositionNoGetiren;
//sers loginf = new Users(0, null,null,null,null,null,null,new1);
public SeeReportsAndFeedbacks() {
//initComponents();
Users loginf = new Users();
PositionNoGetiren = loginf.getPno(); //gets initial value instead of set value on login_form
System.out.println("Babakingg " + PositionNoGetiren);
//int ananas = loginf.getPno();
//fillFeedbackJTable(jTable2);
}
public void fillReportJTable(){//JTable table
//loginf.setPno(2); it works if i manually set but it's useless
//System.out.println("Loginfvalue in see reports: " + loginf.getPno() + loginf.getUsername());
//new1 = loginf.getPno(); //not works shows 0
//see.getNo();
new1=PositionNoGetiren;
String selectQuery = "SELECT * FROM `users` WHERE `position_no` = ?";
if(new1==0){//admin
selectQuery = "SELECT * FROM `reports`";
}
if(new1==1){//manager
selectQuery = "SELECT * FROM `reports` WHERE `position_no` = 1";
}
if(new1==2){//clerk
selectQuery = "SELECT * FROM `reports` WHERE `position_no` = 2";
}
//}
}}
Login_Form
public class Login_Form {
int positionNoGetiren;
/**
* Creates new form Login_Form
*/
public Login_Form() {
//initComponents();
//positionNoGetiren = 9999;
}
private void girisyap() {
//I DELETED ALL DATABASE RELATED THINGS FOR QUESTION.
//String tip = rs.getString("position_no"); //DETECTS CORRECTLY POSITION NO FROM DATABASE
String tip = "IT'S rs.getString(\"position_no\")"; //for posting question
System.out.println(tip);
int new1 = Integer.parseInt(tip);
//Users loginf = new Users(new1); //welcome yazisi icin
Users loginf = new Users(); //ONLY WORKS IN THIS CLASS.
loginf.setPno(new1); //set user type for reports class BUT IT'S NOT WORKING
System.out.println("Loginf degeri login_formdaki: " + loginf.getPno());
//THIS IF IS WORKING CORRECTLY.
if(new1==0){
//Admin form = new Admin();
//form.setVisible(true);
//form.pack();
//form.setLocationRelativeTo(null);
// form.setExtendedState(JFrame.MAXIMIZED_BOTH);
}
if(new1==1){
//Manager form = new Manager();
//form.setVisible(true);
//form.pack();
//form.setLocationRelativeTo(null);
}
if(new1==2){
//Clerk form = new Clerk();
//form.setVisible(true);
//form.pack();
//form.setLocationRelativeTo(null);
// form.setExtendedState(JFrame.MAXIMIZED_BOTH);
}
//this.dispose();
}
private void jButton_LoginActionPerformed(java.awt.event.ActionEvent evt) {
girisyap();}
}
There is nothing wrong with your getters and setters.
This is most likely an issue with parsing the value of TIP, that could not be parsed as an INT, maybe its a float with a weird value of like 2.00000004, or simply null. Try writing a test or log the value which your query return and check if this is the value you are looking for.
Below is my test method.
#Test
public void testSaveUserPreference() throws Exception {
final long userId = 1L;
final String category = "category";
final UserPreference userPreference = createMockedUserPreference(userId, category);
final UserPreferenceDTO userPreferenceDTO = createMockedUserPreferenceDTO(userId, category);
final Date lastAccessed = userPreference.getLastAccessedDate();
userPreferenceDTO.setLastAccessedDate(lastAccessed);
//override the convert method to control the object being "saved"
final UserPreference document = new UserPreference();
new MockUp<UserPreferenceUtils>() {
#Mock
UserPreference convertFromDTO(UserPreferenceDTO dto) {
document.setUserId(userPreference.getUserId());
document.setCategory(userPreference.getCategory());
document.setProperties(userPreference.getProperties());
return document;
}
};
new Expectations() {{
component.getUserPreference(userId, category);
returns(userPreference);
component.saveUserPreference(userPreference);
returns(userPreference);
}};
UserPreferenceDTO actual = service.savePreference(userPreferenceDTO);
assertNotNull(actual);
assertEquals(userPreference.getUserId(), actual.getUserId());
assertEquals(userPreference.getCategory(), actual.getCategory());
assertEquals(userPreference.getProperties(), actual.getProperties());
assertNotNull(actual.getCreatedDate());
assertTrue(lastAccessed.before(actual.getLastAccessedDate()));
}
Below is the service method in which I am facing the error.
#Transactional
public UserPreferenceDTO savePreference(UserPreferenceDTO userPreference) {
UserPreference preference = UserPreferenceUtils.convertFromDTO(userPreference);
UserPreference existingPreference = userPreferenceComponent.getUserPreference(userPreference.getUserId(), userPreference.getCategory());
if(existingPreference!=null && !CollectionUtils.isEmpty(existingPreference.getProperties())) {
Map<String,Object> report = (Map<String, Object>) preference.getProperties().get("favoriteFilters");
Map<String,Object> existingRep = (Map<String, Object>) existingPreference.getProperties().get("favoriteFilters");
existingRep.putAll(report);
existingPreference.getProperties().put("favoriteFilters",existingRep);
} else {
existingPreference = preference;
}
if (existingPreference.getCreatedDate() == null) {
existingPreference.setCreatedDate(new Date());
}
existingPreference.setLastAccessedDate(new Date());
UserPreferenceDTO savedPreference = UserPreferenceUtils.convertFromDocument(userPreferenceComponent.saveUserPreference(existingPreference));
return savedPreference;
}
When calling the save method in the second last line, it is giving this error.
mockit.internal.UnexpectedInvocation: Parameter "userPreference" of com.curaspan.platformsupportservice.components.preference.UserPreferenceComponent#saveUserPreference(com.curaspan.platformsupportservice.mongo.document.UserPreference userPreference) expected com.curaspan.platformsupportservice.mongo.document.UserPreference#3d3fcdb0, got com.curaspan.platformsupportservice.mongo.document.UserPreference#636be97c
The userPreference object in the Expectation and the actual method is not matching, though I have all the parameters same. Is there anything I am missing out?