Skip to content

Commit

Permalink
added test case for standalone mode and error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mynecker committed Jul 17, 2024
1 parent 9b2547a commit da4e9a6
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.List;
import java.util.Optional;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
Expand All @@ -38,7 +39,7 @@ class ScanManagerHandleErrorTest {
private ScanStatusPublisher scanStatusPublisher;

@Test
void testScanManagerHandleError(){
void testScanManagerConnectedHandleError(){
when(eventPortalProperties.getOrganizationId()).thenReturn("orgId");
when(eventPortalProperties.getRuntimeAgentId()).thenReturn("runtimeAgentId");

Expand All @@ -54,7 +55,24 @@ void testScanManagerHandleError(){
verify(scanStatusPublisher, times(1)).sendOverallScanStatus(any(),any());
}

@Test
void testScanManagerStandaloneHandleError(){
when(eventPortalProperties.getOrganizationId()).thenReturn("orgId");
when(eventPortalProperties.getRuntimeAgentId()).thenReturn("runtimeAgentId");

RuntimeException mockEx = new RuntimeException("Mock Exception");

ScanManager scanManagerUnderTest = new ScanManager(
messagingServiceDelegateService,
scanService,
eventPortalProperties,
Optional.empty()
);
// should just do "nothing" and not throw an exception when scanStatusPublisher is not present
assertDoesNotThrow(() -> {
scanManagerUnderTest.handleError(mockEx, createScanCommandMessage());
});
}

private ScanCommandMessage createScanCommandMessage(){
return new ScanCommandMessage(
Expand Down

0 comments on commit da4e9a6

Please sign in to comment.