keith-turner opened a new issue, #5666:
URL: https://github.com/apache/accumulo/issues/5666

   **Is your feature request related to a problem? Please describe.**
   
   When writing unit test that use the TabletId object its difficult to mock 
because it implements comparable and the comparison logic that is implemented 
in TabletIdImpl is quite complex. Although the interface is fairly simple, 
trying to duplicate this comparison logic in a unit test using something like 
EasyMock would be quite involved and error prone.  The hashCode() and equals() 
methods on TabletId are also non trivial.
   
   
   **Describe the solution you'd like**
   
   Add a few static methods to TabletId that enable easily creating TabletId 
objects. The implementation of these static methods could use TabletIdImpl 
whichis not in the public API.
   
   ```java
   TableId tableId = TableId.of("2");
   TabletId tablet1 = TabletId.of(TableId.of("2"), null, null); // creates a 
tablet over the range -inf,+inf
   TabletId tablet2 = TabletId.of(TableId.of("3"), "a", "m"); // creates a 
tablet over the range (a,m]
   TabletId tablet3 = TabletId.of(TableId.of("4"), "b".getBytes(UTF_8), 
"e".getBytes(UTF_8)); // creates a tablet over the range (b,e]
   ```
   
   The above tabletIds would properly implement hashCode(), equals(), and 
compareTo because they are based in TabletIdImpl.
   
   
   **Additional context**
   
   Not sure where this should land, would be really nice to have in 2.X for 
writing unit test that only use Accumulo's public API.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to