|
30 | 30 | import org.junit.Before; |
31 | 31 | import org.junit.Test; |
32 | 32 |
|
| 33 | +import static org.junit.Assert.assertThrows; |
| 34 | +import static org.junit.Assert.assertTrue; |
33 | 35 | import static org.mockito.ArgumentMatchers.eq; |
34 | 36 | import static org.mockito.Mockito.mock; |
35 | 37 | import static org.mockito.Mockito.verify; |
@@ -141,4 +143,28 @@ public void testJobMasterLeaderRetrieval() throws Exception { |
141 | 143 | .notifyLeaderAddress( |
142 | 144 | eq(jobManagerAddress2), eq(HighAvailabilityServices.DEFAULT_LEADER_ID)); |
143 | 145 | } |
| 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 | + } |
144 | 170 | } |
0 commit comments