From 349980f10757a58624ffa601cd4bad5a8c03fd5f Mon Sep 17 00:00:00 2001 From: Richard Zowalla Date: Mon, 4 Dec 2023 10:34:57 +0100 Subject: [PATCH] Fix JUnit 5 related compile issues --- .../resource/TestResourceAwareScheduler.java | 5 ++- .../TestUtilsForResourceAwareScheduler.java | 33 +++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/storm-server/src/test/java/org/apache/storm/scheduler/resource/TestResourceAwareScheduler.java b/storm-server/src/test/java/org/apache/storm/scheduler/resource/TestResourceAwareScheduler.java index 6caea706b55..a4804202abc 100644 --- a/storm-server/src/test/java/org/apache/storm/scheduler/resource/TestResourceAwareScheduler.java +++ b/storm-server/src/test/java/org/apache/storm/scheduler/resource/TestResourceAwareScheduler.java @@ -762,8 +762,7 @@ public void testTopologyWorkerMaxHeapSize() { assertTrue(cluster.needsSchedulingRas(topology2)); String status = cluster.getStatusMap().get(topology2.getId()); String expectedStatusPrefix = "Not enough resources to schedule"; - assertTrue("Expected status to start with \"" + expectedStatusPrefix + "\" but status is: " + status, - status.startsWith(expectedStatusPrefix)); + assertTrue(status.startsWith(expectedStatusPrefix), "Expected status to start with \"" + expectedStatusPrefix + "\" but status is: " + status); assertEquals(5, cluster.getUnassignedExecutors(topology2).size()); } finally { rs.cleanup(); @@ -1137,7 +1136,7 @@ void append(TimeBlockResult other) { private long getMedianValue(List values) { final int numValues = values.size(); - assertTrue("Expecting odd number of values to compute median, got " + numValues, (numValues % 2) == 1); + assertEquals(1, (numValues % 2), "Expecting odd number of values to compute median, got " + numValues); List sortedValues = new ArrayList<>(); sortedValues.addAll(values); Collections.sort(sortedValues); diff --git a/storm-server/src/test/java/org/apache/storm/scheduler/resource/TestUtilsForResourceAwareScheduler.java b/storm-server/src/test/java/org/apache/storm/scheduler/resource/TestUtilsForResourceAwareScheduler.java index 6b52e186577..3647aa664f4 100644 --- a/storm-server/src/test/java/org/apache/storm/scheduler/resource/TestUtilsForResourceAwareScheduler.java +++ b/storm-server/src/test/java/org/apache/storm/scheduler/resource/TestUtilsForResourceAwareScheduler.java @@ -48,7 +48,7 @@ import org.apache.storm.tuple.Tuple; import org.apache.storm.tuple.Values; import org.apache.storm.utils.Utils; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -482,13 +482,13 @@ public static void assertTopologiesNotScheduled(Cluster cluster, Class strategyC Topologies topologies = cluster.getTopologies(); for (String topoName : topoNames) { TopologyDetails td = topologies.getByName(topoName); - Assert.assertTrue("Cannot find topology for topoName " + topoName, td != null); + Assertions.assertNotNull(td, "Cannot find topology for topoName " + topoName); String topoId = td.getId(); String status = cluster.getStatus(topoId); - Assert.assertTrue("Status unknown for topoName " + topoName, status != null); - Assert.assertTrue("Successful status " + status + " for topoName " + topoName, !isStatusSuccess(status)); - Assert.assertTrue("Found assignment for topoId " + topoId, cluster.getAssignmentById(topoId) == null); - Assert.assertTrue("Scheduling not required for topoName " + topoName, cluster.needsSchedulingRas(td)); + Assertions.assertNotNull(status, "Status unknown for topoName " + topoName); + Assertions.assertFalse(isStatusSuccess(status), "Successful status " + status + " for topoName " + topoName); + Assertions.assertNull(cluster.getAssignmentById(topoId), "Found assignment for topoId " + topoId); + Assertions.assertTrue(cluster.needsSchedulingRas(td), "Scheduling not required for topoName " + topoName); } } @@ -496,11 +496,11 @@ public static void assertTopologiesFullyScheduled(Cluster cluster, Class strateg Topologies topologies = cluster.getTopologies(); for (String topoName : topoNames) { TopologyDetails td = topologies.getByName(topoName); - Assert.assertTrue("Cannot find topology for topoName " + topoName, td != null); + Assertions.assertNotNull(td, "Cannot find topology for topoName " + topoName); String topoId = td.getId(); assertStatusSuccess(cluster, topoId); - Assert.assertTrue("Cannot find assignment for topoId " + topoId, cluster.getAssignmentById(topoId) != null); - Assert.assertTrue("Scheduling required for topoName " + topoName, !cluster.needsSchedulingRas(td)); + Assertions.assertNotNull(cluster.getAssignmentById(topoId), "Cannot find assignment for topoId " + topoId); + Assertions.assertFalse(cluster.needsSchedulingRas(td), "Scheduling required for topoName " + topoName); } } @@ -523,32 +523,31 @@ public static void assertTopologiesFullyScheduled(Cluster cluster, Class strateg public static void assertTopologiesBeenEvicted(Cluster cluster, Class strategyClass, Set evictedTopologies, String... topoNames) { Topologies topologies = cluster.getTopologies(); LOG.info("Evicted topos: {}", evictedTopologies); - Assert.assertTrue("evictedTopologies is null", evictedTopologies != null); + Assertions.assertNotNull(evictedTopologies, "evictedTopologies is null"); for (String topoName : topoNames) { String errMsg = "topology " + topoName + " using " + strategyClass.getName(); TopologyDetails td = topologies.getByName(topoName); - Assert.assertTrue("Cannot find topology for topoName " + topoName, td != null); + Assertions.assertNotNull(td, "Cannot find topology for topoName " + topoName); String topoId = td.getId(); - Assert.assertTrue("evictedTopologies does not contain topoId " + topoId, evictedTopologies.contains(topoId)); + Assertions.assertTrue(evictedTopologies.contains(topoId), "evictedTopologies does not contain topoId " + topoId); } } public static void assertTopologiesNotBeenEvicted(Cluster cluster, Class strategyClass, Set evictedTopologies, String... topoNames) { Topologies topologies = cluster.getTopologies(); LOG.info("Evicted topos: {}", evictedTopologies); - Assert.assertTrue("evictedTopologies is null", evictedTopologies != null); + Assertions.assertNotNull(evictedTopologies, "evictedTopologies is null"); for (String topoName : topoNames) { String errMsg = "topology " + topoName + " using " + strategyClass.getName(); TopologyDetails td = topologies.getByName(topoName); - Assert.assertTrue("Cannot find topology for topoName " + topoName, td != null); + Assertions.assertNotNull(td, "Cannot find topology for topoName " + topoName); String topoId = td.getId(); - Assert.assertTrue("evictedTopologies contains topoId " + topoId, !evictedTopologies.contains(topoId)); + Assertions.assertFalse(evictedTopologies.contains(topoId), "evictedTopologies contains topoId " + topoId); } } public static void assertStatusSuccess(Cluster cluster, String topoId) { - Assert.assertTrue("topology " + topoId + " in unsuccessful status: " + cluster.getStatus(topoId), - isStatusSuccess(cluster.getStatus(topoId))); + Assertions.assertTrue(isStatusSuccess(cluster.getStatus(topoId)), "topology " + topoId + " in unsuccessful status: " + cluster.getStatus(topoId)); } public static boolean isStatusSuccess(String status) {