From c114645bcceeb7d624fb26cb04610864900e0389 Mon Sep 17 00:00:00 2001 From: antban Date: Thu, 27 Jul 2017 16:41:03 +0200 Subject: [PATCH] Dmitry reformatted code. --- .../db/AbstractDbRepositoryTest.java | 10 ++-- .../repository/db/EventTypeCacheTestAT.java | 18 ++++--- .../db/EventTypeDbRepositoryTest.java | 6 +-- .../db/SubscriptionDbRepositoryTest.java | 2 +- .../org/zalando/nakadi/webservice/BaseAT.java | 4 +- .../nakadi/webservice/CursorsServiceAT.java | 30 ++++++----- .../nakadi/webservice/HealthCheckAT.java | 8 ++- .../webservice/PartitionsControllerAT.java | 4 +- .../webservice/hila/HilaRebalanceAT.java | 2 +- .../webservice/hila/SubscriptionAT.java | 48 +++++++++-------- .../SubscriptionConsumptionTest.java | 24 +++++---- .../timelines/TimelineConsumptionTest.java | 14 ++--- .../webservice/timelines/TimelineSyncAT.java | 21 ++++---- .../webservice/utils/TestStreamingClient.java | 18 ++++--- .../webservice/utils/ZookeeperTestUtils.java | 3 +- .../CursorOperationsController.java | 14 ++--- .../nakadi/controller/CursorsController.java | 28 +++++----- .../controller/HealthCheckController.java | 12 ++--- .../controller/PartitionsController.java | 18 ++++--- .../PostSubscriptionController.java | 18 ++++--- .../zalando/nakadi/domain/ConsumedEvent.java | 2 +- .../nakadi/domain/EventTypeStatistics.java | 2 +- .../zalando/nakadi/domain/NakadiCursor.java | 1 + .../domain/SubscriptionEventTypeStats.java | 5 +- .../org/zalando/nakadi/domain/Timeline.java | 7 +-- .../zalando/nakadi/domain/TopicPartition.java | 2 +- .../enrichment/EnrichmentsRegistry.java | 2 +- .../MetadataEnrichmentStrategy.java | 8 +-- .../partitioning/PartitionStrategy.java | 2 +- .../partitioning/RandomPartitionStrategy.java | 2 +- .../UserDefinedPartitionStrategy.java | 4 +- .../nakadi/repository/EventConsumer.java | 9 ++-- .../MultiTimelineEventConsumer.java | 31 +++++------ .../nakadi/repository/TopicRepository.java | 7 +-- .../nakadi/repository/db/EventTypeCache.java | 25 ++++----- .../repository/db/StorageDbRepository.java | 9 ++-- .../nakadi/repository/kafka/KafkaConfig.java | 3 +- .../nakadi/repository/kafka/KafkaCursor.java | 4 +- .../nakadi/repository/kafka/KafkaFactory.java | 15 +++--- .../kafka/KafkaTopicRepository.java | 54 ++++++++++--------- .../repository/kafka/NakadiKafkaConsumer.java | 13 ++--- .../kafka/PartitionsCalculator.java | 5 +- .../nakadi/service/CursorsService.java | 15 +++--- .../zalando/nakadi/service/EventStream.java | 18 ++++--- .../nakadi/service/EventStreamConfig.java | 7 +-- .../nakadi/service/EventStreamFactory.java | 3 +- .../service/EventTypeChangeListener.java | 11 ++-- .../converter/CursorConverterImpl.java | 9 ++-- .../subscription/ExactWeightRebalancer.java | 1 + .../subscription/StreamingContext.java | 17 +++--- .../SubscriptionStreamerFactory.java | 7 +-- .../SubscriptionValidationService.java | 13 ++--- .../service/subscription/model/Partition.java | 5 +- .../subscription/state/CleanupState.java | 3 +- .../subscription/state/ClosingState.java | 13 ++--- .../subscription/state/PartitionData.java | 13 ++--- .../subscription/state/StartingState.java | 15 +++--- .../service/subscription/state/State.java | 3 +- .../zk/AbstractZkSubscriptionClient.java | 30 ++++++----- .../subscription/zk/ChangeListener.java | 5 +- .../zk/NewZkSubscriptionClient.java | 14 ++--- .../subscription/zk/ZkSubscriptionClient.java | 7 +-- .../subscription/zk/ZkSubscriptionNode.java | 7 +-- .../nakadi/service/timeline/LocalLocking.java | 5 +- .../service/timeline/TimelineSyncImpl.java | 31 +++++------ .../nakadi/util/FeatureToggleService.java | 5 +- .../zalando/nakadi/util/JsonPathAccess.java | 2 +- .../nakadi/util/NakadiCollectionUtils.java | 1 + .../org/zalando/nakadi/util/TimeLogger.java | 2 +- .../nakadi/validation/EventTypeValidator.java | 2 +- .../nakadi/validation/EventValidator.java | 3 +- .../nakadi/validation/FieldNameMustBeSet.java | 1 - .../validation/RFC3339DateTimeValidator.java | 6 ++- .../validation/SchemaEvolutionService.java | 2 +- .../validation/schema/SchemaConstraint.java | 5 +- .../java/org/zalando/nakadi/view/Cursor.java | 1 + .../nakadi/view/SubscriptionCursor.java | 1 + .../view/SubscriptionCursorWithoutToken.java | 3 +- .../org/zalando/nakadi/view/TimelineView.java | 3 +- .../PostSubscriptionControllerTest.java | 32 +++++------ .../SubscriptionStreamControllerTest.java | 26 ++++----- .../nakadi/domain/BatchItemResponseTest.java | 2 +- .../zalando/nakadi/domain/EventTypeTest.java | 4 +- .../nakadi/enrichment/EnrichmentTest.java | 12 ++--- .../MetadataEnrichmentStrategyTest.java | 12 ++--- .../UserDefinedPartitionStrategyTest.java | 2 +- .../db/CachingEventTypeRepositoryTest.java | 4 +- .../repository/db/EventTypeCacheTest.java | 5 +- .../repository/kafka/KafkaFactoryTest.java | 7 +-- .../kafka/KafkaTopicRepositoryTest.java | 16 +++--- .../kafka/NakadiKafkaConsumerTest.java | 8 +-- .../kafka/PartitionsCalculatorTest.java | 6 ++- .../security/BasicModeAuthenticationTest.java | 3 +- .../org/zalando/nakadi/security/Endpoint.java | 8 +-- .../security/FullModeAuthenticationTest.java | 3 +- .../security/OffModeAuthenticationTest.java | 2 +- .../service/ClosedConnectionsCrutchTest.java | 8 +-- .../service/EventStreamConfigBuilderTest.java | 1 + .../service/EventTypeChangeListenerTest.java | 12 +++-- .../SubscriptionValidationServiceTest.java | 36 +++++++------ .../converter/CursorConverterImplTest.java | 6 ++- .../converter/VersionZeroConverterTest.java | 3 +- .../ExactWeightRebalancerTest.java | 10 ++-- .../subscription/StartingStateTest.java | 12 +++-- .../subscription/model/PartitionTest.java | 8 +-- .../subscription/state/PartitionDataTest.java | 6 ++- .../state/StreamingStateTest.java | 16 +++--- .../nakadi/util/FeatureToggleServiceTest.java | 4 +- .../nakadi/util/JsonPathAccessTest.java | 4 +- .../util/NakadiCollectionUtilsTest.java | 3 +- .../nakadi/util/PrincipalMockFactory.java | 4 +- .../zalando/nakadi/util/TimeLoggerTest.java | 3 +- .../RFC3339DateTimeValidatorTest.java | 3 +- .../SchemaEvolutionServiceTest.java | 2 +- 114 files changed, 603 insertions(+), 493 deletions(-) diff --git a/src/acceptance-test/java/org/zalando/nakadi/repository/db/AbstractDbRepositoryTest.java b/src/acceptance-test/java/org/zalando/nakadi/repository/db/AbstractDbRepositoryTest.java index 59019174cf..34a3f56606 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/repository/db/AbstractDbRepositoryTest.java +++ b/src/acceptance-test/java/org/zalando/nakadi/repository/db/AbstractDbRepositoryTest.java @@ -1,15 +1,17 @@ package org.zalando.nakadi.repository.db; import com.fasterxml.jackson.databind.ObjectMapper; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.stream.Stream; -import javax.sql.DataSource; import org.junit.After; import org.junit.Before; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.zalando.nakadi.config.JsonConfig; + +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.stream.Stream; + import static org.zalando.nakadi.webservice.BaseAT.POSTGRES_PWD; import static org.zalando.nakadi.webservice.BaseAT.POSTGRES_URL; import static org.zalando.nakadi.webservice.BaseAT.POSTGRES_USER; diff --git a/src/acceptance-test/java/org/zalando/nakadi/repository/db/EventTypeCacheTestAT.java b/src/acceptance-test/java/org/zalando/nakadi/repository/db/EventTypeCacheTestAT.java index 668c5c4ea5..41c988fc5f 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/repository/db/EventTypeCacheTestAT.java +++ b/src/acceptance-test/java/org/zalando/nakadi/repository/db/EventTypeCacheTestAT.java @@ -1,14 +1,6 @@ package org.zalando.nakadi.repository.db; import com.google.common.collect.ImmutableList; -import java.io.Closeable; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.TimeoutException; -import java.util.function.Consumer; import org.apache.curator.RetryPolicy; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; @@ -28,6 +20,16 @@ import org.zalando.nakadi.repository.EventTypeRepository; import org.zalando.nakadi.repository.zookeeper.ZooKeeperHolder; import org.zalando.nakadi.service.timeline.TimelineSync; + +import java.io.Closeable; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.TimeoutException; +import java.util.function.Consumer; + import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertNull; import static junit.framework.Assert.fail; diff --git a/src/acceptance-test/java/org/zalando/nakadi/repository/db/EventTypeDbRepositoryTest.java b/src/acceptance-test/java/org/zalando/nakadi/repository/db/EventTypeDbRepositoryTest.java index 22a235c37c..ac9fbad963 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/repository/db/EventTypeDbRepositoryTest.java +++ b/src/acceptance-test/java/org/zalando/nakadi/repository/db/EventTypeDbRepositoryTest.java @@ -1,6 +1,9 @@ package org.zalando.nakadi.repository.db; import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.Before; +import org.junit.Test; +import org.springframework.jdbc.support.rowset.SqlRowSet; import org.zalando.nakadi.config.JsonConfig; import org.zalando.nakadi.domain.EventCategory; import org.zalando.nakadi.domain.EventType; @@ -10,9 +13,6 @@ import org.zalando.nakadi.exceptions.NakadiException; import org.zalando.nakadi.exceptions.NoSuchEventTypeException; import org.zalando.nakadi.repository.EventTypeRepository; -import org.junit.Before; -import org.junit.Test; -import org.springframework.jdbc.support.rowset.SqlRowSet; import java.io.IOException; import java.util.List; diff --git a/src/acceptance-test/java/org/zalando/nakadi/repository/db/SubscriptionDbRepositoryTest.java b/src/acceptance-test/java/org/zalando/nakadi/repository/db/SubscriptionDbRepositoryTest.java index 4ebebe0a6a..01c1f151f7 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/repository/db/SubscriptionDbRepositoryTest.java +++ b/src/acceptance-test/java/org/zalando/nakadi/repository/db/SubscriptionDbRepositoryTest.java @@ -9,9 +9,9 @@ import org.zalando.nakadi.config.JsonConfig; import org.zalando.nakadi.domain.Subscription; import org.zalando.nakadi.domain.SubscriptionBase; -import org.zalando.nakadi.exceptions.runtime.DuplicatedSubscriptionException; import org.zalando.nakadi.exceptions.NoSuchSubscriptionException; import org.zalando.nakadi.exceptions.ServiceUnavailableException; +import org.zalando.nakadi.exceptions.runtime.DuplicatedSubscriptionException; import org.zalando.nakadi.util.HashGenerator; import org.zalando.nakadi.util.UUIDGenerator; import org.zalando.nakadi.utils.RandomSubscriptionBuilder; diff --git a/src/acceptance-test/java/org/zalando/nakadi/webservice/BaseAT.java b/src/acceptance-test/java/org/zalando/nakadi/webservice/BaseAT.java index aaeebf7fd4..b0883b09f2 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/webservice/BaseAT.java +++ b/src/acceptance-test/java/org/zalando/nakadi/webservice/BaseAT.java @@ -3,7 +3,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.jayway.restassured.RestAssured; import com.jayway.restassured.parsing.Parser; -import java.util.Optional; import org.junit.BeforeClass; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.DriverManagerDataSource; @@ -15,6 +14,9 @@ import org.zalando.nakadi.repository.db.StorageDbRepository; import org.zalando.nakadi.repository.db.TimelineDbRepository; import org.zalando.nakadi.utils.EventTypeTestBuilder; + +import java.util.Optional; + import static org.zalando.nakadi.utils.TestUtils.buildDefaultEventType; public abstract class BaseAT { diff --git a/src/acceptance-test/java/org/zalando/nakadi/webservice/CursorsServiceAT.java b/src/acceptance-test/java/org/zalando/nakadi/webservice/CursorsServiceAT.java index ec4104e1f2..418440df14 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/webservice/CursorsServiceAT.java +++ b/src/acceptance-test/java/org/zalando/nakadi/webservice/CursorsServiceAT.java @@ -1,23 +1,11 @@ package org.zalando.nakadi.webservice; -import static com.google.common.base.Charsets.UTF_8; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import static java.text.MessageFormat.format; -import java.util.List; import org.apache.curator.framework.CuratorFramework; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.MatcherAssert.assertThat; import org.junit.After; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import org.junit.Before; import org.junit.Test; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import org.mockito.stubbing.Answer; import org.zalando.nakadi.config.NakadiSettings; import org.zalando.nakadi.domain.EventType; @@ -37,11 +25,25 @@ import org.zalando.nakadi.service.subscription.zk.NewZkSubscriptionClient; import org.zalando.nakadi.service.subscription.zk.SubscriptionClientFactory; import org.zalando.nakadi.service.timeline.TimelineService; +import org.zalando.nakadi.view.SubscriptionCursorWithoutToken; +import org.zalando.nakadi.webservice.utils.ZookeeperTestUtils; + +import java.util.List; + +import static com.google.common.base.Charsets.UTF_8; +import static java.text.MessageFormat.format; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; import static org.zalando.nakadi.utils.TestUtils.createFakeTimeline; import static org.zalando.nakadi.utils.TestUtils.randomUUID; import static org.zalando.nakadi.utils.TestUtils.randomValidEventTypeName; -import org.zalando.nakadi.view.SubscriptionCursorWithoutToken; -import org.zalando.nakadi.webservice.utils.ZookeeperTestUtils; public class CursorsServiceAT extends BaseAT { diff --git a/src/acceptance-test/java/org/zalando/nakadi/webservice/HealthCheckAT.java b/src/acceptance-test/java/org/zalando/nakadi/webservice/HealthCheckAT.java index abe1af396f..0aab4195b0 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/webservice/HealthCheckAT.java +++ b/src/acceptance-test/java/org/zalando/nakadi/webservice/HealthCheckAT.java @@ -1,13 +1,11 @@ package org.zalando.nakadi.webservice; -import static org.hamcrest.Matchers.equalTo; - -import static com.jayway.restassured.RestAssured.given; - import org.apache.http.HttpStatus; - import org.junit.Test; +import static com.jayway.restassured.RestAssured.given; +import static org.hamcrest.Matchers.equalTo; + public class HealthCheckAT extends BaseAT { @Test(timeout = 5000) diff --git a/src/acceptance-test/java/org/zalando/nakadi/webservice/PartitionsControllerAT.java b/src/acceptance-test/java/org/zalando/nakadi/webservice/PartitionsControllerAT.java index 90bf290e93..919d03395c 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/webservice/PartitionsControllerAT.java +++ b/src/acceptance-test/java/org/zalando/nakadi/webservice/PartitionsControllerAT.java @@ -9,8 +9,9 @@ import org.junit.Test; import org.springframework.http.HttpStatus; import org.zalando.nakadi.domain.EventType; -import org.zalando.nakadi.view.Cursor; import org.zalando.nakadi.repository.kafka.KafkaTestHelper; +import org.zalando.nakadi.view.Cursor; +import org.zalando.nakadi.webservice.utils.NakadiTestUtils; import java.io.IOException; import java.util.List; @@ -18,7 +19,6 @@ import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; -import org.zalando.nakadi.webservice.utils.NakadiTestUtils; import static com.jayway.restassured.RestAssured.get; import static com.jayway.restassured.RestAssured.when; diff --git a/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/HilaRebalanceAT.java b/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/HilaRebalanceAT.java index 6dc1251442..8f5bfdc6ba 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/HilaRebalanceAT.java +++ b/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/HilaRebalanceAT.java @@ -5,8 +5,8 @@ import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.domain.Subscription; import org.zalando.nakadi.domain.SubscriptionBase; -import org.zalando.nakadi.view.SubscriptionCursor; import org.zalando.nakadi.utils.RandomSubscriptionBuilder; +import org.zalando.nakadi.view.SubscriptionCursor; import org.zalando.nakadi.webservice.BaseAT; import org.zalando.nakadi.webservice.utils.TestStreamingClient; diff --git a/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/SubscriptionAT.java b/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/SubscriptionAT.java index 48d3e71959..23f276174b 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/SubscriptionAT.java +++ b/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/SubscriptionAT.java @@ -6,28 +6,10 @@ import com.google.common.base.Charsets; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import static com.jayway.restassured.RestAssured.get; -import static com.jayway.restassured.RestAssured.given; -import static com.jayway.restassured.RestAssured.when; -import static com.jayway.restassured.http.ContentType.JSON; import com.jayway.restassured.response.Response; -import java.io.IOException; -import static java.text.MessageFormat.format; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import static java.util.stream.IntStream.range; import org.apache.curator.framework.CuratorFramework; import org.apache.http.HttpStatus; import org.apache.zookeeper.data.Stat; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.isEmptyString; -import static org.hamcrest.Matchers.not; -import static org.hamcrest.core.IsEqual.equalTo; import org.junit.Assert; import org.junit.Test; import org.zalando.nakadi.config.JsonConfig; @@ -43,21 +25,41 @@ import org.zalando.nakadi.repository.kafka.KafkaCursor; import org.zalando.nakadi.utils.JsonTestHelper; import org.zalando.nakadi.utils.RandomSubscriptionBuilder; -import static org.zalando.nakadi.utils.TestUtils.buildDefaultEventType; -import static org.zalando.nakadi.utils.TestUtils.randomUUID; -import static org.zalando.nakadi.utils.TestUtils.waitFor; import org.zalando.nakadi.view.Cursor; import org.zalando.nakadi.view.SubscriptionCursor; import org.zalando.nakadi.view.SubscriptionCursorWithoutToken; import org.zalando.nakadi.webservice.BaseAT; import org.zalando.nakadi.webservice.utils.NakadiTestUtils; +import org.zalando.nakadi.webservice.utils.TestStreamingClient; +import org.zalando.nakadi.webservice.utils.ZookeeperTestUtils; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import static com.jayway.restassured.RestAssured.get; +import static com.jayway.restassured.RestAssured.given; +import static com.jayway.restassured.RestAssured.when; +import static com.jayway.restassured.http.ContentType.JSON; +import static java.text.MessageFormat.format; +import static java.util.stream.IntStream.range; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.isEmptyString; +import static org.hamcrest.Matchers.not; +import static org.hamcrest.core.IsEqual.equalTo; +import static org.zalando.nakadi.utils.TestUtils.buildDefaultEventType; +import static org.zalando.nakadi.utils.TestUtils.randomUUID; +import static org.zalando.nakadi.utils.TestUtils.waitFor; import static org.zalando.nakadi.webservice.utils.NakadiTestUtils.createBusinessEventTypeWithPartitions; import static org.zalando.nakadi.webservice.utils.NakadiTestUtils.createSubscription; import static org.zalando.nakadi.webservice.utils.NakadiTestUtils.createSubscriptionForEventType; import static org.zalando.nakadi.webservice.utils.NakadiTestUtils.publishBusinessEventWithUserDefinedPartition; -import org.zalando.nakadi.webservice.utils.TestStreamingClient; import static org.zalando.nakadi.webservice.utils.TestStreamingClient.SESSION_ID_UNKNOWN; -import org.zalando.nakadi.webservice.utils.ZookeeperTestUtils; public class SubscriptionAT extends BaseAT { diff --git a/src/acceptance-test/java/org/zalando/nakadi/webservice/timelines/SubscriptionConsumptionTest.java b/src/acceptance-test/java/org/zalando/nakadi/webservice/timelines/SubscriptionConsumptionTest.java index 50164483f9..5d864c99c6 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/webservice/timelines/SubscriptionConsumptionTest.java +++ b/src/acceptance-test/java/org/zalando/nakadi/webservice/timelines/SubscriptionConsumptionTest.java @@ -1,15 +1,5 @@ package org.zalando.nakadi.webservice.timelines; -import java.io.IOException; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Consumer; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import java.util.stream.Stream; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -20,12 +10,24 @@ import org.zalando.nakadi.view.SubscriptionCursorWithoutToken; import org.zalando.nakadi.webservice.BaseAT; import org.zalando.nakadi.webservice.hila.StreamBatch; +import org.zalando.nakadi.webservice.utils.TestStreamingClient; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.Stream; + import static org.zalando.nakadi.webservice.utils.NakadiTestUtils.createEventType; import static org.zalando.nakadi.webservice.utils.NakadiTestUtils.createSubscription; import static org.zalando.nakadi.webservice.utils.NakadiTestUtils.createTimeline; import static org.zalando.nakadi.webservice.utils.NakadiTestUtils.deleteTimeline; import static org.zalando.nakadi.webservice.utils.NakadiTestUtils.publishEvent; -import org.zalando.nakadi.webservice.utils.TestStreamingClient; public class SubscriptionConsumptionTest { diff --git a/src/acceptance-test/java/org/zalando/nakadi/webservice/timelines/TimelineConsumptionTest.java b/src/acceptance-test/java/org/zalando/nakadi/webservice/timelines/TimelineConsumptionTest.java index 4051ad1455..233bdc76bd 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/webservice/timelines/TimelineConsumptionTest.java +++ b/src/acceptance-test/java/org/zalando/nakadi/webservice/timelines/TimelineConsumptionTest.java @@ -3,9 +3,14 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; -import static com.jayway.restassured.RestAssured.given; import com.jayway.restassured.response.Header; import com.jayway.restassured.response.Response; +import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.zalando.nakadi.domain.EventType; + import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -14,11 +19,8 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import java.util.stream.IntStream; -import org.apache.http.HttpStatus; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.zalando.nakadi.domain.EventType; + +import static com.jayway.restassured.RestAssured.given; import static org.zalando.nakadi.webservice.utils.NakadiTestUtils.createEventType; import static org.zalando.nakadi.webservice.utils.NakadiTestUtils.createTimeline; import static org.zalando.nakadi.webservice.utils.NakadiTestUtils.deleteTimeline; diff --git a/src/acceptance-test/java/org/zalando/nakadi/webservice/timelines/TimelineSyncAT.java b/src/acceptance-test/java/org/zalando/nakadi/webservice/timelines/TimelineSyncAT.java index 04659ca664..a148b301f2 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/webservice/timelines/TimelineSyncAT.java +++ b/src/acceptance-test/java/org/zalando/nakadi/webservice/timelines/TimelineSyncAT.java @@ -1,15 +1,5 @@ package org.zalando.nakadi.webservice.timelines; -import java.io.Closeable; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Consumer; import org.apache.curator.framework.CuratorFramework; import org.junit.AfterClass; import org.junit.Assert; @@ -24,6 +14,17 @@ import org.zalando.nakadi.webservice.BaseAT; import org.zalando.nakadi.webservice.utils.ZookeeperTestUtils; +import java.io.Closeable; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Consumer; + public class TimelineSyncAT extends BaseAT { private static final CuratorFramework CURATOR = ZookeeperTestUtils.createCurator(ZOOKEEPER_URL); private static final ArrayList DELAYED_RUNS = new ArrayList<>(); diff --git a/src/acceptance-test/java/org/zalando/nakadi/webservice/utils/TestStreamingClient.java b/src/acceptance-test/java/org/zalando/nakadi/webservice/utils/TestStreamingClient.java index 9780afd345..b763428e17 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/webservice/utils/TestStreamingClient.java +++ b/src/acceptance-test/java/org/zalando/nakadi/webservice/utils/TestStreamingClient.java @@ -3,6 +3,14 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Lists; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.zalando.nakadi.config.JsonConfig; +import org.zalando.nakadi.view.SubscriptionCursor; +import org.zalando.nakadi.webservice.BaseAT; +import org.zalando.nakadi.webservice.hila.StreamBatch; + +import javax.annotation.Nullable; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -10,7 +18,6 @@ import java.net.HttpURLConnection; import java.net.SocketTimeoutException; import java.net.URL; -import static java.text.MessageFormat.format; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -19,13 +26,8 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CountDownLatch; import java.util.function.Consumer; -import javax.annotation.Nullable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.zalando.nakadi.config.JsonConfig; -import org.zalando.nakadi.view.SubscriptionCursor; -import org.zalando.nakadi.webservice.BaseAT; -import org.zalando.nakadi.webservice.hila.StreamBatch; + +import static java.text.MessageFormat.format; public class TestStreamingClient implements Runnable { diff --git a/src/acceptance-test/java/org/zalando/nakadi/webservice/utils/ZookeeperTestUtils.java b/src/acceptance-test/java/org/zalando/nakadi/webservice/utils/ZookeeperTestUtils.java index e7842a4b6e..8e5facc6e2 100644 --- a/src/acceptance-test/java/org/zalando/nakadi/webservice/utils/ZookeeperTestUtils.java +++ b/src/acceptance-test/java/org/zalando/nakadi/webservice/utils/ZookeeperTestUtils.java @@ -1,10 +1,11 @@ package org.zalando.nakadi.webservice.utils; -import java.util.concurrent.TimeUnit; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.retry.RetryNTimes; +import java.util.concurrent.TimeUnit; + public class ZookeeperTestUtils { private ZookeeperTestUtils() { diff --git a/src/main/java/org/zalando/nakadi/controller/CursorOperationsController.java b/src/main/java/org/zalando/nakadi/controller/CursorOperationsController.java index f837c362b3..b746322573 100644 --- a/src/main/java/org/zalando/nakadi/controller/CursorOperationsController.java +++ b/src/main/java/org/zalando/nakadi/controller/CursorOperationsController.java @@ -1,15 +1,9 @@ package org.zalando.nakadi.controller; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; -import javax.validation.Valid; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import static org.springframework.http.HttpStatus.OK; import org.springframework.http.ResponseEntity; -import static org.springframework.http.ResponseEntity.status; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; @@ -45,6 +39,14 @@ import org.zalando.problem.Problem; import org.zalando.problem.spring.web.advice.Responses; +import javax.validation.Valid; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; + +import static org.springframework.http.HttpStatus.OK; +import static org.springframework.http.ResponseEntity.status; + @RestController public class CursorOperationsController { diff --git a/src/main/java/org/zalando/nakadi/controller/CursorsController.java b/src/main/java/org/zalando/nakadi/controller/CursorsController.java index 55ca20306c..4e81f28dba 100644 --- a/src/main/java/org/zalando/nakadi/controller/CursorsController.java +++ b/src/main/java/org/zalando/nakadi/controller/CursorsController.java @@ -1,20 +1,9 @@ package org.zalando.nakadi.controller; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.ws.rs.core.Response; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import static org.springframework.http.HttpStatus.OK; import org.springframework.http.ResponseEntity; -import static org.springframework.http.ResponseEntity.noContent; -import static org.springframework.http.ResponseEntity.ok; -import static org.springframework.http.ResponseEntity.status; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.PathVariable; @@ -41,15 +30,28 @@ import org.zalando.nakadi.service.CursorTokenService; import org.zalando.nakadi.service.CursorsService; import org.zalando.nakadi.util.FeatureToggleService; -import static org.zalando.nakadi.util.FeatureToggleService.Feature.HIGH_LEVEL_API; import org.zalando.nakadi.util.TimeLogger; import org.zalando.nakadi.view.CursorCommitResult; import org.zalando.nakadi.view.SubscriptionCursor; import org.zalando.nakadi.view.SubscriptionCursorWithoutToken; import org.zalando.problem.MoreStatus; -import static org.zalando.problem.MoreStatus.UNPROCESSABLE_ENTITY; import org.zalando.problem.Problem; import org.zalando.problem.spring.web.advice.Responses; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import static org.springframework.http.HttpStatus.OK; +import static org.springframework.http.ResponseEntity.noContent; +import static org.springframework.http.ResponseEntity.ok; +import static org.springframework.http.ResponseEntity.status; +import static org.zalando.nakadi.util.FeatureToggleService.Feature.HIGH_LEVEL_API; +import static org.zalando.problem.MoreStatus.UNPROCESSABLE_ENTITY; import static org.zalando.problem.spring.web.advice.Responses.create; @RestController diff --git a/src/main/java/org/zalando/nakadi/controller/HealthCheckController.java b/src/main/java/org/zalando/nakadi/controller/HealthCheckController.java index 1f336432ac..0daaa19bb0 100644 --- a/src/main/java/org/zalando/nakadi/controller/HealthCheckController.java +++ b/src/main/java/org/zalando/nakadi/controller/HealthCheckController.java @@ -1,16 +1,14 @@ package org.zalando.nakadi.controller; -import static org.springframework.http.ResponseEntity.ok; - -import static org.springframework.web.bind.annotation.RequestMethod.GET; - -import javax.ws.rs.core.MediaType; - import org.springframework.http.ResponseEntity; - import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import javax.ws.rs.core.MediaType; + +import static org.springframework.http.ResponseEntity.ok; +import static org.springframework.web.bind.annotation.RequestMethod.GET; + @RestController @RequestMapping(value = "/health", produces = MediaType.TEXT_PLAIN) public class HealthCheckController { diff --git a/src/main/java/org/zalando/nakadi/controller/PartitionsController.java b/src/main/java/org/zalando/nakadi/controller/PartitionsController.java index 7f25c1b14a..129fe77d7a 100644 --- a/src/main/java/org/zalando/nakadi/controller/PartitionsController.java +++ b/src/main/java/org/zalando/nakadi/controller/PartitionsController.java @@ -1,18 +1,10 @@ package org.zalando.nakadi.controller; import com.google.common.collect.Lists; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import javax.ws.rs.core.Response; -import static javax.ws.rs.core.Response.Status.NOT_FOUND; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; -import static org.springframework.http.ResponseEntity.ok; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -44,6 +36,16 @@ import org.zalando.problem.MoreStatus; import org.zalando.problem.Problem; import org.zalando.problem.spring.web.advice.Responses; + +import javax.annotation.Nullable; +import javax.ws.rs.core.Response; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import static javax.ws.rs.core.Response.Status.NOT_FOUND; +import static org.springframework.http.ResponseEntity.ok; import static org.zalando.problem.spring.web.advice.Responses.create; @RestController diff --git a/src/main/java/org/zalando/nakadi/controller/PostSubscriptionController.java b/src/main/java/org/zalando/nakadi/controller/PostSubscriptionController.java index 0eb5c2a866..010ff020f3 100644 --- a/src/main/java/org/zalando/nakadi/controller/PostSubscriptionController.java +++ b/src/main/java/org/zalando/nakadi/controller/PostSubscriptionController.java @@ -1,14 +1,9 @@ package org.zalando.nakadi.controller; -import javax.validation.Valid; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.Response; -import static javax.ws.rs.core.Response.Status.NOT_IMPLEMENTED; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import static org.springframework.http.HttpStatus.OK; import org.springframework.http.ResponseEntity; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.ExceptionHandler; @@ -34,13 +29,20 @@ import org.zalando.nakadi.service.AuthorizationValidator; import org.zalando.nakadi.service.subscription.SubscriptionService; import org.zalando.nakadi.util.FeatureToggleService; -import static org.zalando.nakadi.util.FeatureToggleService.Feature.CHECK_OWNING_APPLICATION; -import static org.zalando.nakadi.util.FeatureToggleService.Feature.DISABLE_SUBSCRIPTION_CREATION; -import static org.zalando.nakadi.util.FeatureToggleService.Feature.HIGH_LEVEL_API; import org.zalando.problem.MoreStatus; import org.zalando.problem.Problem; import org.zalando.problem.spring.web.advice.Responses; +import javax.validation.Valid; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.Response; + +import static javax.ws.rs.core.Response.Status.NOT_IMPLEMENTED; +import static org.springframework.http.HttpStatus.OK; +import static org.zalando.nakadi.util.FeatureToggleService.Feature.CHECK_OWNING_APPLICATION; +import static org.zalando.nakadi.util.FeatureToggleService.Feature.DISABLE_SUBSCRIPTION_CREATION; +import static org.zalando.nakadi.util.FeatureToggleService.Feature.HIGH_LEVEL_API; + @RestController public class PostSubscriptionController { diff --git a/src/main/java/org/zalando/nakadi/domain/ConsumedEvent.java b/src/main/java/org/zalando/nakadi/domain/ConsumedEvent.java index efedf74525..2e37ce2f14 100644 --- a/src/main/java/org/zalando/nakadi/domain/ConsumedEvent.java +++ b/src/main/java/org/zalando/nakadi/domain/ConsumedEvent.java @@ -1,7 +1,7 @@ package org.zalando.nakadi.domain; -import java.util.Objects; import javax.annotation.concurrent.Immutable; +import java.util.Objects; @Immutable public class ConsumedEvent { diff --git a/src/main/java/org/zalando/nakadi/domain/EventTypeStatistics.java b/src/main/java/org/zalando/nakadi/domain/EventTypeStatistics.java index fc0f83dfea..6e2d022fce 100644 --- a/src/main/java/org/zalando/nakadi/domain/EventTypeStatistics.java +++ b/src/main/java/org/zalando/nakadi/domain/EventTypeStatistics.java @@ -1,8 +1,8 @@ package org.zalando.nakadi.domain; -import java.util.Objects; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; +import java.util.Objects; public class EventTypeStatistics { @NotNull diff --git a/src/main/java/org/zalando/nakadi/domain/NakadiCursor.java b/src/main/java/org/zalando/nakadi/domain/NakadiCursor.java index 33c057bb6f..0f1d9aaf89 100644 --- a/src/main/java/org/zalando/nakadi/domain/NakadiCursor.java +++ b/src/main/java/org/zalando/nakadi/domain/NakadiCursor.java @@ -1,6 +1,7 @@ package org.zalando.nakadi.domain; import com.google.common.base.Preconditions; + import java.util.Objects; public class NakadiCursor implements Comparable { diff --git a/src/main/java/org/zalando/nakadi/domain/SubscriptionEventTypeStats.java b/src/main/java/org/zalando/nakadi/domain/SubscriptionEventTypeStats.java index b75e634550..5dcd01008d 100644 --- a/src/main/java/org/zalando/nakadi/domain/SubscriptionEventTypeStats.java +++ b/src/main/java/org/zalando/nakadi/domain/SubscriptionEventTypeStats.java @@ -2,10 +2,11 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Collections; -import java.util.Set; + import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; +import java.util.Collections; +import java.util.Set; @Immutable public class SubscriptionEventTypeStats { diff --git a/src/main/java/org/zalando/nakadi/domain/Timeline.java b/src/main/java/org/zalando/nakadi/domain/Timeline.java index c912abbf48..dca8f36901 100644 --- a/src/main/java/org/zalando/nakadi/domain/Timeline.java +++ b/src/main/java/org/zalando/nakadi/domain/Timeline.java @@ -1,12 +1,13 @@ package org.zalando.nakadi.domain; +import org.zalando.nakadi.repository.kafka.KafkaCursor; +import org.zalando.nakadi.util.UUIDGenerator; + +import javax.annotation.Nullable; import java.util.Date; import java.util.List; import java.util.Objects; import java.util.UUID; -import javax.annotation.Nullable; -import org.zalando.nakadi.repository.kafka.KafkaCursor; -import org.zalando.nakadi.util.UUIDGenerator; public class Timeline { diff --git a/src/main/java/org/zalando/nakadi/domain/TopicPartition.java b/src/main/java/org/zalando/nakadi/domain/TopicPartition.java index 6fcebf35e2..c2ba032770 100644 --- a/src/main/java/org/zalando/nakadi/domain/TopicPartition.java +++ b/src/main/java/org/zalando/nakadi/domain/TopicPartition.java @@ -1,7 +1,7 @@ package org.zalando.nakadi.domain; -import java.util.Objects; import javax.annotation.concurrent.Immutable; +import java.util.Objects; @Immutable public class TopicPartition { diff --git a/src/main/java/org/zalando/nakadi/enrichment/EnrichmentsRegistry.java b/src/main/java/org/zalando/nakadi/enrichment/EnrichmentsRegistry.java index 3a105f8cad..c20f96745e 100644 --- a/src/main/java/org/zalando/nakadi/enrichment/EnrichmentsRegistry.java +++ b/src/main/java/org/zalando/nakadi/enrichment/EnrichmentsRegistry.java @@ -1,8 +1,8 @@ package org.zalando.nakadi.enrichment; import com.google.common.collect.ImmutableMap; -import org.zalando.nakadi.domain.EnrichmentStrategyDescriptor; import org.springframework.stereotype.Component; +import org.zalando.nakadi.domain.EnrichmentStrategyDescriptor; import java.util.Map; diff --git a/src/main/java/org/zalando/nakadi/enrichment/MetadataEnrichmentStrategy.java b/src/main/java/org/zalando/nakadi/enrichment/MetadataEnrichmentStrategy.java index ec4e154fe1..ec8221703f 100644 --- a/src/main/java/org/zalando/nakadi/enrichment/MetadataEnrichmentStrategy.java +++ b/src/main/java/org/zalando/nakadi/enrichment/MetadataEnrichmentStrategy.java @@ -1,13 +1,13 @@ package org.zalando.nakadi.enrichment; -import org.zalando.nakadi.domain.BatchItem; -import org.zalando.nakadi.domain.EventType; -import org.zalando.nakadi.exceptions.EnrichmentException; -import org.zalando.nakadi.util.FlowIdUtils; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.json.JSONException; import org.json.JSONObject; +import org.zalando.nakadi.domain.BatchItem; +import org.zalando.nakadi.domain.EventType; +import org.zalando.nakadi.exceptions.EnrichmentException; +import org.zalando.nakadi.util.FlowIdUtils; public class MetadataEnrichmentStrategy implements EnrichmentStrategy { @Override diff --git a/src/main/java/org/zalando/nakadi/partitioning/PartitionStrategy.java b/src/main/java/org/zalando/nakadi/partitioning/PartitionStrategy.java index 9a36b910f2..681ccd8b5f 100644 --- a/src/main/java/org/zalando/nakadi/partitioning/PartitionStrategy.java +++ b/src/main/java/org/zalando/nakadi/partitioning/PartitionStrategy.java @@ -1,8 +1,8 @@ package org.zalando.nakadi.partitioning; +import org.json.JSONObject; import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.exceptions.PartitioningException; -import org.json.JSONObject; import java.util.List; diff --git a/src/main/java/org/zalando/nakadi/partitioning/RandomPartitionStrategy.java b/src/main/java/org/zalando/nakadi/partitioning/RandomPartitionStrategy.java index 104c22adb6..10efcf138d 100644 --- a/src/main/java/org/zalando/nakadi/partitioning/RandomPartitionStrategy.java +++ b/src/main/java/org/zalando/nakadi/partitioning/RandomPartitionStrategy.java @@ -1,7 +1,7 @@ package org.zalando.nakadi.partitioning; -import org.zalando.nakadi.domain.EventType; import org.json.JSONObject; +import org.zalando.nakadi.domain.EventType; import java.util.List; import java.util.Random; diff --git a/src/main/java/org/zalando/nakadi/partitioning/UserDefinedPartitionStrategy.java b/src/main/java/org/zalando/nakadi/partitioning/UserDefinedPartitionStrategy.java index 60bcf0bf88..265d104e57 100644 --- a/src/main/java/org/zalando/nakadi/partitioning/UserDefinedPartitionStrategy.java +++ b/src/main/java/org/zalando/nakadi/partitioning/UserDefinedPartitionStrategy.java @@ -1,9 +1,9 @@ package org.zalando.nakadi.partitioning; -import org.zalando.nakadi.domain.EventType; -import org.zalando.nakadi.exceptions.PartitioningException; import org.json.JSONException; import org.json.JSONObject; +import org.zalando.nakadi.domain.EventType; +import org.zalando.nakadi.exceptions.PartitioningException; import java.util.List; diff --git a/src/main/java/org/zalando/nakadi/repository/EventConsumer.java b/src/main/java/org/zalando/nakadi/repository/EventConsumer.java index cc56fcaa6a..4b27f7bdb0 100644 --- a/src/main/java/org/zalando/nakadi/repository/EventConsumer.java +++ b/src/main/java/org/zalando/nakadi/repository/EventConsumer.java @@ -1,9 +1,5 @@ package org.zalando.nakadi.repository; -import java.io.Closeable; -import java.util.Collection; -import java.util.List; -import java.util.Set; import org.zalando.nakadi.domain.ConsumedEvent; import org.zalando.nakadi.domain.EventTypePartition; import org.zalando.nakadi.domain.NakadiCursor; @@ -11,6 +7,11 @@ import org.zalando.nakadi.exceptions.InvalidCursorException; import org.zalando.nakadi.exceptions.NakadiException; +import java.io.Closeable; +import java.util.Collection; +import java.util.List; +import java.util.Set; + public interface EventConsumer extends Closeable { List readEvents(); diff --git a/src/main/java/org/zalando/nakadi/repository/MultiTimelineEventConsumer.java b/src/main/java/org/zalando/nakadi/repository/MultiTimelineEventConsumer.java index 1ce94f5242..f96352a7d5 100644 --- a/src/main/java/org/zalando/nakadi/repository/MultiTimelineEventConsumer.java +++ b/src/main/java/org/zalando/nakadi/repository/MultiTimelineEventConsumer.java @@ -1,5 +1,21 @@ package org.zalando.nakadi.repository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.zalando.nakadi.domain.ConsumedEvent; +import org.zalando.nakadi.domain.EventTypePartition; +import org.zalando.nakadi.domain.NakadiCursor; +import org.zalando.nakadi.domain.PartitionStatistics; +import org.zalando.nakadi.domain.Timeline; +import org.zalando.nakadi.domain.TopicPartition; +import org.zalando.nakadi.exceptions.InvalidCursorException; +import org.zalando.nakadi.exceptions.NakadiException; +import org.zalando.nakadi.exceptions.NakadiRuntimeException; +import org.zalando.nakadi.exceptions.ServiceUnavailableException; +import org.zalando.nakadi.service.timeline.TimelineService; +import org.zalando.nakadi.service.timeline.TimelineSync; +import org.zalando.nakadi.util.NakadiCollectionUtils; + import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -17,21 +33,6 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.zalando.nakadi.domain.ConsumedEvent; -import org.zalando.nakadi.domain.EventTypePartition; -import org.zalando.nakadi.domain.NakadiCursor; -import org.zalando.nakadi.domain.PartitionStatistics; -import org.zalando.nakadi.domain.Timeline; -import org.zalando.nakadi.domain.TopicPartition; -import org.zalando.nakadi.exceptions.InvalidCursorException; -import org.zalando.nakadi.exceptions.NakadiException; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; -import org.zalando.nakadi.exceptions.ServiceUnavailableException; -import org.zalando.nakadi.service.timeline.TimelineService; -import org.zalando.nakadi.service.timeline.TimelineSync; -import org.zalando.nakadi.util.NakadiCollectionUtils; public class MultiTimelineEventConsumer implements EventConsumer.ReassignableEventConsumer { private final String clientId; diff --git a/src/main/java/org/zalando/nakadi/repository/TopicRepository.java b/src/main/java/org/zalando/nakadi/repository/TopicRepository.java index 130a2545da..edcc5e83f7 100644 --- a/src/main/java/org/zalando/nakadi/repository/TopicRepository.java +++ b/src/main/java/org/zalando/nakadi/repository/TopicRepository.java @@ -1,8 +1,5 @@ package org.zalando.nakadi.repository; -import java.util.Collection; -import java.util.List; -import java.util.Optional; import org.zalando.nakadi.domain.BatchItem; import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.PartitionEndStatistics; @@ -17,6 +14,10 @@ import org.zalando.nakadi.exceptions.runtime.TopicConfigException; import org.zalando.nakadi.exceptions.runtime.TopicRepositoryException; +import java.util.Collection; +import java.util.List; +import java.util.Optional; + public interface TopicRepository { String createTopic(int partitionCount, Long retentionTimeMs) throws TopicCreationException; diff --git a/src/main/java/org/zalando/nakadi/repository/db/EventTypeCache.java b/src/main/java/org/zalando/nakadi/repository/db/EventTypeCache.java index 48d30c6b6b..cd513013b6 100644 --- a/src/main/java/org/zalando/nakadi/repository/db/EventTypeCache.java +++ b/src/main/java/org/zalando/nakadi/repository/db/EventTypeCache.java @@ -5,18 +5,6 @@ import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableList; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock; -import java.util.function.Consumer; -import java.util.stream.Collectors; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.recipes.cache.PathChildrenCache; import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; @@ -35,6 +23,19 @@ import org.zalando.nakadi.validation.EventTypeValidator; import org.zalando.nakadi.validation.EventValidation; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.function.Consumer; +import java.util.stream.Collectors; + public class EventTypeCache { public static final String ZKNODE_PATH = "/nakadi/event_types"; diff --git a/src/main/java/org/zalando/nakadi/repository/db/StorageDbRepository.java b/src/main/java/org/zalando/nakadi/repository/db/StorageDbRepository.java index 1fadac0732..e79e6343ff 100644 --- a/src/main/java/org/zalando/nakadi/repository/db/StorageDbRepository.java +++ b/src/main/java/org/zalando/nakadi/repository/db/StorageDbRepository.java @@ -2,10 +2,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.sql.SQLException; -import java.util.List; -import java.util.Optional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataAccessException; import org.springframework.dao.DataIntegrityViolationException; @@ -20,6 +16,11 @@ import org.zalando.nakadi.exceptions.runtime.RepositoryProblemException; import org.zalando.nakadi.exceptions.runtime.StorageIsUsedException; +import java.io.IOException; +import java.sql.SQLException; +import java.util.List; +import java.util.Optional; + @DB @Repository public class StorageDbRepository extends AbstractDbRepository { diff --git a/src/main/java/org/zalando/nakadi/repository/kafka/KafkaConfig.java b/src/main/java/org/zalando/nakadi/repository/kafka/KafkaConfig.java index d1dbf35a01..6c014ff7fb 100644 --- a/src/main/java/org/zalando/nakadi/repository/kafka/KafkaConfig.java +++ b/src/main/java/org/zalando/nakadi/repository/kafka/KafkaConfig.java @@ -1,7 +1,6 @@ package org.zalando.nakadi.repository.kafka; import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -10,6 +9,8 @@ import org.zalando.nakadi.config.NakadiSettings; import org.zalando.nakadi.repository.zookeeper.ZookeeperConfig; +import java.io.IOException; + @Configuration @Import(ZookeeperConfig.class) @Profile("!test") diff --git a/src/main/java/org/zalando/nakadi/repository/kafka/KafkaCursor.java b/src/main/java/org/zalando/nakadi/repository/kafka/KafkaCursor.java index e70a8436b3..fad1ae8169 100644 --- a/src/main/java/org/zalando/nakadi/repository/kafka/KafkaCursor.java +++ b/src/main/java/org/zalando/nakadi/repository/kafka/KafkaCursor.java @@ -1,9 +1,11 @@ package org.zalando.nakadi.repository.kafka; -import java.util.Objects; import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.Timeline; import org.zalando.nakadi.exceptions.InvalidCursorException; + +import java.util.Objects; + import static org.zalando.nakadi.domain.CursorError.INVALID_FORMAT; import static org.zalando.nakadi.domain.CursorError.PARTITION_NOT_FOUND; diff --git a/src/main/java/org/zalando/nakadi/repository/kafka/KafkaFactory.java b/src/main/java/org/zalando/nakadi/repository/kafka/KafkaFactory.java index 639f2ba69a..410d29c108 100644 --- a/src/main/java/org/zalando/nakadi/repository/kafka/KafkaFactory.java +++ b/src/main/java/org/zalando/nakadi/repository/kafka/KafkaFactory.java @@ -2,6 +2,14 @@ import com.codahale.metrics.Counter; import com.codahale.metrics.MetricRegistry; +import org.apache.kafka.clients.consumer.Consumer; +import org.apache.kafka.clients.consumer.KafkaConsumer; +import org.apache.kafka.clients.producer.KafkaProducer; +import org.apache.kafka.clients.producer.Producer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.Nullable; import java.util.Map; import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; @@ -9,13 +17,6 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; -import javax.annotation.Nullable; -import org.apache.kafka.clients.consumer.Consumer; -import org.apache.kafka.clients.consumer.KafkaConsumer; -import org.apache.kafka.clients.producer.KafkaProducer; -import org.apache.kafka.clients.producer.Producer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class KafkaFactory { diff --git a/src/main/java/org/zalando/nakadi/repository/kafka/KafkaTopicRepository.java b/src/main/java/org/zalando/nakadi/repository/kafka/KafkaTopicRepository.java index 996b4be84d..a56d86ec9c 100644 --- a/src/main/java/org/zalando/nakadi/repository/kafka/KafkaTopicRepository.java +++ b/src/main/java/org/zalando/nakadi/repository/kafka/KafkaTopicRepository.java @@ -1,28 +1,6 @@ package org.zalando.nakadi.repository.kafka; import com.google.common.base.Preconditions; -import static com.google.common.collect.Lists.newArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import static java.util.Collections.unmodifiableList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Properties; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.stream.Collectors; -import static java.util.stream.Collectors.toList; -import java.util.stream.IntStream; -import java.util.stream.Stream; -import javax.annotation.Nullable; import kafka.admin.AdminUtils; import kafka.common.TopicExistsException; import kafka.server.ConfigType; @@ -41,10 +19,6 @@ import org.slf4j.LoggerFactory; import org.zalando.nakadi.config.NakadiSettings; import org.zalando.nakadi.domain.BatchItem; -import static org.zalando.nakadi.domain.CursorError.NULL_OFFSET; -import static org.zalando.nakadi.domain.CursorError.NULL_PARTITION; -import static org.zalando.nakadi.domain.CursorError.PARTITION_NOT_FOUND; -import static org.zalando.nakadi.domain.CursorError.UNAVAILABLE; import org.zalando.nakadi.domain.EventPublishingStatus; import org.zalando.nakadi.domain.EventPublishingStep; import org.zalando.nakadi.domain.NakadiCursor; @@ -66,6 +40,34 @@ import org.zalando.nakadi.repository.zookeeper.ZookeeperSettings; import org.zalando.nakadi.util.UUIDGenerator; +import javax.annotation.Nullable; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Properties; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +import static com.google.common.collect.Lists.newArrayList; +import static java.util.Collections.unmodifiableList; +import static java.util.stream.Collectors.toList; +import static org.zalando.nakadi.domain.CursorError.NULL_OFFSET; +import static org.zalando.nakadi.domain.CursorError.NULL_PARTITION; +import static org.zalando.nakadi.domain.CursorError.PARTITION_NOT_FOUND; +import static org.zalando.nakadi.domain.CursorError.UNAVAILABLE; + public class KafkaTopicRepository implements TopicRepository { private static final Logger LOG = LoggerFactory.getLogger(KafkaTopicRepository.class); diff --git a/src/main/java/org/zalando/nakadi/repository/kafka/NakadiKafkaConsumer.java b/src/main/java/org/zalando/nakadi/repository/kafka/NakadiKafkaConsumer.java index 6c57187d1b..85d6bb05d7 100644 --- a/src/main/java/org/zalando/nakadi/repository/kafka/NakadiKafkaConsumer.java +++ b/src/main/java/org/zalando/nakadi/repository/kafka/NakadiKafkaConsumer.java @@ -1,11 +1,5 @@ package org.zalando.nakadi.repository.kafka; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; import org.apache.kafka.clients.consumer.Consumer; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.consumer.ConsumerRecords; @@ -14,6 +8,13 @@ import org.zalando.nakadi.domain.Timeline; import org.zalando.nakadi.repository.EventConsumer; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + public class NakadiKafkaConsumer implements EventConsumer.LowLevelConsumer { private final Consumer kafkaConsumer; diff --git a/src/main/java/org/zalando/nakadi/repository/kafka/PartitionsCalculator.java b/src/main/java/org/zalando/nakadi/repository/kafka/PartitionsCalculator.java index 46ffb3a4b0..198363b078 100644 --- a/src/main/java/org/zalando/nakadi/repository/kafka/PartitionsCalculator.java +++ b/src/main/java/org/zalando/nakadi/repository/kafka/PartitionsCalculator.java @@ -2,6 +2,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.annotations.VisibleForTesting; +import org.zalando.nakadi.config.NakadiSettings; +import org.zalando.nakadi.domain.EventTypeStatistics; + import java.io.IOException; import java.io.InputStream; import java.util.Arrays; @@ -10,8 +13,6 @@ import java.util.Objects; import java.util.TreeMap; import java.util.stream.Stream; -import org.zalando.nakadi.config.NakadiSettings; -import org.zalando.nakadi.domain.EventTypeStatistics; public class PartitionsCalculator { // Contains mapping from message size (in bytes) to list of throughput of kafka with (index + 1) as partition count. diff --git a/src/main/java/org/zalando/nakadi/service/CursorsService.java b/src/main/java/org/zalando/nakadi/service/CursorsService.java index dcec7ece5f..253e3e940c 100644 --- a/src/main/java/org/zalando/nakadi/service/CursorsService.java +++ b/src/main/java/org/zalando/nakadi/service/CursorsService.java @@ -1,13 +1,6 @@ package org.zalando.nakadi.service; import com.google.common.collect.ImmutableList; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.zalando.nakadi.config.NakadiSettings; @@ -39,6 +32,14 @@ import org.zalando.nakadi.util.TimeLogger; import org.zalando.nakadi.view.SubscriptionCursorWithoutToken; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; +import java.util.stream.Stream; + @Component public class CursorsService { diff --git a/src/main/java/org/zalando/nakadi/service/EventStream.java b/src/main/java/org/zalando/nakadi/service/EventStream.java index 7209c4d86b..624664d1fe 100644 --- a/src/main/java/org/zalando/nakadi/service/EventStream.java +++ b/src/main/java/org/zalando/nakadi/service/EventStream.java @@ -2,23 +2,25 @@ import com.codahale.metrics.Meter; import com.google.common.collect.Lists; +import org.apache.kafka.common.KafkaException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.zalando.nakadi.domain.ConsumedEvent; +import org.zalando.nakadi.domain.NakadiCursor; +import org.zalando.nakadi.repository.EventConsumer; + import java.io.IOException; import java.io.OutputStream; -import static java.lang.System.currentTimeMillis; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Function; -import static java.util.function.Function.identity; import java.util.stream.Collectors; -import org.apache.kafka.common.KafkaException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.zalando.nakadi.domain.ConsumedEvent; -import org.zalando.nakadi.domain.NakadiCursor; -import org.zalando.nakadi.repository.EventConsumer; + +import static java.lang.System.currentTimeMillis; +import static java.util.function.Function.identity; public class EventStream { diff --git a/src/main/java/org/zalando/nakadi/service/EventStreamConfig.java b/src/main/java/org/zalando/nakadi/service/EventStreamConfig.java index 79a0c16ae5..20189b35b4 100644 --- a/src/main/java/org/zalando/nakadi/service/EventStreamConfig.java +++ b/src/main/java/org/zalando/nakadi/service/EventStreamConfig.java @@ -1,11 +1,12 @@ package org.zalando.nakadi.service; -import java.util.List; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.exceptions.UnprocessableEntityException; +import javax.annotation.Nullable; +import javax.annotation.concurrent.Immutable; +import java.util.List; + @Immutable public class EventStreamConfig { diff --git a/src/main/java/org/zalando/nakadi/service/EventStreamFactory.java b/src/main/java/org/zalando/nakadi/service/EventStreamFactory.java index 55a6cd3779..e325198f16 100644 --- a/src/main/java/org/zalando/nakadi/service/EventStreamFactory.java +++ b/src/main/java/org/zalando/nakadi/service/EventStreamFactory.java @@ -1,13 +1,14 @@ package org.zalando.nakadi.service; import com.codahale.metrics.Meter; -import java.io.OutputStream; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.zalando.nakadi.exceptions.InvalidCursorException; import org.zalando.nakadi.exceptions.NakadiException; import org.zalando.nakadi.repository.EventConsumer; +import java.io.OutputStream; + @Component public class EventStreamFactory { diff --git a/src/main/java/org/zalando/nakadi/service/EventTypeChangeListener.java b/src/main/java/org/zalando/nakadi/service/EventTypeChangeListener.java index b229a28ef7..ff43346ac2 100644 --- a/src/main/java/org/zalando/nakadi/service/EventTypeChangeListener.java +++ b/src/main/java/org/zalando/nakadi/service/EventTypeChangeListener.java @@ -1,5 +1,11 @@ package org.zalando.nakadi.service; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.zalando.nakadi.repository.db.EventTypeCache; + import java.io.Closeable; import java.io.IOException; import java.util.Collection; @@ -11,11 +17,6 @@ import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.function.Consumer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.zalando.nakadi.repository.db.EventTypeCache; @Component public class EventTypeChangeListener { diff --git a/src/main/java/org/zalando/nakadi/service/converter/CursorConverterImpl.java b/src/main/java/org/zalando/nakadi/service/converter/CursorConverterImpl.java index 6ad3576fe1..97f62ba4cd 100644 --- a/src/main/java/org/zalando/nakadi/service/converter/CursorConverterImpl.java +++ b/src/main/java/org/zalando/nakadi/service/converter/CursorConverterImpl.java @@ -1,10 +1,6 @@ package org.zalando.nakadi.service.converter; import com.google.common.annotations.VisibleForTesting; -import java.util.EnumMap; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Stream; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.zalando.nakadi.domain.CursorError; @@ -20,6 +16,11 @@ import org.zalando.nakadi.view.SubscriptionCursor; import org.zalando.nakadi.view.SubscriptionCursorWithoutToken; +import java.util.EnumMap; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Stream; + @Service public class CursorConverterImpl implements CursorConverter { diff --git a/src/main/java/org/zalando/nakadi/service/subscription/ExactWeightRebalancer.java b/src/main/java/org/zalando/nakadi/service/subscription/ExactWeightRebalancer.java index f0836a4304..0227a83b73 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/ExactWeightRebalancer.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/ExactWeightRebalancer.java @@ -2,6 +2,7 @@ import org.zalando.nakadi.service.subscription.model.Partition; import org.zalando.nakadi.service.subscription.model.Session; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; diff --git a/src/main/java/org/zalando/nakadi/service/subscription/StreamingContext.java b/src/main/java/org/zalando/nakadi/service/subscription/StreamingContext.java index dd600118af..69472d60dc 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/StreamingContext.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/StreamingContext.java @@ -3,14 +3,6 @@ import com.codahale.metrics.MetricRegistry; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Preconditions; -import java.io.Closeable; -import java.io.IOException; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.BiFunction; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.zalando.nakadi.domain.Subscription; @@ -32,6 +24,15 @@ import org.zalando.nakadi.service.subscription.zk.ZkSubscriptionClient; import org.zalando.nakadi.service.timeline.TimelineService; +import java.io.Closeable; +import java.io.IOException; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.BiFunction; + public class StreamingContext implements SubscriptionStreamer { public static final State DEAD_STATE = new DummyState(); diff --git a/src/main/java/org/zalando/nakadi/service/subscription/SubscriptionStreamerFactory.java b/src/main/java/org/zalando/nakadi/service/subscription/SubscriptionStreamerFactory.java index 4f6d80c0a3..4e0b40ca72 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/SubscriptionStreamerFactory.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/SubscriptionStreamerFactory.java @@ -2,9 +2,6 @@ import com.codahale.metrics.MetricRegistry; import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.atomic.AtomicBoolean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; @@ -24,6 +21,10 @@ import org.zalando.nakadi.service.subscription.zk.SubscriptionClientFactory; import org.zalando.nakadi.service.timeline.TimelineService; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.atomic.AtomicBoolean; + @Service public class SubscriptionStreamerFactory { @Value("${nakadi.kafka.poll.timeoutMs}") diff --git a/src/main/java/org/zalando/nakadi/service/subscription/SubscriptionValidationService.java b/src/main/java/org/zalando/nakadi/service/subscription/SubscriptionValidationService.java index 922ea52a88..dbd2420615 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/SubscriptionValidationService.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/SubscriptionValidationService.java @@ -1,11 +1,5 @@ package org.zalando.nakadi.service.subscription; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.function.Function; -import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -29,6 +23,13 @@ import org.zalando.nakadi.service.timeline.TimelineService; import org.zalando.nakadi.view.SubscriptionCursorWithoutToken; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.function.Function; +import java.util.stream.Collectors; + @Service public class SubscriptionValidationService { diff --git a/src/main/java/org/zalando/nakadi/service/subscription/model/Partition.java b/src/main/java/org/zalando/nakadi/service/subscription/model/Partition.java index c753d2e963..40312befba 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/model/Partition.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/model/Partition.java @@ -2,10 +2,11 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Collection; -import javax.annotation.Nullable; import org.zalando.nakadi.domain.EventTypePartition; +import javax.annotation.Nullable; +import java.util.Collection; + public class Partition { public enum State { UNASSIGNED("unassigned"), diff --git a/src/main/java/org/zalando/nakadi/service/subscription/state/CleanupState.java b/src/main/java/org/zalando/nakadi/service/subscription/state/CleanupState.java index 1271a48a52..1bc2b25d73 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/state/CleanupState.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/state/CleanupState.java @@ -1,8 +1,9 @@ package org.zalando.nakadi.service.subscription.state; -import javax.annotation.Nullable; import org.zalando.nakadi.service.subscription.StreamingContext; +import javax.annotation.Nullable; + public class CleanupState extends State { private final Exception exception; diff --git a/src/main/java/org/zalando/nakadi/service/subscription/state/ClosingState.java b/src/main/java/org/zalando/nakadi/service/subscription/state/ClosingState.java index d3f7aa04f8..cb2193c7c3 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/state/ClosingState.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/state/ClosingState.java @@ -1,5 +1,12 @@ package org.zalando.nakadi.service.subscription.state; +import org.zalando.nakadi.domain.EventTypePartition; +import org.zalando.nakadi.domain.NakadiCursor; +import org.zalando.nakadi.exceptions.NakadiRuntimeException; +import org.zalando.nakadi.exceptions.runtime.MyNakadiRuntimeException1; +import org.zalando.nakadi.service.subscription.model.Partition; +import org.zalando.nakadi.service.subscription.zk.ZKSubscription; + import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -10,12 +17,6 @@ import java.util.function.LongSupplier; import java.util.function.Supplier; import java.util.stream.Stream; -import org.zalando.nakadi.domain.EventTypePartition; -import org.zalando.nakadi.domain.NakadiCursor; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; -import org.zalando.nakadi.exceptions.runtime.MyNakadiRuntimeException1; -import org.zalando.nakadi.service.subscription.model.Partition; -import org.zalando.nakadi.service.subscription.zk.ZKSubscription; class ClosingState extends State { private final Supplier> uncommittedOffsetsSupplier; diff --git a/src/main/java/org/zalando/nakadi/service/subscription/state/PartitionData.java b/src/main/java/org/zalando/nakadi/service/subscription/state/PartitionData.java index fd699ce5cb..0b4aa05054 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/state/PartitionData.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/state/PartitionData.java @@ -1,18 +1,19 @@ package org.zalando.nakadi.service.subscription.state; import com.google.common.annotations.VisibleForTesting; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.zalando.nakadi.domain.ConsumedEvent; +import org.zalando.nakadi.domain.NakadiCursor; +import org.zalando.nakadi.service.subscription.zk.ZKSubscription; + +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.NavigableSet; import java.util.Set; import java.util.TreeSet; -import javax.annotation.Nullable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.zalando.nakadi.domain.ConsumedEvent; -import org.zalando.nakadi.domain.NakadiCursor; -import org.zalando.nakadi.service.subscription.zk.ZKSubscription; class PartitionData { private final ZKSubscription subscription; diff --git a/src/main/java/org/zalando/nakadi/service/subscription/state/StartingState.java b/src/main/java/org/zalando/nakadi/service/subscription/state/StartingState.java index daf30c243e..6b6cfb0a70 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/state/StartingState.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/state/StartingState.java @@ -1,12 +1,5 @@ package org.zalando.nakadi.service.subscription.state; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.EnumMap; -import java.util.List; -import java.util.Map; -import javax.ws.rs.core.Response; import org.zalando.nakadi.domain.Subscription; import org.zalando.nakadi.domain.SubscriptionBase; import org.zalando.nakadi.domain.Timeline; @@ -20,6 +13,14 @@ import org.zalando.nakadi.service.timeline.TimelineService; import org.zalando.nakadi.view.SubscriptionCursorWithoutToken; +import javax.ws.rs.core.Response; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.EnumMap; +import java.util.List; +import java.util.Map; + public class StartingState extends State { @Override public void onEnter() { diff --git a/src/main/java/org/zalando/nakadi/service/subscription/state/State.java b/src/main/java/org/zalando/nakadi/service/subscription/state/State.java index ec31a1f1dc..417dc29c80 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/state/State.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/state/State.java @@ -1,6 +1,5 @@ package org.zalando.nakadi.service.subscription.state; -import java.util.concurrent.TimeUnit; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.zalando.nakadi.service.subscription.StreamParameters; @@ -8,6 +7,8 @@ import org.zalando.nakadi.service.subscription.SubscriptionOutput; import org.zalando.nakadi.service.subscription.zk.ZkSubscriptionClient; +import java.util.concurrent.TimeUnit; + public abstract class State { private StreamingContext context; private Logger log; diff --git a/src/main/java/org/zalando/nakadi/service/subscription/zk/AbstractZkSubscriptionClient.java b/src/main/java/org/zalando/nakadi/service/subscription/zk/AbstractZkSubscriptionClient.java index d2396b49c5..47e31ecaf0 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/zk/AbstractZkSubscriptionClient.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/zk/AbstractZkSubscriptionClient.java @@ -1,20 +1,7 @@ package org.zalando.nakadi.service.subscription.zk; import com.google.common.base.Charsets; -import static com.google.common.base.Charsets.UTF_8; import com.google.common.collect.Lists; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.stream.Collectors; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.recipes.cache.NodeCache; import org.apache.curator.framework.recipes.locks.InterProcessSemaphoreMutex; @@ -22,7 +9,6 @@ import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.data.Stat; import org.echocat.jomon.runtime.concurrent.RetryForSpecifiedCountStrategy; -import static org.echocat.jomon.runtime.concurrent.Retryer.executeWithRetry; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.zalando.nakadi.domain.EventTypePartition; @@ -37,6 +23,22 @@ import org.zalando.nakadi.service.subscription.model.Session; import org.zalando.nakadi.view.SubscriptionCursorWithoutToken; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Collectors; + +import static com.google.common.base.Charsets.UTF_8; +import static org.echocat.jomon.runtime.concurrent.Retryer.executeWithRetry; + public abstract class AbstractZkSubscriptionClient implements ZkSubscriptionClient { private static final String STATE_INITIALIZED = "INITIALIZED"; private static final int COMMIT_CONFLICT_RETRY_TIMES = 5; diff --git a/src/main/java/org/zalando/nakadi/service/subscription/zk/ChangeListener.java b/src/main/java/org/zalando/nakadi/service/subscription/zk/ChangeListener.java index 0ceed66f33..717c13e4ce 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/zk/ChangeListener.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/zk/ChangeListener.java @@ -1,10 +1,11 @@ package org.zalando.nakadi.service.subscription.zk; -import org.zalando.nakadi.exceptions.NakadiRuntimeException; -import java.util.concurrent.atomic.AtomicBoolean; import org.apache.curator.framework.CuratorFramework; import org.apache.zookeeper.WatchedEvent; import org.apache.zookeeper.Watcher; +import org.zalando.nakadi.exceptions.NakadiRuntimeException; + +import java.util.concurrent.atomic.AtomicBoolean; public abstract class ChangeListener implements ZKSubscription, Watcher { protected final CuratorFramework curatorFramework; diff --git a/src/main/java/org/zalando/nakadi/service/subscription/zk/NewZkSubscriptionClient.java b/src/main/java/org/zalando/nakadi/service/subscription/zk/NewZkSubscriptionClient.java index 49f2e12f33..40ce13e47e 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/zk/NewZkSubscriptionClient.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/zk/NewZkSubscriptionClient.java @@ -2,12 +2,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.ObjectMapper; -import static com.google.common.base.Charsets.UTF_8; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.stream.Stream; import org.apache.curator.framework.CuratorFramework; import org.apache.zookeeper.KeeperException; import org.zalando.nakadi.domain.EventTypePartition; @@ -16,6 +10,14 @@ import org.zalando.nakadi.service.subscription.model.Partition; import org.zalando.nakadi.view.SubscriptionCursorWithoutToken; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.stream.Stream; + +import static com.google.common.base.Charsets.UTF_8; + /** * Subscription client that uses topology as an object node and separates changeable data to a separate zk node. * The structure of zk data is like this: diff --git a/src/main/java/org/zalando/nakadi/service/subscription/zk/ZkSubscriptionClient.java b/src/main/java/org/zalando/nakadi/service/subscription/zk/ZkSubscriptionClient.java index b94446316d..b8a4b75329 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/zk/ZkSubscriptionClient.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/zk/ZkSubscriptionClient.java @@ -1,8 +1,5 @@ package org.zalando.nakadi.service.subscription.zk; -import java.util.Collection; -import java.util.Comparator; -import java.util.List; import org.zalando.nakadi.domain.EventTypePartition; import org.zalando.nakadi.exceptions.NakadiRuntimeException; import org.zalando.nakadi.exceptions.ServiceUnavailableException; @@ -12,6 +9,10 @@ import org.zalando.nakadi.service.subscription.model.Session; import org.zalando.nakadi.view.SubscriptionCursorWithoutToken; +import java.util.Collection; +import java.util.Comparator; +import java.util.List; + public interface ZkSubscriptionClient { /** diff --git a/src/main/java/org/zalando/nakadi/service/subscription/zk/ZkSubscriptionNode.java b/src/main/java/org/zalando/nakadi/service/subscription/zk/ZkSubscriptionNode.java index 98c37e5749..327f04d16b 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/zk/ZkSubscriptionNode.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/zk/ZkSubscriptionNode.java @@ -1,12 +1,13 @@ package org.zalando.nakadi.service.subscription.zk; -import java.util.Optional; -import java.util.stream.Stream; -import javax.annotation.Nullable; import org.zalando.nakadi.domain.EventTypePartition; import org.zalando.nakadi.service.subscription.model.Partition; import org.zalando.nakadi.service.subscription.model.Session; +import javax.annotation.Nullable; +import java.util.Optional; +import java.util.stream.Stream; + public final class ZkSubscriptionNode { private Partition[] partitions; diff --git a/src/main/java/org/zalando/nakadi/service/timeline/LocalLocking.java b/src/main/java/org/zalando/nakadi/service/timeline/LocalLocking.java index a6dc6129a4..7fc3a91e5b 100644 --- a/src/main/java/org/zalando/nakadi/service/timeline/LocalLocking.java +++ b/src/main/java/org/zalando/nakadi/service/timeline/LocalLocking.java @@ -1,5 +1,8 @@ package org.zalando.nakadi.service.timeline; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.Closeable; import java.util.HashMap; import java.util.HashSet; @@ -8,8 +11,6 @@ import java.util.Set; import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class LocalLocking { private static final Logger LOG = LoggerFactory.getLogger(LocalLocking.class); diff --git a/src/main/java/org/zalando/nakadi/service/timeline/TimelineSyncImpl.java b/src/main/java/org/zalando/nakadi/service/timeline/TimelineSyncImpl.java index 8f4a974ae0..28191eee9e 100644 --- a/src/main/java/org/zalando/nakadi/service/timeline/TimelineSyncImpl.java +++ b/src/main/java/org/zalando/nakadi/service/timeline/TimelineSyncImpl.java @@ -2,6 +2,22 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Charsets; +import org.apache.curator.framework.recipes.locks.InterProcessLock; +import org.apache.curator.framework.recipes.locks.InterProcessSemaphoreMutex; +import org.apache.zookeeper.CreateMode; +import org.apache.zookeeper.KeeperException; +import org.apache.zookeeper.WatchedEvent; +import org.apache.zookeeper.Watcher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Profile; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; +import org.zalando.nakadi.repository.zookeeper.ZooKeeperHolder; +import org.zalando.nakadi.util.UUIDGenerator; + +import javax.annotation.Nullable; import java.io.Closeable; import java.util.ArrayList; import java.util.Collection; @@ -19,21 +35,6 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; import java.util.function.Function; -import javax.annotation.Nullable; -import org.apache.curator.framework.recipes.locks.InterProcessLock; -import org.apache.curator.framework.recipes.locks.InterProcessSemaphoreMutex; -import org.apache.zookeeper.CreateMode; -import org.apache.zookeeper.KeeperException; -import org.apache.zookeeper.WatchedEvent; -import org.apache.zookeeper.Watcher; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Profile; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Service; -import org.zalando.nakadi.repository.zookeeper.ZooKeeperHolder; -import org.zalando.nakadi.util.UUIDGenerator; @Service @Profile("!test") diff --git a/src/main/java/org/zalando/nakadi/util/FeatureToggleService.java b/src/main/java/org/zalando/nakadi/util/FeatureToggleService.java index 6c6f2ffe2a..f91630ef40 100644 --- a/src/main/java/org/zalando/nakadi/util/FeatureToggleService.java +++ b/src/main/java/org/zalando/nakadi/util/FeatureToggleService.java @@ -1,10 +1,11 @@ package org.zalando.nakadi.util; +import org.springframework.stereotype.Service; +import org.zalando.nakadi.exceptions.runtime.FeatureNotAvailableException; + import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; -import org.springframework.stereotype.Service; -import org.zalando.nakadi.exceptions.runtime.FeatureNotAvailableException; @Service public interface FeatureToggleService { diff --git a/src/main/java/org/zalando/nakadi/util/JsonPathAccess.java b/src/main/java/org/zalando/nakadi/util/JsonPathAccess.java index 20d7f3914d..fed583415c 100644 --- a/src/main/java/org/zalando/nakadi/util/JsonPathAccess.java +++ b/src/main/java/org/zalando/nakadi/util/JsonPathAccess.java @@ -1,8 +1,8 @@ package org.zalando.nakadi.util; -import org.zalando.nakadi.exceptions.InvalidPartitionKeyFieldsException; import org.json.JSONException; import org.json.JSONObject; +import org.zalando.nakadi.exceptions.InvalidPartitionKeyFieldsException; /* One could use JsonPath Lib instead: https://github.com/jayway/JsonPath diff --git a/src/main/java/org/zalando/nakadi/util/NakadiCollectionUtils.java b/src/main/java/org/zalando/nakadi/util/NakadiCollectionUtils.java index f7a6641788..30a6e76616 100644 --- a/src/main/java/org/zalando/nakadi/util/NakadiCollectionUtils.java +++ b/src/main/java/org/zalando/nakadi/util/NakadiCollectionUtils.java @@ -1,6 +1,7 @@ package org.zalando.nakadi.util; import com.google.common.collect.ImmutableSet; + import java.util.Set; public class NakadiCollectionUtils { diff --git a/src/main/java/org/zalando/nakadi/util/TimeLogger.java b/src/main/java/org/zalando/nakadi/util/TimeLogger.java index 84b53759d9..b3b9d1a029 100644 --- a/src/main/java/org/zalando/nakadi/util/TimeLogger.java +++ b/src/main/java/org/zalando/nakadi/util/TimeLogger.java @@ -1,8 +1,8 @@ package org.zalando.nakadi.util; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; -import javax.annotation.Nullable; public class TimeLogger { diff --git a/src/main/java/org/zalando/nakadi/validation/EventTypeValidator.java b/src/main/java/org/zalando/nakadi/validation/EventTypeValidator.java index 1e2a248e3e..2997648f4d 100644 --- a/src/main/java/org/zalando/nakadi/validation/EventTypeValidator.java +++ b/src/main/java/org/zalando/nakadi/validation/EventTypeValidator.java @@ -1,9 +1,9 @@ package org.zalando.nakadi.validation; import com.google.common.collect.Lists; +import org.json.JSONObject; import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.domain.ValidationStrategyConfiguration; -import org.json.JSONObject; import java.util.List; import java.util.Optional; diff --git a/src/main/java/org/zalando/nakadi/validation/EventValidator.java b/src/main/java/org/zalando/nakadi/validation/EventValidator.java index 6e0d483b7b..54dd8de189 100644 --- a/src/main/java/org/zalando/nakadi/validation/EventValidator.java +++ b/src/main/java/org/zalando/nakadi/validation/EventValidator.java @@ -1,8 +1,9 @@ package org.zalando.nakadi.validation; -import java.util.Optional; import org.json.JSONObject; +import java.util.Optional; + interface EventValidator { Optional accepts(JSONObject event); } diff --git a/src/main/java/org/zalando/nakadi/validation/FieldNameMustBeSet.java b/src/main/java/org/zalando/nakadi/validation/FieldNameMustBeSet.java index f9abdccd35..c2cec47229 100644 --- a/src/main/java/org/zalando/nakadi/validation/FieldNameMustBeSet.java +++ b/src/main/java/org/zalando/nakadi/validation/FieldNameMustBeSet.java @@ -1,7 +1,6 @@ package org.zalando.nakadi.validation; import org.json.JSONObject; - import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.domain.ValidationStrategyConfiguration; diff --git a/src/main/java/org/zalando/nakadi/validation/RFC3339DateTimeValidator.java b/src/main/java/org/zalando/nakadi/validation/RFC3339DateTimeValidator.java index 1a2677b0ab..d7fb692d35 100644 --- a/src/main/java/org/zalando/nakadi/validation/RFC3339DateTimeValidator.java +++ b/src/main/java/org/zalando/nakadi/validation/RFC3339DateTimeValidator.java @@ -1,12 +1,14 @@ package org.zalando.nakadi.validation; +import org.everit.json.schema.FormatValidator; + import java.time.OffsetDateTime; -import static java.time.format.DateTimeFormatter.ISO_OFFSET_DATE_TIME; import java.time.format.DateTimeParseException; import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.everit.json.schema.FormatValidator; + +import static java.time.format.DateTimeFormatter.ISO_OFFSET_DATE_TIME; public class RFC3339DateTimeValidator implements FormatValidator { diff --git a/src/main/java/org/zalando/nakadi/validation/SchemaEvolutionService.java b/src/main/java/org/zalando/nakadi/validation/SchemaEvolutionService.java index 9e2f796bb1..c66fe124b5 100644 --- a/src/main/java/org/zalando/nakadi/validation/SchemaEvolutionService.java +++ b/src/main/java/org/zalando/nakadi/validation/SchemaEvolutionService.java @@ -15,9 +15,9 @@ import org.zalando.nakadi.domain.Version; import org.zalando.nakadi.exceptions.InvalidEventTypeException; import org.zalando.nakadi.validation.schema.ForbiddenAttributeIncompatibility; -import org.zalando.nakadi.validation.schema.diff.SchemaDiff; import org.zalando.nakadi.validation.schema.SchemaEvolutionConstraint; import org.zalando.nakadi.validation.schema.SchemaEvolutionIncompatibility; +import org.zalando.nakadi.validation.schema.diff.SchemaDiff; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/org/zalando/nakadi/validation/schema/SchemaConstraint.java b/src/main/java/org/zalando/nakadi/validation/schema/SchemaConstraint.java index 9f679357f2..e3624945f7 100644 --- a/src/main/java/org/zalando/nakadi/validation/schema/SchemaConstraint.java +++ b/src/main/java/org/zalando/nakadi/validation/schema/SchemaConstraint.java @@ -1,10 +1,11 @@ package org.zalando.nakadi.validation.schema; -import java.util.List; -import java.util.Optional; import org.everit.json.schema.Schema; import org.zalando.nakadi.validation.SchemaIncompatibility; +import java.util.List; +import java.util.Optional; + public abstract class SchemaConstraint { public abstract Optional validate(List jsonPath, Schema schema); diff --git a/src/main/java/org/zalando/nakadi/view/Cursor.java b/src/main/java/org/zalando/nakadi/view/Cursor.java index 64ea3f5517..e268eaf1e5 100644 --- a/src/main/java/org/zalando/nakadi/view/Cursor.java +++ b/src/main/java/org/zalando/nakadi/view/Cursor.java @@ -1,6 +1,7 @@ package org.zalando.nakadi.view; import com.fasterxml.jackson.annotation.JsonProperty; + import javax.annotation.concurrent.Immutable; import javax.validation.constraints.NotNull; diff --git a/src/main/java/org/zalando/nakadi/view/SubscriptionCursor.java b/src/main/java/org/zalando/nakadi/view/SubscriptionCursor.java index a5ce34ba6f..8dcca3eee3 100644 --- a/src/main/java/org/zalando/nakadi/view/SubscriptionCursor.java +++ b/src/main/java/org/zalando/nakadi/view/SubscriptionCursor.java @@ -1,6 +1,7 @@ package org.zalando.nakadi.view; import com.fasterxml.jackson.annotation.JsonProperty; + import javax.annotation.concurrent.Immutable; import javax.validation.constraints.NotNull; diff --git a/src/main/java/org/zalando/nakadi/view/SubscriptionCursorWithoutToken.java b/src/main/java/org/zalando/nakadi/view/SubscriptionCursorWithoutToken.java index e9d2626edf..ae3f8609c5 100644 --- a/src/main/java/org/zalando/nakadi/view/SubscriptionCursorWithoutToken.java +++ b/src/main/java/org/zalando/nakadi/view/SubscriptionCursorWithoutToken.java @@ -2,9 +2,10 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import org.zalando.nakadi.domain.EventTypePartition; + import javax.annotation.concurrent.Immutable; import javax.validation.constraints.NotNull; -import org.zalando.nakadi.domain.EventTypePartition; @Immutable public class SubscriptionCursorWithoutToken extends Cursor { diff --git a/src/main/java/org/zalando/nakadi/view/TimelineView.java b/src/main/java/org/zalando/nakadi/view/TimelineView.java index a989fa7a15..50aac9151c 100644 --- a/src/main/java/org/zalando/nakadi/view/TimelineView.java +++ b/src/main/java/org/zalando/nakadi/view/TimelineView.java @@ -1,8 +1,9 @@ package org.zalando.nakadi.view; +import org.zalando.nakadi.domain.Timeline; + import java.util.Date; import java.util.UUID; -import org.zalando.nakadi.domain.Timeline; public class TimelineView { diff --git a/src/test/java/org/zalando/nakadi/controller/PostSubscriptionControllerTest.java b/src/test/java/org/zalando/nakadi/controller/PostSubscriptionControllerTest.java index e3041647ea..683aeb2d10 100644 --- a/src/test/java/org/zalando/nakadi/controller/PostSubscriptionControllerTest.java +++ b/src/test/java/org/zalando/nakadi/controller/PostSubscriptionControllerTest.java @@ -3,29 +3,16 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; -import static javax.ws.rs.core.Response.Status.FORBIDDEN; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.junit.Test; -import static org.mockito.Matchers.any; import org.mockito.Mockito; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import org.springframework.core.MethodParameter; import org.springframework.http.HttpStatus; -import static org.springframework.http.MediaType.APPLICATION_JSON; import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.test.web.servlet.ResultActions; import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup; import org.springframework.test.web.servlet.setup.StandaloneMockMvcBuilder; import org.springframework.web.bind.support.WebDataBinderFactory; import org.springframework.web.context.request.NativeWebRequest; @@ -45,13 +32,28 @@ import org.zalando.nakadi.service.AuthorizationValidator; import org.zalando.nakadi.service.subscription.SubscriptionService; import org.zalando.nakadi.util.FeatureToggleService; -import static org.zalando.nakadi.util.FeatureToggleService.Feature.DISABLE_SUBSCRIPTION_CREATION; import org.zalando.nakadi.utils.JsonTestHelper; +import org.zalando.problem.Problem; + +import java.util.HashSet; +import java.util.Optional; +import java.util.Set; + +import static javax.ws.rs.core.Response.Status.FORBIDDEN; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.springframework.http.MediaType.APPLICATION_JSON; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup; +import static org.zalando.nakadi.util.FeatureToggleService.Feature.DISABLE_SUBSCRIPTION_CREATION; import static org.zalando.nakadi.utils.RandomSubscriptionBuilder.builder; import static org.zalando.nakadi.utils.TestUtils.invalidProblem; import static org.zalando.nakadi.utils.TestUtils.mockAccessDeniedException; import static org.zalando.problem.MoreStatus.UNPROCESSABLE_ENTITY; -import org.zalando.problem.Problem; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; public class PostSubscriptionControllerTest { diff --git a/src/test/java/org/zalando/nakadi/controller/SubscriptionStreamControllerTest.java b/src/test/java/org/zalando/nakadi/controller/SubscriptionStreamControllerTest.java index ddb5466a58..2434dea0fe 100644 --- a/src/test/java/org/zalando/nakadi/controller/SubscriptionStreamControllerTest.java +++ b/src/test/java/org/zalando/nakadi/controller/SubscriptionStreamControllerTest.java @@ -3,19 +3,9 @@ import com.codahale.metrics.Counter; import com.codahale.metrics.MetricRegistry; import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.net.UnknownHostException; -import java.util.concurrent.atomic.AtomicBoolean; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import static org.hamcrest.MatcherAssert.assertThat; import org.junit.Before; import org.junit.Test; -import static org.mockito.Matchers.any; import org.mockito.Mockito; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; import org.zalando.nakadi.config.JsonConfig; import org.zalando.nakadi.config.NakadiSettings; @@ -31,11 +21,23 @@ import org.zalando.nakadi.service.EventTypeChangeListener; import org.zalando.nakadi.service.subscription.SubscriptionStreamerFactory; import org.zalando.nakadi.util.FeatureToggleService; -import static org.zalando.nakadi.util.FeatureToggleService.Feature.HIGH_LEVEL_API; import org.zalando.nakadi.utils.JsonTestHelper; -import static org.zalando.problem.MoreStatus.UNPROCESSABLE_ENTITY; import org.zalando.problem.Problem; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.net.UnknownHostException; +import java.util.concurrent.atomic.AtomicBoolean; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.zalando.nakadi.util.FeatureToggleService.Feature.HIGH_LEVEL_API; +import static org.zalando.problem.MoreStatus.UNPROCESSABLE_ENTITY; + public class SubscriptionStreamControllerTest { private static final Client FULL_ACCESS_CLIENT = new FullAccessClient("clientId"); diff --git a/src/test/java/org/zalando/nakadi/domain/BatchItemResponseTest.java b/src/test/java/org/zalando/nakadi/domain/BatchItemResponseTest.java index feed06a47f..d211d8b874 100644 --- a/src/test/java/org/zalando/nakadi/domain/BatchItemResponseTest.java +++ b/src/test/java/org/zalando/nakadi/domain/BatchItemResponseTest.java @@ -2,9 +2,9 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.zalando.nakadi.config.JsonConfig; import org.junit.Before; import org.junit.Test; +import org.zalando.nakadi.config.JsonConfig; import java.util.Map; import java.util.UUID; diff --git a/src/test/java/org/zalando/nakadi/domain/EventTypeTest.java b/src/test/java/org/zalando/nakadi/domain/EventTypeTest.java index 98987cdda2..b2dee69394 100644 --- a/src/test/java/org/zalando/nakadi/domain/EventTypeTest.java +++ b/src/test/java/org/zalando/nakadi/domain/EventTypeTest.java @@ -1,12 +1,12 @@ package org.zalando.nakadi.domain; import com.fasterxml.jackson.databind.ObjectMapper; -import org.zalando.nakadi.config.JsonConfig; import org.junit.Test; +import org.zalando.nakadi.config.JsonConfig; -import static org.zalando.nakadi.utils.TestUtils.resourceAsString; import static org.hamcrest.Matchers.notNullValue; import static org.junit.Assert.assertThat; +import static org.zalando.nakadi.utils.TestUtils.resourceAsString; public class EventTypeTest { diff --git a/src/test/java/org/zalando/nakadi/enrichment/EnrichmentTest.java b/src/test/java/org/zalando/nakadi/enrichment/EnrichmentTest.java index d03d687a2a..3828f5324d 100644 --- a/src/test/java/org/zalando/nakadi/enrichment/EnrichmentTest.java +++ b/src/test/java/org/zalando/nakadi/enrichment/EnrichmentTest.java @@ -1,20 +1,20 @@ package org.zalando.nakadi.enrichment; +import org.json.JSONObject; +import org.junit.Test; +import org.mockito.Mockito; import org.zalando.nakadi.domain.BatchItem; import org.zalando.nakadi.domain.EnrichmentStrategyDescriptor; import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.exceptions.InvalidEventTypeException; -import org.json.JSONObject; -import org.junit.Test; -import org.mockito.Mockito; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import static org.zalando.nakadi.domain.EventCategory.BUSINESS; import static org.zalando.nakadi.domain.EventCategory.DATA; import static org.zalando.nakadi.utils.TestUtils.buildDefaultEventType; import static org.zalando.nakadi.utils.TestUtils.createBatchItem; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; public class EnrichmentTest { private final EnrichmentsRegistry registry = mock(EnrichmentsRegistry.class); diff --git a/src/test/java/org/zalando/nakadi/enrichment/MetadataEnrichmentStrategyTest.java b/src/test/java/org/zalando/nakadi/enrichment/MetadataEnrichmentStrategyTest.java index 642ec2568a..add6dadf41 100644 --- a/src/test/java/org/zalando/nakadi/enrichment/MetadataEnrichmentStrategyTest.java +++ b/src/test/java/org/zalando/nakadi/enrichment/MetadataEnrichmentStrategyTest.java @@ -1,21 +1,21 @@ package org.zalando.nakadi.enrichment; +import org.joda.time.DateTimeUtils; +import org.json.JSONObject; +import org.junit.Test; import org.zalando.nakadi.domain.BatchItem; import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.exceptions.EnrichmentException; import org.zalando.nakadi.util.FlowIdUtils; -import org.joda.time.DateTimeUtils; -import org.json.JSONObject; -import org.junit.Test; import org.zalando.nakadi.utils.TestUtils; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.Matchers.isEmptyString; +import static org.junit.Assert.assertThat; import static org.zalando.nakadi.utils.TestUtils.buildBusinessEvent; import static org.zalando.nakadi.utils.TestUtils.buildDefaultEventType; import static org.zalando.nakadi.utils.TestUtils.createBatchItem; import static org.zalando.nakadi.utils.TestUtils.randomString; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.Matchers.isEmptyString; -import static org.junit.Assert.assertThat; public class MetadataEnrichmentStrategyTest { private final MetadataEnrichmentStrategy strategy = new MetadataEnrichmentStrategy(); diff --git a/src/test/java/org/zalando/nakadi/partitioning/UserDefinedPartitionStrategyTest.java b/src/test/java/org/zalando/nakadi/partitioning/UserDefinedPartitionStrategyTest.java index 2a390a6658..43e917fb89 100644 --- a/src/test/java/org/zalando/nakadi/partitioning/UserDefinedPartitionStrategyTest.java +++ b/src/test/java/org/zalando/nakadi/partitioning/UserDefinedPartitionStrategyTest.java @@ -1,9 +1,9 @@ package org.zalando.nakadi.partitioning; import com.google.common.collect.ImmutableList; -import org.zalando.nakadi.exceptions.PartitioningException; import org.json.JSONObject; import org.junit.Test; +import org.zalando.nakadi.exceptions.PartitioningException; import java.util.List; diff --git a/src/test/java/org/zalando/nakadi/repository/db/CachingEventTypeRepositoryTest.java b/src/test/java/org/zalando/nakadi/repository/db/CachingEventTypeRepositoryTest.java index 80d2019ccd..e933a6f510 100644 --- a/src/test/java/org/zalando/nakadi/repository/db/CachingEventTypeRepositoryTest.java +++ b/src/test/java/org/zalando/nakadi/repository/db/CachingEventTypeRepositoryTest.java @@ -1,10 +1,10 @@ package org.zalando.nakadi.repository.db; +import org.junit.Test; +import org.mockito.Mockito; import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.exceptions.InternalNakadiException; import org.zalando.nakadi.repository.EventTypeRepository; -import org.junit.Test; -import org.mockito.Mockito; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; diff --git a/src/test/java/org/zalando/nakadi/repository/db/EventTypeCacheTest.java b/src/test/java/org/zalando/nakadi/repository/db/EventTypeCacheTest.java index 8d0a523de0..7d7358deba 100644 --- a/src/test/java/org/zalando/nakadi/repository/db/EventTypeCacheTest.java +++ b/src/test/java/org/zalando/nakadi/repository/db/EventTypeCacheTest.java @@ -1,7 +1,5 @@ package org.zalando.nakadi.repository.db; -import java.util.Collections; -import java.util.List; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -18,6 +16,9 @@ import org.zalando.nakadi.validation.JsonSchemaEnrichment; import org.zalando.nakadi.validation.ValidationStrategy; +import java.util.Collections; +import java.util.List; + public class EventTypeCacheTest { @BeforeClass public static void initValidation() { diff --git a/src/test/java/org/zalando/nakadi/repository/kafka/KafkaFactoryTest.java b/src/test/java/org/zalando/nakadi/repository/kafka/KafkaFactoryTest.java index a4d01c669d..ca3f532e9a 100644 --- a/src/test/java/org/zalando/nakadi/repository/kafka/KafkaFactoryTest.java +++ b/src/test/java/org/zalando/nakadi/repository/kafka/KafkaFactoryTest.java @@ -2,14 +2,15 @@ import com.codahale.metrics.Counter; import com.codahale.metrics.MetricRegistry; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; import org.apache.kafka.clients.producer.Producer; import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + public class KafkaFactoryTest { private static class FakeKafkaFactory extends KafkaFactory { diff --git a/src/test/java/org/zalando/nakadi/repository/kafka/KafkaTopicRepositoryTest.java b/src/test/java/org/zalando/nakadi/repository/kafka/KafkaTopicRepositoryTest.java index 2f45065a42..f5d92a8b5b 100644 --- a/src/test/java/org/zalando/nakadi/repository/kafka/KafkaTopicRepositoryTest.java +++ b/src/test/java/org/zalando/nakadi/repository/kafka/KafkaTopicRepositoryTest.java @@ -2,14 +2,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.concurrent.Future; -import java.util.stream.Collectors; - import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.api.GetChildrenBuilder; import org.apache.kafka.clients.consumer.Consumer; @@ -40,6 +32,14 @@ import org.zalando.nakadi.util.UUIDGenerator; import org.zalando.nakadi.view.Cursor; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import java.util.concurrent.Future; +import java.util.stream.Collectors; + import static com.google.common.collect.Sets.newHashSet; import static java.util.Arrays.asList; import static java.util.stream.Collectors.toList; diff --git a/src/test/java/org/zalando/nakadi/repository/kafka/NakadiKafkaConsumerTest.java b/src/test/java/org/zalando/nakadi/repository/kafka/NakadiKafkaConsumerTest.java index 2d076ab5de..0f08a5b08e 100644 --- a/src/test/java/org/zalando/nakadi/repository/kafka/NakadiKafkaConsumerTest.java +++ b/src/test/java/org/zalando/nakadi/repository/kafka/NakadiKafkaConsumerTest.java @@ -2,9 +2,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.consumer.ConsumerRecords; import org.apache.kafka.clients.consumer.KafkaConsumer; @@ -17,6 +14,11 @@ import org.zalando.nakadi.domain.ConsumedEvent; import org.zalando.nakadi.domain.Timeline; import org.zalando.nakadi.utils.TestUtils; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import static junit.framework.TestCase.fail; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/org/zalando/nakadi/repository/kafka/PartitionsCalculatorTest.java b/src/test/java/org/zalando/nakadi/repository/kafka/PartitionsCalculatorTest.java index cce3a91158..12afadb5a3 100644 --- a/src/test/java/org/zalando/nakadi/repository/kafka/PartitionsCalculatorTest.java +++ b/src/test/java/org/zalando/nakadi/repository/kafka/PartitionsCalculatorTest.java @@ -1,12 +1,14 @@ package org.zalando.nakadi.repository.kafka; import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.io.InputStream; import org.junit.Assert; import org.junit.Test; import org.zalando.nakadi.config.JsonConfig; import org.zalando.nakadi.domain.EventTypeStatistics; + +import java.io.IOException; +import java.io.InputStream; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThanOrEqualTo; diff --git a/src/test/java/org/zalando/nakadi/security/BasicModeAuthenticationTest.java b/src/test/java/org/zalando/nakadi/security/BasicModeAuthenticationTest.java index 98a438baa7..51c28fd3f5 100644 --- a/src/test/java/org/zalando/nakadi/security/BasicModeAuthenticationTest.java +++ b/src/test/java/org/zalando/nakadi/security/BasicModeAuthenticationTest.java @@ -1,9 +1,10 @@ package org.zalando.nakadi.security; +import org.junit.Test; import org.zalando.nakadi.config.SecuritySettings; + import java.util.stream.Stream; -import org.junit.Test; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; diff --git a/src/test/java/org/zalando/nakadi/security/Endpoint.java b/src/test/java/org/zalando/nakadi/security/Endpoint.java index be1fc509b4..cbd1542db0 100644 --- a/src/test/java/org/zalando/nakadi/security/Endpoint.java +++ b/src/test/java/org/zalando/nakadi/security/Endpoint.java @@ -1,13 +1,15 @@ package org.zalando.nakadi.security; -import java.util.Optional; -import javax.annotation.concurrent.Immutable; import org.springframework.http.HttpMethod; +import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; + +import javax.annotation.concurrent.Immutable; +import java.util.Optional; + import static org.springframework.http.HttpMethod.DELETE; import static org.springframework.http.HttpMethod.GET; import static org.springframework.http.HttpMethod.POST; import static org.springframework.http.HttpMethod.PUT; -import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; diff --git a/src/test/java/org/zalando/nakadi/security/FullModeAuthenticationTest.java b/src/test/java/org/zalando/nakadi/security/FullModeAuthenticationTest.java index 9af762b5a0..e3e27b1907 100644 --- a/src/test/java/org/zalando/nakadi/security/FullModeAuthenticationTest.java +++ b/src/test/java/org/zalando/nakadi/security/FullModeAuthenticationTest.java @@ -1,8 +1,9 @@ package org.zalando.nakadi.security; -import org.zalando.nakadi.config.SecuritySettings; import org.junit.Test; +import org.zalando.nakadi.config.SecuritySettings; + import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; public class FullModeAuthenticationTest extends AuthenticationTest { diff --git a/src/test/java/org/zalando/nakadi/security/OffModeAuthenticationTest.java b/src/test/java/org/zalando/nakadi/security/OffModeAuthenticationTest.java index f2bf1d7159..9903931afc 100644 --- a/src/test/java/org/zalando/nakadi/security/OffModeAuthenticationTest.java +++ b/src/test/java/org/zalando/nakadi/security/OffModeAuthenticationTest.java @@ -1,8 +1,8 @@ package org.zalando.nakadi.security; -import org.zalando.nakadi.config.SecuritySettings; import org.junit.Test; +import org.zalando.nakadi.config.SecuritySettings; import java.util.stream.Stream; diff --git a/src/test/java/org/zalando/nakadi/service/ClosedConnectionsCrutchTest.java b/src/test/java/org/zalando/nakadi/service/ClosedConnectionsCrutchTest.java index d80cfc077e..a27f219781 100644 --- a/src/test/java/org/zalando/nakadi/service/ClosedConnectionsCrutchTest.java +++ b/src/test/java/org/zalando/nakadi/service/ClosedConnectionsCrutchTest.java @@ -1,13 +1,15 @@ package org.zalando.nakadi.service; import com.codahale.metrics.MetricRegistry; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.zalando.nakadi.util.FeatureToggleService; + import java.io.IOException; import java.net.InetAddress; import java.util.Map; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; + import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/src/test/java/org/zalando/nakadi/service/EventStreamConfigBuilderTest.java b/src/test/java/org/zalando/nakadi/service/EventStreamConfigBuilderTest.java index 3b82082c24..989bf3d645 100644 --- a/src/test/java/org/zalando/nakadi/service/EventStreamConfigBuilderTest.java +++ b/src/test/java/org/zalando/nakadi/service/EventStreamConfigBuilderTest.java @@ -2,6 +2,7 @@ import org.junit.Test; import org.zalando.nakadi.exceptions.UnprocessableEntityException; + import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; diff --git a/src/test/java/org/zalando/nakadi/service/EventTypeChangeListenerTest.java b/src/test/java/org/zalando/nakadi/service/EventTypeChangeListenerTest.java index 9a39720be6..d1c336c80a 100644 --- a/src/test/java/org/zalando/nakadi/service/EventTypeChangeListenerTest.java +++ b/src/test/java/org/zalando/nakadi/service/EventTypeChangeListenerTest.java @@ -1,18 +1,20 @@ package org.zalando.nakadi.service; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.ArgumentCaptor; +import org.zalando.nakadi.repository.db.EventTypeCache; + import java.io.Closeable; import java.io.IOException; import java.util.Collections; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentCaptor; + import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import org.zalando.nakadi.repository.db.EventTypeCache; public class EventTypeChangeListenerTest { diff --git a/src/test/java/org/zalando/nakadi/service/SubscriptionValidationServiceTest.java b/src/test/java/org/zalando/nakadi/service/SubscriptionValidationServiceTest.java index 4cb5c79245..183d4fceeb 100644 --- a/src/test/java/org/zalando/nakadi/service/SubscriptionValidationServiceTest.java +++ b/src/test/java/org/zalando/nakadi/service/SubscriptionValidationServiceTest.java @@ -2,25 +2,8 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.Matchers.isOneOf; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; import org.junit.Before; import org.junit.Test; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.argThat; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; import org.zalando.nakadi.config.NakadiSettings; import org.zalando.nakadi.domain.CursorError; import org.zalando.nakadi.domain.EventType; @@ -42,6 +25,25 @@ import org.zalando.nakadi.service.timeline.TimelineService; import org.zalando.nakadi.view.SubscriptionCursorWithoutToken; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.Matchers.isOneOf; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.argThat; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + public class SubscriptionValidationServiceTest { public static final int MAX_SUBSCRIPTION_PARTITIONS = 10; diff --git a/src/test/java/org/zalando/nakadi/service/converter/CursorConverterImplTest.java b/src/test/java/org/zalando/nakadi/service/converter/CursorConverterImplTest.java index ec6a86c75d..21695d4c62 100644 --- a/src/test/java/org/zalando/nakadi/service/converter/CursorConverterImplTest.java +++ b/src/test/java/org/zalando/nakadi/service/converter/CursorConverterImplTest.java @@ -1,7 +1,5 @@ package org.zalando.nakadi.service.converter; -import java.util.Collections; -import java.util.Optional; import org.junit.Assert; import org.junit.Test; import org.zalando.nakadi.domain.NakadiCursor; @@ -12,6 +10,10 @@ import org.zalando.nakadi.service.CursorConverter; import org.zalando.nakadi.service.timeline.TimelineService; import org.zalando.nakadi.view.Cursor; + +import java.util.Collections; +import java.util.Optional; + import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/src/test/java/org/zalando/nakadi/service/converter/VersionZeroConverterTest.java b/src/test/java/org/zalando/nakadi/service/converter/VersionZeroConverterTest.java index 55b8f22b48..eddc9da299 100644 --- a/src/test/java/org/zalando/nakadi/service/converter/VersionZeroConverterTest.java +++ b/src/test/java/org/zalando/nakadi/service/converter/VersionZeroConverterTest.java @@ -2,7 +2,6 @@ import org.junit.Before; import org.junit.Test; -import static org.mockito.Mockito.mock; import org.zalando.nakadi.exceptions.InternalNakadiException; import org.zalando.nakadi.exceptions.InvalidCursorException; import org.zalando.nakadi.exceptions.NoSuchEventTypeException; @@ -11,6 +10,8 @@ import org.zalando.nakadi.service.timeline.TimelineService; import org.zalando.nakadi.view.Cursor; +import static org.mockito.Mockito.mock; + public class VersionZeroConverterTest { private TimelineService timelineService; diff --git a/src/test/java/org/zalando/nakadi/service/subscription/ExactWeightRebalancerTest.java b/src/test/java/org/zalando/nakadi/service/subscription/ExactWeightRebalancerTest.java index c2bed90a91..576ac7757e 100644 --- a/src/test/java/org/zalando/nakadi/service/subscription/ExactWeightRebalancerTest.java +++ b/src/test/java/org/zalando/nakadi/service/subscription/ExactWeightRebalancerTest.java @@ -1,18 +1,20 @@ package org.zalando.nakadi.service.subscription; +import org.junit.Test; +import org.zalando.nakadi.domain.EventTypePartition; +import org.zalando.nakadi.service.subscription.model.Partition; +import org.zalando.nakadi.service.subscription.model.Session; + import java.util.stream.Stream; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.emptyArray; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import org.junit.Test; -import org.zalando.nakadi.domain.EventTypePartition; -import org.zalando.nakadi.service.subscription.model.Partition; import static org.zalando.nakadi.service.subscription.model.Partition.State.ASSIGNED; import static org.zalando.nakadi.service.subscription.model.Partition.State.REASSIGNING; -import org.zalando.nakadi.service.subscription.model.Session; public class ExactWeightRebalancerTest { diff --git a/src/test/java/org/zalando/nakadi/service/subscription/StartingStateTest.java b/src/test/java/org/zalando/nakadi/service/subscription/StartingStateTest.java index 0cfe2657f6..834d942d8f 100644 --- a/src/test/java/org/zalando/nakadi/service/subscription/StartingStateTest.java +++ b/src/test/java/org/zalando/nakadi/service/subscription/StartingStateTest.java @@ -3,14 +3,9 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; -import java.util.Collections; -import java.util.List; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.PartitionStatistics; import org.zalando.nakadi.domain.Subscription; @@ -22,6 +17,13 @@ import org.zalando.nakadi.service.timeline.TimelineService; import org.zalando.nakadi.view.SubscriptionCursorWithoutToken; +import java.util.Collections; +import java.util.List; + +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + public class StartingStateTest { public static final String ET_0 = "et_0"; diff --git a/src/test/java/org/zalando/nakadi/service/subscription/model/PartitionTest.java b/src/test/java/org/zalando/nakadi/service/subscription/model/PartitionTest.java index ab4a8c61ac..885bbf901c 100644 --- a/src/test/java/org/zalando/nakadi/service/subscription/model/PartitionTest.java +++ b/src/test/java/org/zalando/nakadi/service/subscription/model/PartitionTest.java @@ -1,16 +1,18 @@ package org.zalando.nakadi.service.subscription.model; import com.google.common.collect.ImmutableList; +import org.junit.Assert; +import org.junit.Test; +import org.zalando.nakadi.domain.EventTypePartition; + import java.util.Arrays; import java.util.Collection; + import static java.util.Collections.singletonList; -import org.junit.Assert; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import org.junit.Test; -import org.zalando.nakadi.domain.EventTypePartition; public class PartitionTest { @Test diff --git a/src/test/java/org/zalando/nakadi/service/subscription/state/PartitionDataTest.java b/src/test/java/org/zalando/nakadi/service/subscription/state/PartitionDataTest.java index f13486fcaf..068ad20c72 100644 --- a/src/test/java/org/zalando/nakadi/service/subscription/state/PartitionDataTest.java +++ b/src/test/java/org/zalando/nakadi/service/subscription/state/PartitionDataTest.java @@ -1,12 +1,14 @@ package org.zalando.nakadi.service.subscription.state; -import java.util.List; -import java.util.concurrent.TimeUnit; import org.junit.Test; import org.zalando.nakadi.domain.ConsumedEvent; import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.Timeline; import org.zalando.nakadi.repository.kafka.KafkaCursor; + +import java.util.List; +import java.util.concurrent.TimeUnit; + import static java.lang.System.currentTimeMillis; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; diff --git a/src/test/java/org/zalando/nakadi/service/subscription/state/StreamingStateTest.java b/src/test/java/org/zalando/nakadi/service/subscription/state/StreamingStateTest.java index 24da2ce45c..f9225e4b1b 100644 --- a/src/test/java/org/zalando/nakadi/service/subscription/state/StreamingStateTest.java +++ b/src/test/java/org/zalando/nakadi/service/subscription/state/StreamingStateTest.java @@ -1,16 +1,9 @@ package org.zalando.nakadi.service.subscription.state; import com.codahale.metrics.MetricRegistry; -import java.util.Collections; -import java.util.Date; -import java.util.Optional; import org.junit.Before; import org.junit.Test; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; import org.mockito.Mockito; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import org.zalando.nakadi.domain.EventTypePartition; import org.zalando.nakadi.domain.NakadiCursor; import org.zalando.nakadi.domain.PartitionStatistics; @@ -31,6 +24,15 @@ import org.zalando.nakadi.service.timeline.TimelineService; import org.zalando.nakadi.view.SubscriptionCursorWithoutToken; +import java.util.Collections; +import java.util.Date; +import java.util.Optional; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + public class StreamingStateTest { private StreamingState state; diff --git a/src/test/java/org/zalando/nakadi/util/FeatureToggleServiceTest.java b/src/test/java/org/zalando/nakadi/util/FeatureToggleServiceTest.java index 3efd248168..624e4a9986 100644 --- a/src/test/java/org/zalando/nakadi/util/FeatureToggleServiceTest.java +++ b/src/test/java/org/zalando/nakadi/util/FeatureToggleServiceTest.java @@ -1,17 +1,17 @@ package org.zalando.nakadi.util; -import org.zalando.nakadi.repository.zookeeper.ZooKeeperHolder; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.api.ExistsBuilder; import org.apache.zookeeper.data.Stat; import org.junit.Before; import org.junit.Test; +import org.zalando.nakadi.repository.zookeeper.ZooKeeperHolder; -import static org.zalando.nakadi.util.FeatureToggleService.Feature.HIGH_LEVEL_API; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import static org.zalando.nakadi.util.FeatureToggleService.Feature.HIGH_LEVEL_API; public class FeatureToggleServiceTest { diff --git a/src/test/java/org/zalando/nakadi/util/JsonPathAccessTest.java b/src/test/java/org/zalando/nakadi/util/JsonPathAccessTest.java index 1139ffc2f5..28d847ec5a 100644 --- a/src/test/java/org/zalando/nakadi/util/JsonPathAccessTest.java +++ b/src/test/java/org/zalando/nakadi/util/JsonPathAccessTest.java @@ -1,9 +1,9 @@ package org.zalando.nakadi.util; -import org.zalando.nakadi.exceptions.InvalidPartitionKeyFieldsException; -import org.zalando.nakadi.utils.TestUtils; import org.json.JSONObject; import org.junit.Test; +import org.zalando.nakadi.exceptions.InvalidPartitionKeyFieldsException; +import org.zalando.nakadi.utils.TestUtils; import java.io.IOException; diff --git a/src/test/java/org/zalando/nakadi/util/NakadiCollectionUtilsTest.java b/src/test/java/org/zalando/nakadi/util/NakadiCollectionUtilsTest.java index 5fd468b181..b190fbf63d 100644 --- a/src/test/java/org/zalando/nakadi/util/NakadiCollectionUtilsTest.java +++ b/src/test/java/org/zalando/nakadi/util/NakadiCollectionUtilsTest.java @@ -1,10 +1,11 @@ package org.zalando.nakadi.util; import com.google.common.collect.ImmutableSet; -import java.util.Set; import org.junit.Assert; import org.junit.Test; +import java.util.Set; + public class NakadiCollectionUtilsTest { @Test public void testDifference() { diff --git a/src/test/java/org/zalando/nakadi/util/PrincipalMockFactory.java b/src/test/java/org/zalando/nakadi/util/PrincipalMockFactory.java index 2182333d66..f6b23095f3 100644 --- a/src/test/java/org/zalando/nakadi/util/PrincipalMockFactory.java +++ b/src/test/java/org/zalando/nakadi/util/PrincipalMockFactory.java @@ -1,10 +1,10 @@ package org.zalando.nakadi.util; +import java.security.Principal; + import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import java.security.Principal; - public class PrincipalMockFactory { public static Principal mockPrincipal(final String clientId) { diff --git a/src/test/java/org/zalando/nakadi/util/TimeLoggerTest.java b/src/test/java/org/zalando/nakadi/util/TimeLoggerTest.java index ca7932b997..92fa870b3a 100644 --- a/src/test/java/org/zalando/nakadi/util/TimeLoggerTest.java +++ b/src/test/java/org/zalando/nakadi/util/TimeLoggerTest.java @@ -1,9 +1,10 @@ package org.zalando.nakadi.util; -import java.util.regex.Pattern; import org.junit.Assert; import org.junit.Test; +import java.util.regex.Pattern; + public class TimeLoggerTest { @Test diff --git a/src/test/java/org/zalando/nakadi/validation/RFC3339DateTimeValidatorTest.java b/src/test/java/org/zalando/nakadi/validation/RFC3339DateTimeValidatorTest.java index cd39155812..3af554f40d 100644 --- a/src/test/java/org/zalando/nakadi/validation/RFC3339DateTimeValidatorTest.java +++ b/src/test/java/org/zalando/nakadi/validation/RFC3339DateTimeValidatorTest.java @@ -1,7 +1,8 @@ package org.zalando.nakadi.validation; -import static org.junit.Assert.assertThat; import org.junit.Test; + +import static org.junit.Assert.assertThat; import static org.zalando.nakadi.utils.IsOptional.isAbsent; import static org.zalando.nakadi.utils.IsOptional.isPresent; diff --git a/src/test/java/org/zalando/nakadi/validation/SchemaEvolutionServiceTest.java b/src/test/java/org/zalando/nakadi/validation/SchemaEvolutionServiceTest.java index d00c75c1d7..4befaa46c1 100644 --- a/src/test/java/org/zalando/nakadi/validation/SchemaEvolutionServiceTest.java +++ b/src/test/java/org/zalando/nakadi/validation/SchemaEvolutionServiceTest.java @@ -16,9 +16,9 @@ import org.zalando.nakadi.domain.Version; import org.zalando.nakadi.exceptions.InvalidEventTypeException; import org.zalando.nakadi.utils.EventTypeTestBuilder; -import org.zalando.nakadi.validation.schema.diff.SchemaDiff; import org.zalando.nakadi.validation.schema.SchemaEvolutionConstraint; import org.zalando.nakadi.validation.schema.SchemaEvolutionIncompatibility; +import org.zalando.nakadi.validation.schema.diff.SchemaDiff; import java.io.IOException; import java.util.HashMap;