Skip to content

Commit 6a0a189

Browse files
committed
Add unit test case for StandaloneHaServices constructor
1 parent 5edbc9c commit 6a0a189

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

flink-runtime/src/test/java/org/apache/flink/runtime/highavailability/nonha/standalone/StandaloneHaServicesTest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import org.junit.Before;
3131
import org.junit.Test;
3232

33+
import static org.junit.Assert.assertThrows;
34+
import static org.junit.Assert.assertTrue;
3335
import static org.mockito.ArgumentMatchers.eq;
3436
import static org.mockito.Mockito.mock;
3537
import static org.mockito.Mockito.verify;
@@ -141,4 +143,28 @@ public void testJobMasterLeaderRetrieval() throws Exception {
141143
.notifyLeaderAddress(
142144
eq(jobManagerAddress2), eq(HighAvailabilityServices.DEFAULT_LEADER_ID));
143145
}
146+
147+
/**
148+
* Tests that the constructor properly validates null parameters and provides meaningful error messages.
149+
*/
150+
@Test
151+
public void testConstructorNullValidation() {
152+
// Test null resourceManagerAddress
153+
Exception exception = assertThrows(
154+
NullPointerException.class,
155+
() -> new StandaloneHaServices(null, dispatcherAddress, webMonitorAddress));
156+
assertTrue(exception.getMessage().contains("resourceManagerAddress"));
157+
158+
// Test null dispatcherAddress
159+
exception = assertThrows(
160+
NullPointerException.class,
161+
() -> new StandaloneHaServices(resourceManagerAddress, null, webMonitorAddress));
162+
assertTrue(exception.getMessage().contains("dispatcherAddress"));
163+
164+
// Test null clusterRestEndpointAddress
165+
exception = assertThrows(
166+
NullPointerException.class,
167+
() -> new StandaloneHaServices(resourceManagerAddress, dispatcherAddress, null));
168+
assertTrue(exception.getMessage().contains("clusterRestEndpointAddress"));
169+
}
144170
}

0 commit comments

Comments
 (0)