Search in sources :

Example 1 with NakadiSettings

use of org.zalando.nakadi.config.NakadiSettings in project nakadi by zalando.

the class SubscriptionValidationServiceTest method setUp.

@Before
public void setUp() throws InternalNakadiException {
    final NakadiSettings nakadiSettings = mock(NakadiSettings.class);
    when(nakadiSettings.getMaxSubscriptionPartitions()).thenReturn(MAX_SUBSCRIPTION_PARTITIONS);
    topicRepository = mock(TopicRepository.class);
    when(topicRepository.listPartitionNames(argThat(isOneOf(topicForET(ET1), topicForET(ET2), topicForET(ET3))))).thenReturn(ImmutableList.of(P0));
    etRepo = mock(EventTypeRepository.class);
    final Map<String, EventType> eventTypes = new HashMap<>();
    for (final String etName : new String[] { ET1, ET2, ET3 }) {
        final EventType eventType = new EventType();
        eventType.setName(etName);
        eventTypes.put(etName, eventType);
    }
    when(etRepo.findByNameO(any())).thenAnswer(invocation -> Optional.ofNullable(eventTypes.get(invocation.getArguments()[0])));
    final TimelineService timelineService = mock(TimelineService.class);
    for (final EventType et : eventTypes.values()) {
        final Timeline timeline = mock(Timeline.class);
        when(timeline.getTopic()).thenReturn(topicForET(et.getName()));
        when(timeline.getEventType()).thenReturn(et.getName());
        when(timelineService.getActiveTimeline(eq(et.getName()))).thenReturn(timeline);
    }
    when(timelineService.getTopicRepository((Timeline) any())).thenReturn(topicRepository);
    when(timelineService.getTopicRepository((EventType) any())).thenReturn(topicRepository);
    cursorConverter = mock(CursorConverter.class);
    subscriptionValidationService = new SubscriptionValidationService(timelineService, etRepo, nakadiSettings, cursorConverter);
    subscriptionBase = new SubscriptionBase();
    subscriptionBase.setEventTypes(ImmutableSet.of(ET1, ET2, ET3));
    subscriptionBase.setReadFrom(SubscriptionBase.InitialPosition.CURSORS);
}
Also used : SubscriptionBase(org.zalando.nakadi.domain.SubscriptionBase) Timeline(org.zalando.nakadi.domain.Timeline) EventType(org.zalando.nakadi.domain.EventType) HashMap(java.util.HashMap) EventTypeRepository(org.zalando.nakadi.repository.EventTypeRepository) TimelineService(org.zalando.nakadi.service.timeline.TimelineService) SubscriptionValidationService(org.zalando.nakadi.service.subscription.SubscriptionValidationService) TopicRepository(org.zalando.nakadi.repository.TopicRepository) NakadiSettings(org.zalando.nakadi.config.NakadiSettings) Before(org.junit.Before)

Example 2 with NakadiSettings

use of org.zalando.nakadi.config.NakadiSettings in project nakadi by zalando.

the class EventTypeControllerTestCase method init.

@Before
public void init() throws Exception {
    final NakadiSettings nakadiSettings = new NakadiSettings(0, 0, 0, TOPIC_RETENTION_TIME_MS, 0, 60, NAKADI_POLL_TIMEOUT, NAKADI_SEND_TIMEOUT, 0, NAKADI_EVENT_MAX_BYTES, NAKADI_SUBSCRIPTION_MAX_PARTITIONS, "service", "nakadi", "I am warning you");
    final PartitionsCalculator partitionsCalculator = new KafkaConfig().createPartitionsCalculator("t2.large", TestUtils.OBJECT_MAPPER, nakadiSettings);
    when(timelineService.getTopicRepository((Timeline) any())).thenReturn(topicRepository);
    when(timelineService.getTopicRepository((EventTypeBase) any())).thenReturn(topicRepository);
    when(transactionTemplate.execute(any())).thenAnswer(invocation -> {
        final TransactionCallback callback = (TransactionCallback) invocation.getArguments()[0];
        return callback.doInTransaction(null);
    });
    final EventTypeService eventTypeService = new EventTypeService(eventTypeRepository, timelineService, partitionResolver, enrichment, subscriptionRepository, schemaEvolutionService, partitionsCalculator, featureToggleService, authorizationValidator, timelineSync, transactionTemplate, nakadiSettings, nakadiKpiPublisher, "et-log-event-type");
    final EventTypeOptionsValidator eventTypeOptionsValidator = new EventTypeOptionsValidator(TOPIC_RETENTION_MIN_MS, TOPIC_RETENTION_MAX_MS);
    final EventTypeController controller = new EventTypeController(eventTypeService, featureToggleService, eventTypeOptionsValidator, applicationService, adminService, nakadiSettings);
    doReturn(randomUUID).when(uuid).randomUUID();
    doReturn(true).when(applicationService).exists(any());
    doReturn(true).when(featureToggleService).isFeatureEnabled(CHECK_PARTITIONS_KEYS);
    mockMvc = standaloneSetup(controller).setMessageConverters(new StringHttpMessageConverter(), TestUtils.JACKSON_2_HTTP_MESSAGE_CONVERTER).setCustomArgumentResolvers(new ClientResolver(settings, featureToggleService)).setControllerAdvice(new ExceptionHandling()).build();
}
Also used : TransactionCallback(org.springframework.transaction.support.TransactionCallback) PartitionsCalculator(org.zalando.nakadi.repository.kafka.PartitionsCalculator) EventTypeService(org.zalando.nakadi.service.EventTypeService) EventTypeOptionsValidator(org.zalando.nakadi.validation.EventTypeOptionsValidator) ClientResolver(org.zalando.nakadi.security.ClientResolver) NakadiSettings(org.zalando.nakadi.config.NakadiSettings) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter) KafkaConfig(org.zalando.nakadi.repository.kafka.KafkaConfig) Before(org.junit.Before)

