firebase-admin-java icon indicating copy to clipboard operation
firebase-admin-java copied to clipboard

com.google.firebase.auth.UserRecord.CreateRequest doesn't override .equals making it hard to test

Open nsadeh opened this issue 3 years ago • 3 comments

[READ] Step 1: Are you in the right place?

  • For issues or feature requests related to the code in this repository file a Github issue.
    • If this is a feature request make sure the issue title starts with "FR:".
  • For general technical questions, post a question on StackOverflow with the firebase tag.
  • For general Firebase discussion, use the firebase-talk google group.
  • For help troubleshooting your application that does not fall under one of the above categories, reach out to the personalized Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Operating System version: _____
  • Firebase SDK version: _____
  • Library version: _____
  • Firebase Product: _____ (auth, database, storage, etc)

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

What happened? How can we make the problem occur? This could be a description, log/console output, etc.

Relevant Code:

// TODO(you): code here to reproduce the problem

I built an application with a function that call firebaseAuth.createUserAsync(CreateRequest request). To test the logic in this function, I created a unit test for it with a mock:

CreateRequest createRequest = // creates some request
UserRecord userRecord = // build a record

FirebaseAuth auth = mock(FirebaseAuth.class);
when(auth.createUserAsync(createRequest)).thenReturn(ApiFutures.immediateFuture(userRecord))

but when I ran the test I got a Null Pointer Exception from Mockito. On further inspection, I realized that two instances of CreateRequest with the same payload value return false when compared via .equals. This leads Mockito to think the function is not defined for this argument.

I am happy to contribute this simple (probably IntelliJ-generated) code, is there a reason you don't want this in there?

nsadeh avatar Sep 30 '21 05:09 nsadeh

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.

google-oss-bot avatar Sep 30 '21 05:09 google-oss-bot

Sounds like a reasonable thing to do. Feel free to provide a PR if you can.

hiranya911 avatar Oct 08 '21 22:10 hiranya911

Hi @hiranya911 Can you review my PR ? Also, I've signed the CLA now. Thanks!

raunaqpahwa avatar Jan 08 '22 17:01 raunaqpahwa