Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public StandaloneHaServices(
checkNotNull(resourceManagerAddress, "resourceManagerAddress");
this.dispatcherAddress = checkNotNull(dispatcherAddress, "dispatcherAddress");
this.clusterRestEndpointAddress =
checkNotNull(clusterRestEndpointAddress, clusterRestEndpointAddress);
checkNotNull(clusterRestEndpointAddress, "clusterRestEndpointAddress");
}

// ------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
Expand Down Expand Up @@ -141,4 +143,36 @@ public void testJobMasterLeaderRetrieval() throws Exception {
.notifyLeaderAddress(
eq(jobManagerAddress2), eq(HighAvailabilityServices.DEFAULT_LEADER_ID));
}

/**
* Tests that the constructor properly validates null parameters and provides meaningful error
* messages.
*/
@Test
public void testConstructorNullValidation() {
// Test null resourceManagerAddress
Exception exception =
assertThrows(
NullPointerException.class,
() -> new StandaloneHaServices(null, dispatcherAddress, webMonitorAddress));
assertTrue(exception.getMessage().contains("resourceManagerAddress"));

// Test null dispatcherAddress
exception =
assertThrows(
NullPointerException.class,
() ->
new StandaloneHaServices(
resourceManagerAddress, null, webMonitorAddress));
assertTrue(exception.getMessage().contains("dispatcherAddress"));

// Test null clusterRestEndpointAddress
exception =
assertThrows(
NullPointerException.class,
() ->
new StandaloneHaServices(
resourceManagerAddress, dispatcherAddress, null));
assertTrue(exception.getMessage().contains("clusterRestEndpointAddress"));
}
}