Skip to content

Commit 1d956c2

Browse files
committed
YARN-11262. Fix CheckStyle & Junit Test.
1 parent 63e3060 commit 1d956c2

14 files changed

+211
-248
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCustomResourceTypesCommons.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ static void verifyAppInfoJson(JSONObject info, RMApp app, ResourceManager rm)
6262
throws JSONException {
6363
int expectedNumberOfElements = getExpectedNumberOfElements(app);
6464

65-
assertEquals(expectedNumberOfElements
66-
, info.length(), "incorrect number of elements");
65+
assertEquals(expectedNumberOfElements,
66+
info.length(), "incorrect number of elements");
6767

6868
AppInfoJsonVerifications.verify(info, app);
6969

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesForCSWithPartitions.java

Lines changed: 55 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -443,15 +443,14 @@ private void verifySchedulerInfoXML(Document dom) throws Exception {
443443
}
444444
} else if (schedulerInfoElem.getTagName().equals(CAPACITIES)) {
445445
NodeList capacitiesListInfos = schedulerInfoElem.getChildNodes();
446-
assertEquals(3
447-
, capacitiesListInfos.getLength(), "incorrect number of partitions");
446+
assertEquals(3,
447+
capacitiesListInfos.getLength(), "incorrect number of partitions");
448448
for (int k = 0; k < capacitiesListInfos.getLength(); k++) {
449449
Element partitionCapacitiesInfo =
450450
(Element) capacitiesListInfos.item(k);
451451
String partitionName = WebServicesTestUtils
452452
.getXmlString(partitionCapacitiesInfo, "partitionName");
453-
assertTrue(
454-
CLUSTER_LABELS.contains(partitionName), "invalid PartitionCapacityInfo");
453+
assertTrue(CLUSTER_LABELS.contains(partitionName), "invalid PartitionCapacityInfo");
455454
verifyPartitionCapacityInfoXML(partitionCapacitiesInfo, 100, 0, 100,
456455
100, 0, 100);
457456
}
@@ -466,8 +465,8 @@ private void verifyQueueAInfoXML(Element queueElem) {
466465
Element queueChildElem = (Element) children.item(j);
467466
if (queueChildElem.getTagName().equals(CAPACITIES)) {
468467
NodeList capacitiesListInfos = queueChildElem.getChildNodes();
469-
assertEquals(1
470-
, capacitiesListInfos.getLength(), "incorrect number of partitions");
468+
assertEquals(1,
469+
capacitiesListInfos.getLength(), "incorrect number of partitions");
471470
Element partitionCapacitiesInfo = (Element) capacitiesListInfos.item(0);
472471
String partitionName = WebServicesTestUtils
473472
.getXmlString(partitionCapacitiesInfo, "partitionName");
@@ -482,16 +481,16 @@ private void verifyQueueAInfoXML(Element queueElem) {
482481
}
483482

484483
private void verifyQueueBInfoXML(Element queueElem) {
485-
assertEquals(LABEL_LX
486-
, WebServicesTestUtils.getXmlString(queueElem,
487-
"defaultNodeLabelExpression"), "Invalid default Label expression");
484+
assertEquals(LABEL_LX,
485+
WebServicesTestUtils.getXmlString(queueElem,
486+
"defaultNodeLabelExpression"), "Invalid default Label expression");
488487
NodeList children = queueElem.getChildNodes();
489488
for (int j = 0; j < children.getLength(); j++) {
490489
Element queueChildElem = (Element) children.item(j);
491490
if (queueChildElem.getTagName().equals(CAPACITIES)) {
492491
NodeList capacitiesListInfos = queueChildElem.getChildNodes();
493-
assertEquals(2
494-
, capacitiesListInfos.getLength(), "incorrect number of partitions");
492+
assertEquals(2,
493+
capacitiesListInfos.getLength(), "incorrect number of partitions");
495494
for (int k = 0; k < capacitiesListInfos.getLength(); k++) {
496495
Element partitionCapacitiesInfo =
497496
(Element) capacitiesListInfos.item(k);
@@ -512,8 +511,8 @@ private void verifyQueueBInfoXML(Element queueElem) {
512511
}
513512
}
514513
}
515-
assertEquals(LABEL_LX
516-
, WebServicesTestUtils.getXmlString(queueElem, "nodeLabels"), "Node Labels are not matching");
514+
assertEquals(LABEL_LX, WebServicesTestUtils.getXmlString(queueElem, "nodeLabels"),
515+
"Node Labels are not matching");
517516
}
518517

519518
private void verifyQueueCInfoXML(Element queueElem) {
@@ -532,9 +531,9 @@ private void verifyQueueCInfoXML(Element queueElem) {
532531
String queue = WebServicesTestUtils.getXmlString(qElem2, "queueName");
533532
switch (queue) {
534533
case LEAF_QUEUE_C1:
535-
assertEquals(LABEL_LX
536-
, WebServicesTestUtils.getXmlString(qElem2,
537-
"defaultNodeLabelExpression"), "Invalid default Label expression");
534+
assertEquals(LABEL_LX,
535+
WebServicesTestUtils.getXmlString(qElem2,
536+
"defaultNodeLabelExpression"), "Invalid default Label expression");
538537
NodeList queuec1Children = qElem2.getChildNodes();
539538
for (int l = 0; l < queuec1Children.getLength(); l++) {
540539
Element queueC1ChildElem = (Element) queuec1Children.item(l);
@@ -545,9 +544,9 @@ private void verifyQueueCInfoXML(Element queueElem) {
545544
}
546545
break;
547546
case LEAF_QUEUE_C2:
548-
assertEquals(LABEL_LY
549-
, WebServicesTestUtils.getXmlString(qElem2,
550-
"defaultNodeLabelExpression"), "Invalid default Label expression");
547+
assertEquals(LABEL_LY,
548+
WebServicesTestUtils.getXmlString(qElem2,
549+
"defaultNodeLabelExpression"), "Invalid default Label expression");
551550
NodeList queuec2Children = qElem2.getChildNodes();
552551
for (int l = 0; l < queuec2Children.getLength(); l++) {
553552
Element queueC2ChildElem = (Element) queuec2Children.item(l);
@@ -570,8 +569,7 @@ private void verifyQcCapacitiesInfoXML(Element partitionCapacitiesElem,
570569
float lyCaps, float lyMaxCaps, float lyAbsCaps, float lyAbsMaxCaps,
571570
float defCaps, float defMaxCaps, float defAbsCaps, float defAbsMaxCaps) {
572571
NodeList capacitiesListInfos = partitionCapacitiesElem.getChildNodes();
573-
assertEquals(3
574-
, capacitiesListInfos.getLength(), "incorrect number of partitions");
572+
assertEquals(3, capacitiesListInfos.getLength(), "incorrect number of partitions");
575573
for (int k = 0; k < capacitiesListInfos.getLength(); k++) {
576574
Element partitionCapacitiesInfo = (Element) capacitiesListInfos.item(k);
577575
String partitionName = WebServicesTestUtils
@@ -597,25 +595,24 @@ private void verifyQcCapacitiesInfoXML(Element partitionCapacitiesElem,
597595

598596
private void verifyResourceUsageInfoXML(Element queueChildElem) {
599597
NodeList resourceUsageInfo = queueChildElem.getChildNodes();
600-
assertEquals(1
601-
, resourceUsageInfo.getLength(), "incorrect number of partitions");
598+
assertEquals(1, resourceUsageInfo.getLength(), "incorrect number of partitions");
602599
Element partitionResourceUsageInfo = (Element) resourceUsageInfo.item(0);
603600
String partitionName = WebServicesTestUtils
604601
.getXmlString(partitionResourceUsageInfo, "partitionName");
605-
assertTrue(
606-
DEFAULT_PARTITION.equals(partitionName), "invalid PartitionCapacityInfo");
602+
assertTrue(DEFAULT_PARTITION.equals(partitionName),
603+
"invalid PartitionCapacityInfo");
607604
}
608605

609606
private void verifyPartitionCapacityInfoXML(Element partitionInfo,
610607
float capacity, float usedCapacity, float maxCapacity,
611608
float absoluteCapacity, float absoluteUsedCapacity,
612609
float absoluteMaxCapacity) {
613-
assertEquals(capacity,
614-
WebServicesTestUtils.getXmlFloat(partitionInfo, "capacity"), EPSILON, "capacity doesn't match");
615-
assertEquals(usedCapacity,
616-
WebServicesTestUtils.getXmlFloat(partitionInfo, "usedCapacity"), EPSILON,"capacity doesn't match");
617-
assertEquals(maxCapacity,
618-
WebServicesTestUtils.getXmlFloat(partitionInfo, "maxCapacity"), EPSILON, "capacity doesn't match");
610+
assertEquals(capacity, WebServicesTestUtils.getXmlFloat(partitionInfo, "capacity"),
611+
EPSILON, "capacity doesn't match");
612+
assertEquals(usedCapacity, WebServicesTestUtils.getXmlFloat(partitionInfo, "usedCapacity"),
613+
EPSILON,"capacity doesn't match");
614+
assertEquals(maxCapacity, WebServicesTestUtils.getXmlFloat(partitionInfo, "maxCapacity"),
615+
EPSILON, "capacity doesn't match");
619616
assertEquals(absoluteCapacity,
620617
WebServicesTestUtils.getXmlFloat(partitionInfo, "absoluteCapacity"),
621618
EPSILON, "capacity doesn't match");
@@ -637,13 +634,12 @@ private void verifySchedulerInfoJson(JSONObject json)
637634
JSONObject capacitiesJsonObject = info.getJSONObject(CAPACITIES);
638635
JSONArray partitionsCapsArray =
639636
capacitiesJsonObject.getJSONArray(QUEUE_CAPACITIES_BY_PARTITION);
640-
assertEquals(CLUSTER_LABELS.size()
641-
, partitionsCapsArray.length(), "incorrect number of elements");
637+
assertEquals(CLUSTER_LABELS.size(),
638+
partitionsCapsArray.length(), "incorrect number of elements");
642639
for (int i = 0; i < partitionsCapsArray.length(); i++) {
643640
JSONObject partitionInfo = partitionsCapsArray.getJSONObject(i);
644641
String partitionName = partitionInfo.getString("partitionName");
645-
assertTrue(
646-
CLUSTER_LABELS.contains(partitionName), "Unknown partition received");
642+
assertTrue(CLUSTER_LABELS.contains(partitionName), "Unknown partition received");
647643
verifyPartitionCapacityInfoJson(partitionInfo, 100, 0, 100, 100, 0, 100);
648644
}
649645
JSONObject jsonQueuesObject = info.getJSONObject("queues");
@@ -684,26 +680,24 @@ private void verifySchedulerInfoJson(JSONObject json)
684680
String partitionName = null;
685681
switch (queue) {
686682
case QUEUE_A:
687-
assertEquals(1
688-
, partitionsCapsArray.length(), "incorrect number of partitions");
683+
assertEquals(1, partitionsCapsArray.length(), "incorrect number of partitions");
689684
partitionInfo = partitionsCapsArray.getJSONObject(0);
690685
partitionName = partitionInfo.getString("partitionName");
691686
verifyPartitionCapacityInfoJson(partitionInfo, 30, 0, 50, 30, 0, 50);
692-
assertEquals(7
693-
, partitionsResourcesArray.getJSONObject(0).length(), "incorrect number of elements");
694-
assertEquals(1
695-
, resourceUsageByPartition.length(), "incorrect number of objects");
687+
assertEquals(7, partitionsResourcesArray.getJSONObject(0).length(),
688+
"incorrect number of elements");
689+
assertEquals(1, resourceUsageByPartition.length(), "incorrect number of objects");
696690
break;
697691
case QUEUE_B:
698-
assertEquals(LABEL_LX
699-
, queueJson.getString("defaultNodeLabelExpression"), "Invalid default Label expression");
700-
assertEquals(7
701-
, partitionsResourcesArray.getJSONObject(0).length(), "incorrect number of elements");
692+
assertEquals(LABEL_LX, queueJson.getString("defaultNodeLabelExpression"),
693+
"Invalid default Label expression");
694+
assertEquals(7, partitionsResourcesArray.getJSONObject(0).length(),
695+
"incorrect number of elements");
702696
verifyAccesibleNodeLabels(queueJson, ImmutableSet.of(LABEL_LX));
703-
assertEquals(2
704-
, partitionsCapsArray.length(), "incorrect number of partitions");
705-
assertEquals(2
706-
, resourceUsageByPartition.length(), "incorrect number of objects");
697+
assertEquals(2, partitionsCapsArray.length(),
698+
"incorrect number of partitions");
699+
assertEquals(2, resourceUsageByPartition.length(),
700+
"incorrect number of objects");
707701
for (int j = 0; j < partitionsCapsArray.length(); j++) {
708702
partitionInfo = partitionsCapsArray.getJSONObject(j);
709703
partitionName = partitionInfo.getString("partitionName");
@@ -724,8 +718,8 @@ private void verifySchedulerInfoJson(JSONObject json)
724718
case QUEUE_C:
725719
verifyAccesibleNodeLabels(queueJson,
726720
ImmutableSet.of(LABEL_LX, LABEL_LY));
727-
assertEquals(4
728-
, partitionsResourcesArray.getJSONObject(0).length(), "incorrect number of elements");
721+
assertEquals(4, partitionsResourcesArray.getJSONObject(0).length(),
722+
"incorrect number of elements");
729723
verifyQcPartitionsCapacityInfoJson(partitionsCapsArray, 70, 100, 70,
730724
100, 100, 100, 100, 100, 40, 50, 40, 50);
731725
verifySubQueuesOfQc(queueJson);
@@ -745,11 +739,11 @@ private void verifyAccesibleNodeLabels(JSONObject queueJson,
745739
} else {
746740
nodeLabels.put(nodeLabelsObj);
747741
}
748-
assertEquals(
749-
accesibleNodeLabels.size(), nodeLabels.length(), "number of accessible Node Labels not matching");
742+
assertEquals(accesibleNodeLabels.size(), nodeLabels.length(),
743+
"number of accessible Node Labels not matching");
750744
for (int i = 0; i < nodeLabels.length(); i++) {
751-
assertTrue(
752-
accesibleNodeLabels.contains(nodeLabels.getString(i)), "Invalid accessible node label : " + nodeLabels.getString(i));
745+
assertTrue(accesibleNodeLabels.contains(nodeLabels.getString(i)),
746+
"Invalid accessible node label : " + nodeLabels.getString(i));
753747
}
754748
}
755749

@@ -767,16 +761,16 @@ private void verifySubQueuesOfQc(JSONObject queueCJson) throws JSONException {
767761
case LEAF_QUEUE_C1:
768762
verifyAccesibleNodeLabels(queueJson,
769763
ImmutableSet.of(LABEL_LX, LABEL_LY));
770-
assertEquals(LABEL_LX
771-
, queueJson.getString("defaultNodeLabelExpression"), "Invalid default Label expression");
764+
assertEquals(LABEL_LX, queueJson.getString("defaultNodeLabelExpression"),
765+
"Invalid default Label expression");
772766
verifyQcPartitionsCapacityInfoJson(partitionsCapsArray, 40, 100, 28,
773767
100, 50, 75, 50, 75, 50, 60, 20, 30);
774768
break;
775769
case LEAF_QUEUE_C2:
776770
verifyAccesibleNodeLabels(queueJson,
777771
ImmutableSet.of(LABEL_LX, LABEL_LY));
778-
assertEquals(LABEL_LY
779-
, queueJson.getString("defaultNodeLabelExpression"), "Invalid default Label expression");
772+
assertEquals(LABEL_LY, queueJson.getString("defaultNodeLabelExpression"),
773+
"Invalid default Label expression");
780774
verifyQcPartitionsCapacityInfoJson(partitionsCapsArray, 60, 100, 42,
781775
100, 50, 75, 50, 75, 50, 70, 20, 35);
782776
break;
@@ -791,8 +785,8 @@ private void verifyQcPartitionsCapacityInfoJson(JSONArray partitionsCapsArray,
791785
float lyCaps, float lyMaxCaps, float lyAbsCaps, float lyAbsMaxCaps,
792786
float defCaps, float defMaxCaps, float defAbsCaps, float defAbsMaxCaps)
793787
throws JSONException {
794-
assertEquals(CLUSTER_LABELS.size()
795-
, partitionsCapsArray.length(), "incorrect number of partitions");
788+
assertEquals(CLUSTER_LABELS.size(), partitionsCapsArray.length(),
789+
"incorrect number of partitions");
796790
for (int j = 0; j < partitionsCapsArray.length(); j++) {
797791
JSONObject partitionInfo = partitionsCapsArray.getJSONObject(j);
798792
String partitionName = partitionInfo.getString("partitionName");

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesNodeLabels.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
import org.apache.hadoop.yarn.webapp.WebServicesTestUtils;
6868
import org.codehaus.jettison.json.JSONException;
6969
import org.codehaus.jettison.json.JSONObject;
70-
import org.junit.jupiter.api.Assertions;
7170
import org.junit.jupiter.api.BeforeEach;
7271
import org.junit.jupiter.api.Test;
7372

@@ -447,8 +446,9 @@ private void assertLabelsToNodesInfo(LabelsToNodesInfo labelsToNodesInfo, int si
447446
assertNotNull(actualNodes, String.format("Node info not found. Expected NodeLabel data: %s",
448447
expectedNLData));
449448
for (String expectedNode : expectedNodes) {
450-
assertTrue(actualNodes.getNodeIDs().contains(expectedNode), String.format("Can't find node ID in actual Node IDs list: %s",
451-
actualNodes.getNodeIDs()));
449+
assertTrue(actualNodes.getNodeIDs().contains(expectedNode),
450+
String.format("Can't find node ID in actual Node IDs list: %s",
451+
actualNodes.getNodeIDs()));
452452
}
453453
}
454454
}
@@ -477,16 +477,16 @@ private void assertNodeLabelsInfoAtPosition(NodeLabelsInfo nodeLabelsInfo, Pair<
477477
private void assertNodeLabelsInfoContains(NodeLabelsInfo nodeLabelsInfo,
478478
Pair<String, Boolean> nlInfo) {
479479
NodeLabelInfo nodeLabelInfo = new NodeLabelInfo(nlInfo.getLeft(), nlInfo.getRight());
480-
assertTrue(
481-
nodeLabelsInfo.getNodeLabelsInfo().contains(nodeLabelInfo), String.format("Cannot find nodeLabelInfo '%s' among items of node label info list:" +
482-
" %s", nodeLabelInfo, nodeLabelsInfo.getNodeLabelsInfo()));
480+
assertTrue(nodeLabelsInfo.getNodeLabelsInfo().contains(nodeLabelInfo),
481+
String.format("Cannot find nodeLabelInfo '%s' among items of node label info list:" +
482+
" %s", nodeLabelInfo, nodeLabelsInfo.getNodeLabelsInfo()));
483483
}
484484

485485
private void assertNodeLabelsInfoDoesNotContain(NodeLabelsInfo nodeLabelsInfo, Pair<String,
486486
Boolean> nlInfo) {
487487
NodeLabelInfo nodeLabelInfo = new NodeLabelInfo(nlInfo.getLeft(), nlInfo.getRight());
488-
assertFalse(
489-
nodeLabelsInfo.getNodeLabelsInfo().contains(nodeLabelInfo), String.format("Should have not found nodeLabelInfo '%s' among " +
488+
assertFalse(nodeLabelsInfo.getNodeLabelsInfo().contains(nodeLabelInfo),
489+
String.format("Should have not found nodeLabelInfo '%s' among " +
490490
"items of node label info list: %s", nodeLabelInfo, nodeLabelsInfo.getNodeLabelsInfo()));
491491
}
492492

@@ -622,7 +622,7 @@ public void testLabelChangeExclusivity()
622622
private void validateJsonExceptionContent(Response response,
623623
String expectedMessage)
624624
throws JSONException {
625-
Assertions.assertEquals(BAD_REQUEST_CODE, response.getStatus());
625+
assertEquals(BAD_REQUEST_CODE, response.getStatus());
626626
JSONObject msg = response.readEntity(JSONObject.class);
627627
JSONObject exception = msg.getJSONObject("RemoteException");
628628
String message = exception.getString("message");

0 commit comments

Comments
 (0)