Example 3 with NakadiSettings

use of org.zalando.nakadi.config.NakadiSettings in project nakadi by zalando.

the class KafkaRepositoryAT method setup.

@Before
public void setup() {
    nakadiSettings = new NakadiSettings(MAX_TOPIC_PARTITION_COUNT, DEFAULT_PARTITION_COUNT, DEFAULT_REPLICA_FACTOR, DEFAULT_TOPIC_RETENTION, DEFAULT_TOPIC_ROTATION, DEFAULT_COMMIT_TIMEOUT, NAKADI_POLL_TIMEOUT, NAKADI_SEND_TIMEOUT, TIMELINE_WAIT_TIMEOUT, NAKADI_EVENT_MAX_BYTES, NAKADI_SUBSCRIPTION_MAX_PARTITIONS, DEFAULT_ADMIN_DATA_TYPE, DEFAULT_ADMIN_VALUE, DEFAULT_WARN_ALL_DATA_ACCESS_MESSAGE);
    kafkaSettings = new KafkaSettings(KAFKA_REQUEST_TIMEOUT, KAFKA_BATCH_SIZE, KAFKA_LINGER_MS, KAFKA_ENABLE_AUTO_COMMIT);
    zookeeperSettings = new ZookeeperSettings(ZK_SESSION_TIMEOUT, ZK_CONNECTION_TIMEOUT);
    kafkaHelper = new KafkaTestHelper(KAFKA_URL);
    kafkaTopicRepository = createKafkaTopicRepository();
}
Also used : ZookeeperSettings(org.zalando.nakadi.repository.zookeeper.ZookeeperSettings) NakadiSettings(org.zalando.nakadi.config.NakadiSettings) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)3 NakadiSettings (org.zalando.nakadi.config.NakadiSettings)3 HashMap (java.util.HashMap)1 StringHttpMessageConverter (org.springframework.http.converter.StringHttpMessageConverter)1 TransactionCallback (org.springframework.transaction.support.TransactionCallback)1 EventType (org.zalando.nakadi.domain.EventType)1 SubscriptionBase (org.zalando.nakadi.domain.SubscriptionBase)1 Timeline (org.zalando.nakadi.domain.Timeline)1 EventTypeRepository (org.zalando.nakadi.repository.EventTypeRepository)1 TopicRepository (org.zalando.nakadi.repository.TopicRepository)1 KafkaConfig (org.zalando.nakadi.repository.kafka.KafkaConfig)1 PartitionsCalculator (org.zalando.nakadi.repository.kafka.PartitionsCalculator)1 ZookeeperSettings (org.zalando.nakadi.repository.zookeeper.ZookeeperSettings)1 ClientResolver (org.zalando.nakadi.security.ClientResolver)1 EventTypeService (org.zalando.nakadi.service.EventTypeService)1 SubscriptionValidationService (org.zalando.nakadi.service.subscription.SubscriptionValidationService)1 TimelineService (org.zalando.nakadi.service.timeline.TimelineService)1 EventTypeOptionsValidator (org.zalando.nakadi.validation.EventTypeOptionsValidator)1