Search in sources :

Example 6 with FakeClock

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);
}
Also used : KafkaService(org.apache.metron.rest.service.KafkaService) UserDetails(org.springframework.security.core.userdetails.UserDetails) UserSettingsClient(org.apache.metron.rest.user.UserSettingsClient) FakeClock(org.apache.metron.common.system.FakeClock) Authentication(org.springframework.security.core.Authentication) Environment(org.springframework.core.env.Environment) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

FakeClock (org.apache.metron.common.system.FakeClock)6 FileInputStream (java.io.FileInputStream)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 BaseEnrichmentBoltTest (org.apache.metron.test.bolt.BaseEnrichmentBoltTest)5 WriterConfiguration (org.apache.metron.common.configuration.writer.WriterConfiguration)4 BulkWriterResponse (org.apache.metron.common.writer.BulkWriterResponse)4 IndexingConfigurations (org.apache.metron.common.configuration.IndexingConfigurations)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 Test (org.junit.jupiter.api.Test)3 StandardCharsets (java.nio.charset.StandardCharsets)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Multiline (org.adrianwalker.multilinestring.Multiline)2 Level (org.apache.log4j.Level)2 Constants (org.apache.metron.common.Constants)2 BulkMessage (org.apache.metron.common.writer.BulkMessage)2 BulkMessageWriter (org.apache.metron.common.writer.BulkMessageWriter)2 MessageId (org.apache.metron.common.writer.MessageId)2 MessageGetters (org.apache.metron.storm.common.message.MessageGetters)2