use of org.apache.metron.common.system.FakeClock in project metron by apache.
the class AlertsUIServiceImplTest method setUp.
@BeforeEach
public void setUp() {
kafkaService = mock(KafkaService.class);
environment = mock(Environment.class);
userSettingsClient = mock(UserSettingsClient.class);
alertsUIService = new AlertsUIServiceImpl(kafkaService, environment, userSettingsClient);
// use a fake clock for testing
clock = new FakeClock();
clock.elapseSeconds(1000);
alertsUIService.setClock(clock);
// assume user1 is logged in for tests
Authentication authentication = Mockito.mock(Authentication.class);
UserDetails userDetails = Mockito.mock(UserDetails.class);
when(authentication.getPrincipal()).thenReturn(userDetails);
when(userDetails.getUsername()).thenReturn(user1);
SecurityContextHolder.getContext().setAuthentication(authentication);
}
Aggregations