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);
}
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();
}
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();
}
Aggregations