Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
None
-
Reviewed
Description
Possible code improvements I've identified in this class:
1. In TestRMWebServicesNodeLabels#testNodeLabels: Missing HTTP response status code checks for successful operations
2. Some methods are throwing too many types of Exceptions, e.g. "throws JSONException, Exception" can be simplified to "throws Exception"
3. Repeated code fragments can be replaced. E.g.:
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
response.getType().toString());
4. Some variable names are confusing, e.g. "NodeLabelsInfo nlsifo"
5. There are many node label related endpoint calls, all copy-pasted, for example:
response = r.path("ws").path("v1").path("cluster") .path("add-node-labels").queryParam("user.name", userName) .accept(MediaType.APPLICATION_JSON) .entity(toJson(nodeLabelsInfo, NodeLabelsInfo.class), MediaType.APPLICATION_JSON) .post(ClientResponse.class);
This is just an example, there are many many endpoint calls duplicated like this, they could be extracted to methods.
6. Duplicated validation code of all REST endpoints can be simplified
7. There are weird, repeated log strings that could be removed, like:
LOG.info("posted node nodelabel")
8. Constants could be added for labels, node ids, etc.
Attachments
Issue Links
- links to