firebase / firebase/firebase-admin-java

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

未关闭
#600 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
help wanted needs-triage type: feature request
主要语言
Java
星标
620
派生
305
平均合并
3 小时 23 分钟
30 天内合并 PR
1

描述

### [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](http://stackoverflow.com/)
with the firebase tag.
* For general Firebase discussion, use the [firebase-talk](https://groups.google.com/forum/#!forum/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](https://firebase.google.com/support/).

### [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:
```java
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?

贡献指南

打开贡献指南

调研方向

Start by locating com.google.firebase.auth.UserRecord.CreateRequest and the createUserAsync(CreateRequest request) entry point. Review the existing authentication tests, then verify that two requests with the same payload compare as expected and that the Mockito-based test no longer receives a null result.

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
authentication
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
描述清楚
新手友好度
55/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。