Small improvements related to types deprecation.#36328
Small improvements related to types deprecation.#36328jtibshirani merged 6 commits intoelastic:masterfrom
Conversation
jtibshirani
commented
Dec 6, 2018
- Make sure to use deprecatedAndMaybeLog for types deprecation messages.
- Introduce a common base class for Rest*Action tests.
|
Pinging @elastic/es-core-infra |
nik9000
left a comment
There was a problem hiding this comment.
Nice! I left a small comment. I wonder if these is some way to clean up RestGetSourceActionTests. Could we make a method that makes the listener rather than set it up every time? That feels a little cleaner but I'm not sure.
|
|
||
| import static org.mockito.Mockito.mock; | ||
|
|
||
| public abstract class RestActionTestCase extends ESTestCase { |
There was a problem hiding this comment.
This is great! Please add javadoc!
|
|
||
| public void setUp() throws Exception { | ||
| super.setUp(); | ||
| controller = new RestController(Collections.emptySet(), null, |
There was a problem hiding this comment.
I think it is worth a comment about why these aren't final.
There was a problem hiding this comment.
Are you imagining a comment like 'these are effectively final, but can't be marked as such because they're initialized in the @Before method`?
There was a problem hiding this comment.
Could you declare the controller as final? I think it looks like it'd work.
There was a problem hiding this comment.
I caught up with @nik9000 offline and he is okay sticking with the style where we use @Before methods (and instance variables aren't final), instead of switching everything over to instance variables/ constructors. The reasoning is that there is an existing convention to use @Before methods in JUnit tests as opposed to standard object construction.
There was a problem hiding this comment.
I tend to use @Before as little as possible because it looks to me like a signal that I'm doing something complex. I see that this might be out of step with normal maven usage though. So I'm totally fine not doing it.
| public abstract class RestActionTestCase extends ESTestCase { | ||
| private RestController controller; | ||
|
|
||
| public void setUp() throws Exception { |
There was a problem hiding this comment.
I think it is weird to override the superclass setup rather than make your own.
There was a problem hiding this comment.
Sorry, I'm having trouble understanding the right alternative. This looked like a common approach in abstract classes that extend ESTestCase.
There was a problem hiding this comment.
It comes up some times but other times we make a new @Before method instead. I think most of the time we make a @Before method. Unless we have specific ordering requirements between the method and the one of the superclass.
|
Thanks @nik9000 for the speedy code review! For |
mayya-sharipova
left a comment
There was a problem hiding this comment.
Thanks Julie, your PR makes the code much shorter
|
|
||
| public abstract class RestActionTestCase extends ESTestCase { | ||
| private RestController controller; | ||
|
|
There was a problem hiding this comment.
should we add @Override above?
There was a problem hiding this comment.
Now that we're creating new @Before methods, we should be able to avoid overriding setUp.
I don't think you should pull more common functionality into |
Got it! I was used to a JUnit style where |
| if (searchRequest.types().length > 0) { | ||
| deprecationLogger.deprecated(RestMultiSearchAction.TYPES_DEPRECATION_MESSAGE); | ||
| deprecationLogger.deprecatedAndMaybeLog("msearch_template_with_types", | ||
| RestMultiSearchAction.TYPES_DEPRECATION_MESSAGE); |
There was a problem hiding this comment.
Do we want to use RestMultiSearchTemplateAction here and the same with logger on line 44?
There was a problem hiding this comment.
Thanks for pointing this out @mayya-sharipova. If it's okay with you, I'll plan to fix this in another PR as this one is already reasonably large.
|
After finding several additional instances of Here are the items I plan to follow up on in subsequent PRs:
|
Sounds good to me! |
|
Thanks, in that case I think this is ready for another look! |
|
|
||
| public void setUp() throws Exception { | ||
| super.setUp(); | ||
| controller = new RestController(Collections.emptySet(), null, |
There was a problem hiding this comment.
I tend to use @Before as little as possible because it looks to me like a signal that I'm doing something complex. I see that this might be out of step with normal maven usage though. So I'm totally fine not doing it.