Skip to content

Commit

Permalink
adding null check
Browse files Browse the repository at this point in the history
  • Loading branch information
heditar committed Dec 13, 2024
1 parent ad73ba1 commit 783939b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ protected Optional<Endpoint> findExistingEndpointForAnAgent(@NotNull final Agent
endpoint ->
Arrays.stream(endpoint.getIps())
.anyMatch(Arrays.asList(agent.getHost_ip_addrs())::contains)
&& endpoint.getExecutor() != null
&& CALDERA_EXECUTOR_TYPE.equals(endpoint.getExecutor().getType()))
.findFirst();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,13 @@ void test_findExistingEndpointForAnAgent_WITH_no_existing_endpoint() throws Exce
Optional<Endpoint> result = calderaExecutorService.findExistingEndpointForAnAgent(calderaAgent);
assertTrue(result.isEmpty());
}

@Test
void test_findExistingEndpointForAnAgent_WITH_1_enpdoint_with_null_executor() throws Exception {
randomEndpoint.setExecutor(null);
randomEndpoint.setHostname(CALDERA_AGENT_HOSTNAME);
randomEndpoint.setIps(new String[] {CALDERA_AGENT_IP});
Optional<Endpoint> result = calderaExecutorService.findExistingEndpointForAnAgent(calderaAgent);
assertEquals(calderaEndpoint, result.get());
}
}

0 comments on commit 783939b

Please sign in to comment.