CURATOR-610: Refactor CountCuratorWatcher in TestWatcherIdentity.java …
authorwx930910 <wx19930910@gmail.com>
Mon, 9 Aug 2021 12:07:51 +0000 (14:07 +0200)
committerEnrico Olivelli <eolivelli@apache.org>
Mon, 9 Aug 2021 12:07:51 +0000 (14:07 +0200)
commit9aafdec9f2607cc6b652371a7687ed38889ddd2b
treed18e6360c8fc9b96fb88a73dc24e15eaf4d1ae01
parent64dc6d82f003693846f6075413683e386df3885e
CURATOR-610: Refactor CountCuratorWatcher in TestWatcherIdentity.java …

Fixes [CURATOR-610](https://issues.apache.org/jira/browse/CURATOR-610)

### Description
Refactor test class [CountCuratorWatcher](https://github.com/apache/curator/blob/4a11aaef8b190dc220d35b7a91df294bfa06250e/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherIdentity.java#L42) by using mocking object created by Mockito.

<hr>

##### Key changed/added classes in this PR
- Create mocking object to replace test subclass `CountCuratorWatcher`, decouple test from production code.
- Make test logic more clear by using method stub instead of method overriding.
- Extract AtomicInteger variable out of the test subclass. Use the extracted variable in assertation statement to check `process(WatchedEvent)` method invocation status.

<hr>

Author: wx930910 <wx19930910@gmail.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>

Closes #397 from wx930910/CURATOR-610
curator-framework/pom.xml
curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherIdentity.java