From 2a77a3144b908ec239d41bfb2289e675f24607c6 Mon Sep 17 00:00:00 2001 From: a1exsh Date: Wed, 18 Oct 2023 10:50:59 +0200 Subject: [PATCH] Big cleanup of Hamcrest imports (#1563) It got messy over the time, mainly due to auto-import suggestions from IDEs. --- .../db/EventTypeDbRepositoryTest.java | 8 +- .../db/SubscriptionDbRepositoryTest.java | 4 +- .../zalando/nakadi/webservice/AuditLogAT.java | 2 +- .../nakadi/webservice/CursorOperationsAT.java | 2 +- .../nakadi/webservice/EventTypeAT.java | 4 +- .../webservice/TimelinesControllerAT.java | 2 +- .../nakadi/webservice/UserJourneyAT.java | 33 ++++---- .../nakadi/webservice/hila/HilaAT.java | 80 ++++++++++--------- .../webservice/hila/HilaDeleteEventsAT.java | 2 +- .../webservice/hila/HilaRebalanceAT.java | 2 +- .../webservice/hila/HilaRepartitionAT.java | 20 ++--- .../webservice/hila/SubscriptionAT.java | 2 +- .../controller/EventStreamControllerTest.java | 27 +++---- .../service/EventStreamConfigBuilderTest.java | 4 +- .../nakadi/service/EventStreamTest.java | 2 +- .../subscription/IdleStreamWatcherTest.java | 2 +- .../subscription/StreamParametersTest.java | 4 +- .../SubscriptionRebalancerTest.java | 2 +- .../controller/EventTypeControllerTest.java | 9 +-- .../SubscriptionTimeLagServiceTest.java | 2 +- .../EventPublishingControllerTest.java | 4 +- .../service/job/TimelineCleaningJobTest.java | 2 +- .../zalando/nakadi/domain/EventTypeTest.java | 13 ++- .../nakadi/domain/NakadiCursorTest.java | 4 +- .../zalando/nakadi/domain/VersionTest.java | 6 +- .../kafka/KafkaTopicRepositoryTest.java | 2 +- .../zk/ZkSubscriptionNodeTest.java | 2 +- .../nakadi/util/HashGeneratorTest.java | 4 +- .../nakadi/util/JsonPathAccessTest.java | 6 +- .../MetadataEnrichmentStrategyTest.java | 4 +- .../partitioning/EventKeyExtractorTest.java | 4 +- .../HashPartitionStrategyCrutchTest.java | 2 +- .../HashPartitionStrategyTest.java | 2 +- .../nakadi/partitioning/StringHashTest.java | 2 +- .../service/AuthorizationValidatorTest.java | 4 +- .../service/CursorOperationsServiceTest.java | 32 ++++---- .../SubscriptionValidationServiceTest.java | 2 +- .../publishing/EventPublisherTest.java | 4 +- .../publishing/NakadiKpiPublisherTest.java | 2 +- .../validation/JSONSchemaValidationTest.java | 15 ++-- .../validation/JsonSchemaEnrichmentTest.java | 4 +- .../SchemaEvolutionServiceTest.java | 4 +- .../schema/CategoryChangeConstraintTest.java | 4 +- .../validation/schema/SchemaDiffTest.java | 6 +- 44 files changed, 174 insertions(+), 173 deletions(-) diff --git a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/repository/db/EventTypeDbRepositoryTest.java b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/repository/db/EventTypeDbRepositoryTest.java index 2897023d4e..b09222c385 100644 --- a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/repository/db/EventTypeDbRepositoryTest.java +++ b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/repository/db/EventTypeDbRepositoryTest.java @@ -20,13 +20,13 @@ import java.util.Optional; import java.util.stream.Collectors; -import static org.hamcrest.CoreMatchers.hasItem; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasProperty; import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.IsEqual.equalTo; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; import static org.zalando.nakadi.utils.TestUtils.buildDefaultEventType; import static org.zalando.nakadi.utils.TestUtils.randomTextString; diff --git a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/repository/db/SubscriptionDbRepositoryTest.java b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/repository/db/SubscriptionDbRepositoryTest.java index c5d10a44ed..37f6ba8485 100644 --- a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/repository/db/SubscriptionDbRepositoryTest.java +++ b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/repository/db/SubscriptionDbRepositoryTest.java @@ -26,10 +26,10 @@ import static java.util.Collections.emptySet; import static java.util.stream.Collectors.toList; -import static org.hamcrest.core.IsEqual.equalTo; -import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.isEmptyOrNullString; +import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; import static org.zalando.nakadi.utils.TestUtils.createRandomSubscriptions; diff --git a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/AuditLogAT.java b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/AuditLogAT.java index 77b643ee83..38183cb0aa 100644 --- a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/AuditLogAT.java +++ b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/AuditLogAT.java @@ -11,8 +11,8 @@ import static com.jayway.restassured.RestAssured.given; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.core.IsEqual.equalTo; import static org.zalando.nakadi.domain.SubscriptionBase.InitialPosition.END; import static org.zalando.nakadi.utils.TestUtils.waitFor; import static org.zalando.nakadi.webservice.utils.NakadiTestUtils.createEventType; diff --git a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/CursorOperationsAT.java b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/CursorOperationsAT.java index 0ec3442257..5073eb1666 100644 --- a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/CursorOperationsAT.java +++ b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/CursorOperationsAT.java @@ -9,7 +9,7 @@ import org.zalando.nakadi.utils.EventTypeTestBuilder; import org.zalando.nakadi.webservice.utils.NakadiTestUtils; -import static org.hamcrest.core.IsEqual.equalTo; +import static org.hamcrest.Matchers.equalTo; import static org.springframework.http.HttpStatus.OK; import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY; import static org.zalando.nakadi.utils.TestUtils.randomTextString; diff --git a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/EventTypeAT.java b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/EventTypeAT.java index d53f867662..3c2d1227bf 100644 --- a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/EventTypeAT.java +++ b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/EventTypeAT.java @@ -46,12 +46,12 @@ import static com.jayway.restassured.http.ContentType.JSON; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasEntry; import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.Matchers.hasKey; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsEqual.equalTo; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; import static org.zalando.nakadi.utils.TestUtils.buildDefaultEventType; import static org.zalando.nakadi.utils.TestUtils.randomTextString; diff --git a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/TimelinesControllerAT.java b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/TimelinesControllerAT.java index 08fd44a0d8..66b14ee4f8 100644 --- a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/TimelinesControllerAT.java +++ b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/TimelinesControllerAT.java @@ -16,7 +16,7 @@ import static java.time.temporal.ChronoUnit.DAYS; import static java.time.temporal.ChronoUnit.MINUTES; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.nullValue; import static org.zalando.nakadi.util.DateWithinMatcher.dateWithin; public class TimelinesControllerAT extends BaseAT { diff --git a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/UserJourneyAT.java b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/UserJourneyAT.java index 0dd7e57e01..af9f4a1082 100644 --- a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/UserJourneyAT.java +++ b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/UserJourneyAT.java @@ -12,7 +12,6 @@ import com.jayway.restassured.response.Header; import com.jayway.restassured.specification.RequestSpecification; import org.echocat.jomon.runtime.concurrent.RetryForSpecifiedTimeStrategy; -import org.hamcrest.Matchers; import org.json.JSONObject; import org.junit.Before; import org.junit.Test; @@ -35,8 +34,12 @@ import static java.util.stream.LongStream.rangeClosed; import static org.echocat.jomon.runtime.concurrent.Retryer.executeWithRetry; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.notNullValue; import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.NOT_FOUND; import static org.springframework.http.HttpStatus.NO_CONTENT; @@ -115,12 +118,12 @@ public void userJourneyM1() throws InterruptedException, IOException { .get("/event-types") .then() .statusCode(OK.value()) - .body("size()", Matchers.greaterThan(0)) - .body("name[0]", Matchers.notNullValue()) - .body("owning_application[0]", Matchers.notNullValue()) - .body("category[0]", Matchers.notNullValue()) - .body("schema.type[0]", Matchers.notNullValue()) - .body("schema.schema[0]", Matchers.notNullValue()); + .body("size()", greaterThan(0)) + .body("name[0]", notNullValue()) + .body("owning_application[0]", notNullValue()) + .body("category[0]", notNullValue()) + .body("schema.type[0]", notNullValue()) + .body("schema.schema[0]", notNullValue()); final String updateEventTypeBody = getUpdateEventType(); @@ -190,9 +193,9 @@ public void userJourneyM1() throws InterruptedException, IOException { .get("/event-types/" + eventTypeName + "/partitions") .then() .statusCode(OK.value()) - .body("size()", equalTo(1)).body("partition[0]", Matchers.notNullValue()) - .body("oldest_available_offset[0]", Matchers.notNullValue()) - .body("newest_available_offset[0]", Matchers.notNullValue()); + .body("size()", equalTo(1)).body("partition[0]", notNullValue()) + .body("oldest_available_offset[0]", notNullValue()) + .body("newest_available_offset[0]", notNullValue()); // read events requestSpec() @@ -340,7 +343,7 @@ public void userJourneyHila() throws InterruptedException, IOException { // create client and wait till we receive all events final TestStreamingClient client = new TestStreamingClient( RestAssured.baseURI + ":" + RestAssured.port, subscription.getId(), "", oauthToken).start(); - waitFor(() -> assertThat(client.getJsonBatches(), Matchers.hasSize(4))); + waitFor(() -> assertThat(client.getJsonBatches(), hasSize(4))); final List batches = client.getJsonBatches(); // validate the content of events @@ -361,7 +364,7 @@ public void userJourneyHila() throws InterruptedException, IOException { .then() .statusCode(OK.value()) .body("items[0].partitions[0].unconsumed_events", equalTo(4)) - .body("items[0].partitions[0].consumer_lag_seconds", Matchers.greaterThanOrEqualTo(0)); + .body("items[0].partitions[0].consumer_lag_seconds", greaterThanOrEqualTo(0)); // commit cursor of latest event final StreamBatch lastBatch = batches.get(batches.size() - 1); @@ -442,7 +445,7 @@ public void userJourneyAvroTransition() throws InterruptedException, IOException final TestStreamingClient client = new TestStreamingClient( RestAssured.baseURI + ":" + RestAssured.port, subscription.getId(), "", oauthToken).start(); - waitFor(() -> assertThat(client.getJsonBatches(), Matchers.hasSize(4))); + waitFor(() -> assertThat(client.getJsonBatches(), hasSize(4))); final List batches = client.getJsonBatches(); // validate the events metadata diff --git a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/HilaAT.java b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/HilaAT.java index b45cf88988..0afcb6d299 100644 --- a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/HilaAT.java +++ b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/HilaAT.java @@ -6,8 +6,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import org.apache.http.HttpStatus; -import org.hamcrest.Matchers; -import org.hamcrest.core.StringContains; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -42,9 +40,13 @@ import static com.jayway.restassured.RestAssured.given; import static com.jayway.restassured.RestAssured.when; import static com.jayway.restassured.http.ContentType.JSON; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; import static org.zalando.nakadi.domain.SubscriptionBase.InitialPosition.BEGIN; import static org.zalando.nakadi.domain.SubscriptionBase.InitialPosition.END; import static org.zalando.nakadi.domain.SubscriptionEventTypeStats.Partition.AssignmentType.AUTO; @@ -83,7 +85,7 @@ public void whenStreamTimeoutReachedPossibleToCommit() throws Exception { final TestStreamingClient client = TestStreamingClient .create(URL, subscription.getId(), "batch_limit=1&stream_limit=2&stream_timeout=1") .start(); - waitFor(() -> assertThat(client.getSessionId(), Matchers.not(equalTo(SESSION_ID_UNKNOWN)))); + waitFor(() -> assertThat(client.getSessionId(), not(equalTo(SESSION_ID_UNKNOWN)))); publishEvent(eventType.getName(), "{\"foo\":\"bar\"}"); waitFor(() -> Assert.assertFalse(client.getJsonBatches().isEmpty()), TimeUnit.SECONDS.toMillis(2), 100); @@ -113,7 +115,7 @@ public void whenEventTypeRepartitionedTheNewSubscriptionShouldHaveUpdatedPartiti .start(); NakadiTestUtils.publishBusinessEventWithUserDefinedPartition( eventType.getName(), 1, x -> "{\"foo\":\"bar" + x + "\"}", p -> "1"); - waitFor(() -> assertThat(clientAfterRepartitioning.getJsonBatches(), Matchers.hasSize(2))); + waitFor(() -> assertThat(clientAfterRepartitioning.getJsonBatches(), hasSize(2))); Assert.assertTrue(clientAfterRepartitioning.getJsonBatches().stream() .anyMatch(event -> event.getCursor().getPartition().equals("1"))); } @@ -124,15 +126,15 @@ public void whenStreamTimeoutReachedThenEventsFlushed() { .create(URL, subscription.getId(), "batch_flush_timeout=600&batch_limit=1000&stream_timeout=2&max_uncommitted_events=1000") .start(); - waitFor(() -> assertThat(client.getSessionId(), Matchers.not(equalTo(SESSION_ID_UNKNOWN)))); + waitFor(() -> assertThat(client.getSessionId(), not(equalTo(SESSION_ID_UNKNOWN)))); publishEvents(eventType.getName(), 4, x -> "{\"foo\":\"bar\"}"); // when stream_timeout is reached we should get 2 batches: // first one containing 4 events, second one with debug message - waitFor(() -> assertThat(client.getJsonBatches(), Matchers.hasSize(2))); - assertThat(client.getJsonBatches().get(0).getEvents(), Matchers.hasSize(4)); - assertThat(client.getJsonBatches().get(1).getEvents(), Matchers.hasSize(0)); + waitFor(() -> assertThat(client.getJsonBatches(), hasSize(2))); + assertThat(client.getJsonBatches().get(0).getEvents(), hasSize(4)); + assertThat(client.getJsonBatches().get(1).getEvents(), hasSize(0)); System.out.println(client.getJsonBatches()); } @@ -145,7 +147,7 @@ public void whenOffsetIsCommittedNextSessionStartsFromNextEventAfterCommitted() final TestStreamingClient client = TestStreamingClient .create(URL, subscription.getId(), "stream_limit=2") .start(); - waitFor(() -> assertThat(client.getJsonBatches(), Matchers.hasSize(2))); + waitFor(() -> assertThat(client.getJsonBatches(), hasSize(2))); assertThat(client.getJsonBatches().get(0), equalToBatchIgnoringToken(singleEventBatch("0", "001-0001-000000000000000000", eventType.getName(), ImmutableMap.of("foo", "bar0"), "Stream started"))); @@ -159,7 +161,7 @@ public void whenOffsetIsCommittedNextSessionStartsFromNextEventAfterCommitted() // create new session and read from subscription again client.start(); - waitFor(() -> assertThat(client.getJsonBatches(), Matchers.hasSize(2))); + waitFor(() -> assertThat(client.getJsonBatches(), hasSize(2))); // check that we have read the next two events with correct offsets assertThat(client.getJsonBatches().get(0), equalToBatchIgnoringToken(singleEventBatch("0", @@ -175,7 +177,7 @@ public void whenNoEventsThenFirstOffsetIsBEGIN() { final TestStreamingClient client = TestStreamingClient .create(URL, subscription.getId(), "batch_flush_timeout=1") .start(); - waitFor(() -> assertThat(client.getJsonBatches(), Matchers.not(Matchers.empty()))); + waitFor(() -> assertThat(client.getJsonBatches(), not(empty()))); assertThat(client.getJsonBatches().get(0).getCursor().getOffset(), equalTo("001-0001--1")); } @@ -184,7 +186,7 @@ public void whenNoEventsThenBeginOffsetIsUsed() throws Exception { final TestStreamingClient client = TestStreamingClient .create(subscription.getId()) .start(); - waitFor(() -> assertThat(client.getSessionId(), Matchers.not(equalTo(SESSION_ID_UNKNOWN)))); + waitFor(() -> assertThat(client.getSessionId(), not(equalTo(SESSION_ID_UNKNOWN)))); when().get("/subscriptions/{sid}/cursors", subscription.getId()) .then() @@ -204,7 +206,7 @@ public void whenCommitVeryFirstEventThenOk() throws Exception { final TestStreamingClient client = TestStreamingClient .create(subscription.getId()) .start(); - waitFor(() -> assertThat(client.getJsonBatches(), Matchers.not(Matchers.empty()))); + waitFor(() -> assertThat(client.getJsonBatches(), not(empty()))); // commit and check that status is 204 final int commitResult = commitCursors(subscription.getId(), @@ -222,17 +224,17 @@ public void whenWindowSizeIsSetItIsConsidered() throws Exception { .create(URL, subscription.getId(), "max_uncommitted_events=5") .start(); - waitFor(() -> assertThat(client.getJsonBatches(), Matchers.hasSize(5))); + waitFor(() -> assertThat(client.getJsonBatches(), hasSize(5))); SubscriptionCursor cursorToCommit = client.getJsonBatches().get(4).getCursor(); commitCursors(subscription.getId(), ImmutableList.of(cursorToCommit), client.getSessionId()); - waitFor(() -> assertThat(client.getJsonBatches(), Matchers.hasSize(10))); + waitFor(() -> assertThat(client.getJsonBatches(), hasSize(10))); cursorToCommit = client.getJsonBatches().get(6).getCursor(); commitCursors(subscription.getId(), ImmutableList.of(cursorToCommit), client.getSessionId()); - waitFor(() -> assertThat(client.getJsonBatches(), Matchers.hasSize(12))); + waitFor(() -> assertThat(client.getJsonBatches(), hasSize(12))); } @Test(timeout = 15000) @@ -244,7 +246,7 @@ public void whenCommitTimeoutReachedSessionIsClosed() { .create(subscription.getId()) // commit_timeout is 5 seconds for test .start(); - waitFor(() -> assertThat(client.getJsonBatches(), Matchers.hasSize(2)), 10000); + waitFor(() -> assertThat(client.getJsonBatches(), hasSize(2)), 10000); waitFor(() -> assertThat(client.isRunning(), is(false)), 10000); assertThat(client.getJsonBatches().get(1), equalToBatchIgnoringToken(singleEventBatch("0", "001-0001-000000000000000000", eventType.getName(), ImmutableMap.of(), "Commit timeout reached"))); @@ -259,7 +261,7 @@ public void whenStreamTimeoutReachedSessionIsClosed() throws Exception { .create(URL, subscription.getId(), "stream_timeout=3") .start(); - waitFor(() -> assertThat(client.getJsonBatches(), Matchers.hasSize(1))); + waitFor(() -> assertThat(client.getJsonBatches(), hasSize(1))); // to check that stream_timeout works we need to commit everything we consumed, in other case // Nakadi will first wait till commit_timeout exceeds @@ -279,15 +281,15 @@ public void whenBatchLimitAndTimeoutAreSetTheyAreConsidered() { .create(URL, subscription.getId(), "batch_limit=5&batch_flush_timeout=1&max_uncommitted_events=20") .start(); - waitFor(() -> assertThat(client.getJsonBatches(), Matchers.hasSize(3))); + waitFor(() -> assertThat(client.getJsonBatches(), hasSize(3))); - assertThat(client.getJsonBatches().get(0).getEvents(), Matchers.hasSize(5)); + assertThat(client.getJsonBatches().get(0).getEvents(), hasSize(5)); assertThat(client.getJsonBatches().get(0).getCursor().getOffset(), is("001-0001-000000000000000004")); - assertThat(client.getJsonBatches().get(1).getEvents(), Matchers.hasSize(5)); + assertThat(client.getJsonBatches().get(1).getEvents(), hasSize(5)); assertThat(client.getJsonBatches().get(1).getCursor().getOffset(), is("001-0001-000000000000000009")); - assertThat(client.getJsonBatches().get(2).getEvents(), Matchers.hasSize(2)); + assertThat(client.getJsonBatches().get(2).getEvents(), hasSize(2)); assertThat(client.getJsonBatches().get(2).getCursor().getOffset(), is("001-0001-000000000000000011")); } @@ -297,7 +299,7 @@ public void whenThereAreNoEmptySlotsThenConflict() { final TestStreamingClient client = TestStreamingClient .create(URL, subscription.getId(), "batch_flush_timeout=1"); client.start(); - waitFor(() -> assertThat(client.getJsonBatches(), Matchers.hasSize(1))); + waitFor(() -> assertThat(client.getJsonBatches(), hasSize(1))); given() .get("/subscriptions/{id}/events", subscription.getId()) @@ -311,7 +313,7 @@ public void whenConnectionIsClosedByClientNakadiRecognizesIt() throws Exception final TestStreamingClient client = TestStreamingClient .create(URL, subscription.getId(), "batch_flush_timeout=1"); client.start(); - waitFor(() -> assertThat(client.getJsonBatches(), Matchers.hasSize(1))); + waitFor(() -> assertThat(client.getJsonBatches(), hasSize(1))); client.close(); ThreadUtils.sleep(10000); @@ -321,7 +323,7 @@ public void whenConnectionIsClosedByClientNakadiRecognizesIt() throws Exception anotherClient.start(); // if we start to get data for another client it means that Nakadi recognized that first client closed // connection (in other case it would not allow second client to connect because of lack of slots) - waitFor(() -> assertThat(anotherClient.getJsonBatches(), Matchers.hasSize(1))); + waitFor(() -> assertThat(anotherClient.getJsonBatches(), hasSize(1))); } @Test(timeout = 10000) @@ -331,7 +333,7 @@ public void testGetSubscriptionStat() throws Exception { final TestStreamingClient client = TestStreamingClient .create(URL, subscription.getId(), "max_uncommitted_events=20") .start(); - waitFor(() -> assertThat(client.getJsonBatches(), Matchers.hasSize(15))); + waitFor(() -> assertThat(client.getJsonBatches(), hasSize(15))); List subscriptionStats = Collections.singletonList(new SubscriptionEventTypeStats( @@ -346,7 +348,7 @@ public void testGetSubscriptionStat() throws Exception { ); NakadiTestUtils.getSubscriptionStat(subscription) .then() - .content(new StringContains(JSON_TEST_HELPER.asJsonString(new ItemsWrapper<>(subscriptionStats)))); + .content(containsString(JSON_TEST_HELPER.asJsonString(new ItemsWrapper<>(subscriptionStats)))); final String partition = client.getJsonBatches().get(0).getCursor().getPartition(); final SubscriptionCursor cursor = new SubscriptionCursor(partition, "9", eventType.getName(), "token"); @@ -365,7 +367,7 @@ public void testGetSubscriptionStat() throws Exception { ); NakadiTestUtils.getSubscriptionStat(subscription) .then() - .content(new StringContains(JSON_TEST_HELPER.asJsonString(new ItemsWrapper<>(subscriptionStats)))); + .content(containsString(JSON_TEST_HELPER.asJsonString(new ItemsWrapper<>(subscriptionStats)))); } @Test(timeout = 10000) @@ -377,11 +379,11 @@ public void testGetSubscriptionStatWhenDirectAssignment() throws Exception { "{\"event_type\":\"" + eventType.getName() + "\",\"partition\":\"0\"}]}")); client.start(); // wait for rebalance to finish - waitFor(() -> assertThat(getNumberOfAssignedStreams(subscription.getId()), Matchers.is(1))); + waitFor(() -> assertThat(getNumberOfAssignedStreams(subscription.getId()), is(1))); NakadiTestUtils.getSubscriptionStat(subscription) .then() - .content(new StringContains(JSON_TEST_HELPER.asJsonString(new SubscriptionEventTypeStats( + .content(containsString(JSON_TEST_HELPER.asJsonString(new SubscriptionEventTypeStats( eventType.getName(), Collections.singletonList(new SubscriptionEventTypeStats.Partition( "0", @@ -415,7 +417,7 @@ public void testSubscriptionStatsMultiET() throws IOException { NakadiTestUtils.getSubscriptionStat(subscription) .then() - .content(new StringContains(JSON_TEST_HELPER.asJsonString(new SubscriptionEventTypeStats( + .content(containsString(JSON_TEST_HELPER.asJsonString(new SubscriptionEventTypeStats( eventTypes.get(0).getName(), Collections.singletonList(new SubscriptionEventTypeStats.Partition( "0", @@ -425,7 +427,7 @@ public void testSubscriptionStatsMultiET() throws IOException { client.getSessionId(), AUTO )))))) - .content(new StringContains(JSON_TEST_HELPER.asJsonString(new SubscriptionEventTypeStats( + .content(containsString(JSON_TEST_HELPER.asJsonString(new SubscriptionEventTypeStats( eventTypes.get(1).getName(), Collections.singletonList(new SubscriptionEventTypeStats.Partition( "0", @@ -461,10 +463,10 @@ public void whenConsumerIsBlockedDuringConsumption() throws Exception { final TestStreamingClient client = TestStreamingClient .create(subscription.getId()) .start(); - waitFor(() -> assertThat(client.getJsonBatches(), Matchers.hasSize(5))); + waitFor(() -> assertThat(client.getJsonBatches(), hasSize(5))); SettingsControllerAT.blacklist(eventType.getName(), BlacklistService.Type.CONSUMER_ET); - waitFor(() -> assertThat(client.getJsonBatches(), Matchers.hasSize(6))); + waitFor(() -> assertThat(client.getJsonBatches(), hasSize(6))); Assert.assertEquals("Consumption is blocked", client.getJsonBatches().get(client.getJsonBatches().size() - 1).getMetadata().getDebug()); @@ -478,7 +480,7 @@ public void whenStreamTimeout0ThenInfiniteStreaming() { .create(URL, subscription.getId(), "stream_timeout=0") .start(); - waitFor(() -> assertThat(client.getJsonBatches(), Matchers.hasSize(5))); + waitFor(() -> assertThat(client.getJsonBatches(), hasSize(5))); Assert.assertFalse(client.getJsonBatches().stream() .anyMatch(streamBatch -> streamBatch.getMetadata() != null && streamBatch.getMetadata().getDebug().equals("Stream timeout reached"))); @@ -490,7 +492,7 @@ public void whenResetCursorsThenStreamFromResetCursorOffset() throws Exception { final TestStreamingClient client1 = TestStreamingClient .create(subscription.getId()) .start(); - waitFor(() -> assertThat(client1.getJsonBatches(), Matchers.hasSize(10))); + waitFor(() -> assertThat(client1.getJsonBatches(), hasSize(10))); int statusCode = commitCursors( subscription.getId(), @@ -515,7 +517,7 @@ public void whenResetCursorsThenStreamFromResetCursorOffset() throws Exception { final TestStreamingClient client2 = TestStreamingClient .create(subscription.getId()) .start(); - waitFor(() -> assertThat(client2.getJsonBatches(), Matchers.hasSize(10))); + waitFor(() -> assertThat(client2.getJsonBatches(), hasSize(10))); Assert.assertEquals("001-0001-000000000000000005", client2.getJsonBatches().get(0).getCursor().getOffset()); } diff --git a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/HilaDeleteEventsAT.java b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/HilaDeleteEventsAT.java index c97a1da37c..2daae105fa 100644 --- a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/HilaDeleteEventsAT.java +++ b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/HilaDeleteEventsAT.java @@ -19,8 +19,8 @@ import java.io.IOException; import java.util.Collections; -import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.not; import static org.zalando.nakadi.domain.SubscriptionBase.InitialPosition.BEGIN; diff --git a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/HilaRebalanceAT.java b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/HilaRebalanceAT.java index d903c3ca9e..cd8d398836 100644 --- a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/HilaRebalanceAT.java +++ b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/HilaRebalanceAT.java @@ -24,8 +24,8 @@ import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toSet; import static java.util.stream.IntStream.range; -import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; import static org.zalando.nakadi.domain.SubscriptionBase.InitialPosition.BEGIN; import static org.zalando.nakadi.utils.TestUtils.waitFor; diff --git a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/HilaRepartitionAT.java b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/HilaRepartitionAT.java index febe4c85b3..4092912846 100644 --- a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/HilaRepartitionAT.java +++ b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/HilaRepartitionAT.java @@ -1,8 +1,6 @@ package org.zalando.nakadi.webservice.hila; import org.apache.curator.framework.CuratorFramework; -import org.hamcrest.MatcherAssert; -import org.hamcrest.Matchers; import org.junit.Assert; import org.junit.Test; import org.slf4j.Logger; @@ -25,6 +23,10 @@ import java.util.List; import java.util.stream.Collectors; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; + public class HilaRepartitionAT extends BaseAT { private static final Logger LOG = LoggerFactory.getLogger(HilaRepartitionAT.class); private static final CuratorFramework CURATOR = ZookeeperTestUtils.createCurator(ZOOKEEPER_URL); @@ -112,11 +114,11 @@ public void whenEventTypeRepartitionedSubscriptionStartsStreamNewPartitions() th .create(URL, subscription.getId(), "") .startWithAutocommit(streamBatches -> LOG.info("{}", streamBatches)); - TestUtils.waitFor(() -> MatcherAssert.assertThat(client.getJsonBatches(), Matchers.hasSize(1))); + TestUtils.waitFor(() -> assertThat(client.getJsonBatches(), hasSize(1))); Assert.assertEquals("0", client.getJsonBatches().get(0).getCursor().getPartition()); NakadiTestUtils.repartitionEventType(eventType, 2); - TestUtils.waitFor(() -> MatcherAssert.assertThat(client.isRunning(), Matchers.is(false))); + TestUtils.waitFor(() -> assertThat(client.isRunning(), is(false))); final TestStreamingClient clientAfterRepartitioning = TestStreamingClient .create(URL, subscription.getId(), "") @@ -125,8 +127,7 @@ public void whenEventTypeRepartitionedSubscriptionStartsStreamNewPartitions() th NakadiTestUtils.publishBusinessEventWithUserDefinedPartition( eventType.getName(), 1, x -> "{\"foo\":\"bar" + x + "\"}", p -> "1"); - TestUtils.waitFor(() -> MatcherAssert.assertThat( - clientAfterRepartitioning.getJsonBatches(), Matchers.hasSize(1))); + TestUtils.waitFor(() -> assertThat(clientAfterRepartitioning.getJsonBatches(), hasSize(1))); Assert.assertEquals("1", clientAfterRepartitioning.getJsonBatches().get(0).getCursor().getPartition()); } @@ -147,14 +148,14 @@ public void shouldRepartitionTimelinedEventType() throws Exception { .create(URL, subscription.getId(), "") .startWithAutocommit(streamBatches -> LOG.info("{}", streamBatches)); - TestUtils.waitFor(() -> MatcherAssert.assertThat(client.getJsonBatches(), Matchers.hasSize(1))); + TestUtils.waitFor(() -> assertThat(client.getJsonBatches(), hasSize(1))); Assert.assertEquals("0", client.getJsonBatches().get(0).getCursor().getPartition()); NakadiTestUtils.createTimeline(eventType.getName()); NakadiTestUtils.repartitionEventType(eventType, 2); - TestUtils.waitFor(() -> MatcherAssert.assertThat(client.isRunning(), Matchers.is(false))); + TestUtils.waitFor(() -> assertThat(client.isRunning(), is(false))); final TestStreamingClient clientAfterRepartitioning = TestStreamingClient .create(URL, subscription.getId(), "") @@ -163,8 +164,7 @@ public void shouldRepartitionTimelinedEventType() throws Exception { NakadiTestUtils.publishBusinessEventWithUserDefinedPartition( eventType.getName(), 1, x -> "{\"foo\":\"bar" + x + "\"}", p -> "1"); - TestUtils.waitFor(() -> MatcherAssert.assertThat( - clientAfterRepartitioning.getJsonBatches(), Matchers.hasSize(1))); + TestUtils.waitFor(() -> assertThat(clientAfterRepartitioning.getJsonBatches(), hasSize(1))); Assert.assertEquals("1", clientAfterRepartitioning.getJsonBatches().get(0).getCursor().getPartition()); } } diff --git a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/SubscriptionAT.java b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/SubscriptionAT.java index 0df06ba2dd..322a03e78a 100644 --- a/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/SubscriptionAT.java +++ b/acceptance-test/src/acceptance-test/java/org/zalando/nakadi/webservice/hila/SubscriptionAT.java @@ -48,12 +48,12 @@ import static java.text.MessageFormat.format; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.equalTo; 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.Matchers.nullValue; -import static org.hamcrest.core.IsEqual.equalTo; import static org.zalando.nakadi.utils.TestUtils.buildDefaultEventType; import static org.zalando.nakadi.utils.TestUtils.randomTextString; import static org.zalando.nakadi.utils.TestUtils.randomUUID; diff --git a/api-consumption/src/test/java/org/zalando/nakadi/controller/EventStreamControllerTest.java b/api-consumption/src/test/java/org/zalando/nakadi/controller/EventStreamControllerTest.java index bc1f7ee475..fb4ce631e0 100644 --- a/api-consumption/src/test/java/org/zalando/nakadi/controller/EventStreamControllerTest.java +++ b/api-consumption/src/test/java/org/zalando/nakadi/controller/EventStreamControllerTest.java @@ -3,7 +3,6 @@ import com.codahale.metrics.Counter; import com.codahale.metrics.MetricRegistry; import com.google.common.collect.ImmutableList; -import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; @@ -62,10 +61,10 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.lessThanOrEqualTo; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doNothing; @@ -175,11 +174,11 @@ public void setup() throws InvalidCursorException { @Test public void testCursorsForNulls() throws Exception { when(eventTypeCache.getEventType(TEST_EVENT_TYPE_NAME)).thenReturn(EVENT_TYPE); - MatcherAssert.assertThat( + assertThat( responseToString(createStreamingResponseBody("[{\"partition\":null,\"offset\":\"0\"}]")), JSON_TEST_HELPER.matchesObject( Problem.valueOf(PRECONDITION_FAILED, "partition must not be null"))); - MatcherAssert.assertThat( + assertThat( responseToString(createStreamingResponseBody("[{\"partition\":\"0\",\"offset\":null}]")), JSON_TEST_HELPER.matchesObject( Problem.valueOf(PRECONDITION_FAILED, "offset must not be null"))); @@ -228,7 +227,7 @@ public void whenTopicNotExistsThenTopicNotFound() throws IOException { final StreamingResponseBody responseBody = createStreamingResponseBody(); final Problem expectedProblem = Problem.valueOf(NOT_FOUND, "topic not found"); - MatcherAssert.assertThat(responseToString(responseBody), JSON_TEST_HELPER.matchesObject(expectedProblem)); + assertThat(responseToString(responseBody), JSON_TEST_HELPER.matchesObject(expectedProblem)); } @Test @@ -239,7 +238,7 @@ public void whenStreamLimitLowerThanBatchLimitThenUnprocessableEntity() throws I final Problem expectedProblem = Problem.valueOf(UNPROCESSABLE_ENTITY, "stream_limit can't be lower than batch_limit"); - MatcherAssert.assertThat(responseToString(responseBody), JSON_TEST_HELPER.matchesObject(expectedProblem)); + assertThat(responseToString(responseBody), JSON_TEST_HELPER.matchesObject(expectedProblem)); } @Test @@ -250,7 +249,7 @@ public void whenStreamTimeoutLowerThanBatchTimeoutThenUnprocessableEntity() thro final Problem expectedProblem = Problem.valueOf(UNPROCESSABLE_ENTITY, "stream_timeout can't be lower than batch_flush_timeout"); - MatcherAssert.assertThat(responseToString(responseBody), JSON_TEST_HELPER.matchesObject(expectedProblem)); + assertThat(responseToString(responseBody), JSON_TEST_HELPER.matchesObject(expectedProblem)); } @Test @@ -260,7 +259,7 @@ public void whenBatchLimitLowerThan1ThenUnprocessableEntity() throws IOException final StreamingResponseBody responseBody = createStreamingResponseBody(0, 0, 0, 0, 0, null); final Problem expectedProblem = Problem.valueOf(UNPROCESSABLE_ENTITY, "batch_limit can't be lower than 1"); - MatcherAssert.assertThat(responseToString(responseBody), JSON_TEST_HELPER.matchesObject(expectedProblem)); + assertThat(responseToString(responseBody), JSON_TEST_HELPER.matchesObject(expectedProblem)); } @Test @@ -271,7 +270,7 @@ public void whenWrongCursorsFormatThenBadRequest() throws IOException { "cursors_with_wrong_format"); final Problem expectedProblem = Problem.valueOf(BAD_REQUEST, "incorrect syntax of X-nakadi-cursors header"); - MatcherAssert.assertThat(responseToString(responseBody), JSON_TEST_HELPER.matchesObject(expectedProblem)); + assertThat(responseToString(responseBody), JSON_TEST_HELPER.matchesObject(expectedProblem)); } @Test @@ -288,7 +287,7 @@ public void whenInvalidCursorsThenPreconditionFailed() throws Exception { "offset 000000000000000000 for partition 0 event type " + TEST_EVENT_TYPE_NAME + " is unavailable as retention time of data elapsed. " + "PATCH partition offset with valid and available offset"); - MatcherAssert.assertThat(responseToString(responseBody), JSON_TEST_HELPER.matchesObject(expectedProblem)); + assertThat(responseToString(responseBody), JSON_TEST_HELPER.matchesObject(expectedProblem)); } @Test @@ -372,7 +371,7 @@ public void whenNakadiExceptionIsThrownThenServiceUnavailable() throws IOExcepti final StreamingResponseBody responseBody = createStreamingResponseBody(); final Problem expectedProblem = Problem.valueOf(SERVICE_UNAVAILABLE); - MatcherAssert.assertThat(responseToString(responseBody), JSON_TEST_HELPER.matchesObject(expectedProblem)); + assertThat(responseToString(responseBody), JSON_TEST_HELPER.matchesObject(expectedProblem)); } @Test @@ -382,7 +381,7 @@ public void whenExceptionIsThrownThenInternalServerError() throws IOException { final StreamingResponseBody responseBody = createStreamingResponseBody(); final Problem expectedProblem = Problem.valueOf(INTERNAL_SERVER_ERROR); - MatcherAssert.assertThat(responseToString(responseBody), JSON_TEST_HELPER.matchesObject(expectedProblem)); + assertThat(responseToString(responseBody), JSON_TEST_HELPER.matchesObject(expectedProblem)); } @Test @@ -461,7 +460,7 @@ public void testAccessDenied() throws Exception { final StreamingResponseBody responseBody = createStreamingResponseBody(0, 0, 0, 0, 0, null); final Problem expectedProblem = Problem.valueOf(FORBIDDEN, "Access on READ some-type:some-name denied"); - MatcherAssert.assertThat(responseToString(responseBody), JSON_TEST_HELPER.matchesObject(expectedProblem)); + assertThat(responseToString(responseBody), JSON_TEST_HELPER.matchesObject(expectedProblem)); } @Test diff --git a/api-consumption/src/test/java/org/zalando/nakadi/service/EventStreamConfigBuilderTest.java b/api-consumption/src/test/java/org/zalando/nakadi/service/EventStreamConfigBuilderTest.java index 972ee89d59..e80bef816b 100644 --- a/api-consumption/src/test/java/org/zalando/nakadi/service/EventStreamConfigBuilderTest.java +++ b/api-consumption/src/test/java/org/zalando/nakadi/service/EventStreamConfigBuilderTest.java @@ -3,10 +3,10 @@ import org.junit.Test; import org.zalando.nakadi.exceptions.runtime.InvalidLimitException; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.lessThanOrEqualTo; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; import static org.zalando.nakadi.service.EventStreamConfig.MAX_STREAM_TIMEOUT; public class EventStreamConfigBuilderTest { diff --git a/api-consumption/src/test/java/org/zalando/nakadi/service/EventStreamTest.java b/api-consumption/src/test/java/org/zalando/nakadi/service/EventStreamTest.java index 5ee74a4eba..6ad92a044b 100644 --- a/api-consumption/src/test/java/org/zalando/nakadi/service/EventStreamTest.java +++ b/api-consumption/src/test/java/org/zalando/nakadi/service/EventStreamTest.java @@ -51,7 +51,7 @@ import static junit.framework.TestCase.fail; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.arrayWithSize; -import static org.hamcrest.core.Is.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.mockito.Mockito.doThrow; diff --git a/api-consumption/src/test/java/org/zalando/nakadi/service/subscription/IdleStreamWatcherTest.java b/api-consumption/src/test/java/org/zalando/nakadi/service/subscription/IdleStreamWatcherTest.java index 3b384e4d65..3895e68307 100644 --- a/api-consumption/src/test/java/org/zalando/nakadi/service/subscription/IdleStreamWatcherTest.java +++ b/api-consumption/src/test/java/org/zalando/nakadi/service/subscription/IdleStreamWatcherTest.java @@ -3,8 +3,8 @@ import org.junit.Test; import org.zalando.nakadi.util.ThreadUtils; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; public class IdleStreamWatcherTest { diff --git a/api-consumption/src/test/java/org/zalando/nakadi/service/subscription/StreamParametersTest.java b/api-consumption/src/test/java/org/zalando/nakadi/service/subscription/StreamParametersTest.java index fae6b93374..eb77ea0a23 100644 --- a/api-consumption/src/test/java/org/zalando/nakadi/service/subscription/StreamParametersTest.java +++ b/api-consumption/src/test/java/org/zalando/nakadi/service/subscription/StreamParametersTest.java @@ -10,11 +10,11 @@ import java.util.concurrent.TimeUnit; import java.util.stream.IntStream; -import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.lessThanOrEqualTo; -import static org.hamcrest.number.OrderingComparison.greaterThanOrEqualTo; import static org.mockito.Mockito.mock; public class StreamParametersTest { diff --git a/api-consumption/src/test/java/org/zalando/nakadi/service/subscription/SubscriptionRebalancerTest.java b/api-consumption/src/test/java/org/zalando/nakadi/service/subscription/SubscriptionRebalancerTest.java index dd3dbd1a75..e7901f96a2 100644 --- a/api-consumption/src/test/java/org/zalando/nakadi/service/subscription/SubscriptionRebalancerTest.java +++ b/api-consumption/src/test/java/org/zalando/nakadi/service/subscription/SubscriptionRebalancerTest.java @@ -11,11 +11,11 @@ import java.util.stream.Stream; import static com.google.common.collect.Sets.newHashSet; +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.assertThat; import static org.junit.Assert.assertTrue; import static org.zalando.nakadi.service.subscription.model.Partition.State.ASSIGNED; import static org.zalando.nakadi.service.subscription.model.Partition.State.REASSIGNING; diff --git a/api-metastore/src/test/java/org/zalando/nakadi/controller/EventTypeControllerTest.java b/api-metastore/src/test/java/org/zalando/nakadi/controller/EventTypeControllerTest.java index 34910307d2..2a726bcda5 100644 --- a/api-metastore/src/test/java/org/zalando/nakadi/controller/EventTypeControllerTest.java +++ b/api-metastore/src/test/java/org/zalando/nakadi/controller/EventTypeControllerTest.java @@ -4,7 +4,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; -import org.hamcrest.core.StringContains; import org.json.JSONObject; import org.junit.Test; import org.mockito.ArgumentCaptor; @@ -45,8 +44,8 @@ import java.util.Optional; import java.util.concurrent.TimeoutException; -import static org.hamcrest.core.StringContains.containsString; import static org.junit.Assert.assertEquals; +import static org.hamcrest.Matchers.containsString; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Matchers.anyLong; @@ -751,7 +750,7 @@ public void whenGetOptionsRetentionTimeExist() throws Exception { getEventType(eventTypeName) .andExpect(status().is2xxSuccessful()) - .andExpect(content().string(new StringContains("\"options\":{\"retention_time\":172800000}"))); + .andExpect(content().string(containsString("\"options\":{\"retention_time\":172800000}"))); } @Test @@ -761,7 +760,7 @@ public void whenPostOptionsRetentionTimeBiggerThanMax() throws Exception { postEventType(defaultEventType) .andExpect(status().is4xxClientError()) - .andExpect(content().string(new StringContains( + .andExpect(content().string(containsString( "Field \\\"options.retention_time\\\" can not be more than 345600000"))); } @@ -772,7 +771,7 @@ public void whenPostOptionsRetentionTimeSmallerThanMin() throws Exception { postEventType(defaultEventType) .andExpect(status().is4xxClientError()) - .andExpect(content().string(new StringContains( + .andExpect(content().string(containsString( "Field \\\"options.retention_time\\\" can not be less than 10800000"))); } diff --git a/api-metastore/src/test/java/org/zalando/nakadi/service/SubscriptionTimeLagServiceTest.java b/api-metastore/src/test/java/org/zalando/nakadi/service/SubscriptionTimeLagServiceTest.java index 9f7a4bf5e9..ea31d7601f 100644 --- a/api-metastore/src/test/java/org/zalando/nakadi/service/SubscriptionTimeLagServiceTest.java +++ b/api-metastore/src/test/java/org/zalando/nakadi/service/SubscriptionTimeLagServiceTest.java @@ -16,8 +16,8 @@ import java.time.Duration; import java.util.Map; -import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; diff --git a/api-publishing/src/test/java/org/zalando/nakadi/controller/EventPublishingControllerTest.java b/api-publishing/src/test/java/org/zalando/nakadi/controller/EventPublishingControllerTest.java index a9f1a247bc..48c9e79e49 100644 --- a/api-publishing/src/test/java/org/zalando/nakadi/controller/EventPublishingControllerTest.java +++ b/api-publishing/src/test/java/org/zalando/nakadi/controller/EventPublishingControllerTest.java @@ -47,8 +47,8 @@ import java.util.List; import java.util.function.Supplier; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.springframework.http.MediaType.APPLICATION_JSON; diff --git a/app/src/test/java/org/zalando/nakadi/service/job/TimelineCleaningJobTest.java b/app/src/test/java/org/zalando/nakadi/service/job/TimelineCleaningJobTest.java index 77a52b0f81..247b1d325a 100644 --- a/app/src/test/java/org/zalando/nakadi/service/job/TimelineCleaningJobTest.java +++ b/app/src/test/java/org/zalando/nakadi/service/job/TimelineCleaningJobTest.java @@ -14,9 +14,9 @@ import java.util.Iterator; import java.util.List; -import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.isOneOf; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Matchers.anyLong; diff --git a/core-common/src/test/java/org/zalando/nakadi/domain/EventTypeTest.java b/core-common/src/test/java/org/zalando/nakadi/domain/EventTypeTest.java index 61866adbdf..da85c40cde 100644 --- a/core-common/src/test/java/org/zalando/nakadi/domain/EventTypeTest.java +++ b/core-common/src/test/java/org/zalando/nakadi/domain/EventTypeTest.java @@ -5,10 +5,9 @@ import java.util.Map; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; public class EventTypeTest { @@ -34,10 +33,10 @@ public void canDeserializeWithAnnotationsAndLabels() throws Exception { final EventType eventType = TestUtils.OBJECT_MAPPER.readValue(json, EventType.class); final Map annotations = eventType.getAnnotations(); final Map labels = eventType.getLabels(); - assertNotNull(annotations); - assertNotNull(labels); - assertEquals(2, annotations.size()); - assertEquals(2, labels.size()); + assertThat(annotations, notNullValue()); + assertThat(labels, notNullValue()); + assertThat(annotations.size(), is(2)); + assertThat(labels.size(), is(2)); } diff --git a/core-common/src/test/java/org/zalando/nakadi/domain/NakadiCursorTest.java b/core-common/src/test/java/org/zalando/nakadi/domain/NakadiCursorTest.java index 64ad482802..b9661ab2b3 100644 --- a/core-common/src/test/java/org/zalando/nakadi/domain/NakadiCursorTest.java +++ b/core-common/src/test/java/org/zalando/nakadi/domain/NakadiCursorTest.java @@ -5,8 +5,8 @@ import org.zalando.nakadi.exceptions.runtime.InvalidCursorException; import org.zalando.nakadi.utils.TestUtils; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; public class NakadiCursorTest { @@ -30,4 +30,4 @@ public void whenValidateInvalidCommitCursorsThenException() { }); } -} \ No newline at end of file +} diff --git a/core-common/src/test/java/org/zalando/nakadi/domain/VersionTest.java b/core-common/src/test/java/org/zalando/nakadi/domain/VersionTest.java index d035ea889a..dae81bf756 100644 --- a/core-common/src/test/java/org/zalando/nakadi/domain/VersionTest.java +++ b/core-common/src/test/java/org/zalando/nakadi/domain/VersionTest.java @@ -2,8 +2,8 @@ import org.junit.Test; -import static org.hamcrest.core.IsEqual.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; public class VersionTest { @Test @@ -11,4 +11,4 @@ public void bumpShouldZeroSmallerVersionNumber() throws Exception { assertThat(new Version("1.1.0").bump(Version.Level.MAJOR), equalTo(new Version("2.0.0"))); assertThat(new Version("1.1.1").bump(Version.Level.MINOR), equalTo(new Version("1.2.0"))); } -} \ No newline at end of file +} diff --git a/core-common/src/test/java/org/zalando/nakadi/repository/kafka/KafkaTopicRepositoryTest.java b/core-common/src/test/java/org/zalando/nakadi/repository/kafka/KafkaTopicRepositoryTest.java index 4a8cdd59c9..04dff26c4f 100644 --- a/core-common/src/test/java/org/zalando/nakadi/repository/kafka/KafkaTopicRepositoryTest.java +++ b/core-common/src/test/java/org/zalando/nakadi/repository/kafka/KafkaTopicRepositoryTest.java @@ -54,10 +54,10 @@ import static com.google.common.collect.Sets.newHashSet; import static java.util.Arrays.asList; import static java.util.stream.Collectors.toList; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; diff --git a/core-common/src/test/java/org/zalando/nakadi/service/subscription/zk/ZkSubscriptionNodeTest.java b/core-common/src/test/java/org/zalando/nakadi/service/subscription/zk/ZkSubscriptionNodeTest.java index 4da299035f..ca9a17ea82 100644 --- a/core-common/src/test/java/org/zalando/nakadi/service/subscription/zk/ZkSubscriptionNodeTest.java +++ b/core-common/src/test/java/org/zalando/nakadi/service/subscription/zk/ZkSubscriptionNodeTest.java @@ -9,8 +9,8 @@ import java.util.List; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; import static org.zalando.nakadi.domain.SubscriptionEventTypeStats.Partition.AssignmentType.AUTO; import static org.zalando.nakadi.domain.SubscriptionEventTypeStats.Partition.AssignmentType.DIRECT; diff --git a/core-common/src/test/java/org/zalando/nakadi/util/HashGeneratorTest.java b/core-common/src/test/java/org/zalando/nakadi/util/HashGeneratorTest.java index 8eb2b4d9fe..1557a99b2b 100644 --- a/core-common/src/test/java/org/zalando/nakadi/util/HashGeneratorTest.java +++ b/core-common/src/test/java/org/zalando/nakadi/util/HashGeneratorTest.java @@ -6,9 +6,9 @@ import org.zalando.nakadi.view.SubscriptionCursorWithoutToken; import static com.google.common.collect.Sets.newHashSet; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.not; public class HashGeneratorTest { diff --git a/core-common/src/test/java/org/zalando/nakadi/util/JsonPathAccessTest.java b/core-common/src/test/java/org/zalando/nakadi/util/JsonPathAccessTest.java index f81908a8d7..47a2b81bb8 100644 --- a/core-common/src/test/java/org/zalando/nakadi/util/JsonPathAccessTest.java +++ b/core-common/src/test/java/org/zalando/nakadi/util/JsonPathAccessTest.java @@ -7,8 +7,8 @@ import java.io.IOException; -import static org.hamcrest.core.IsEqual.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; public class JsonPathAccessTest { @@ -46,4 +46,4 @@ public void throwsExceptionIfPropertyDoesNotExist() throws JsonPathAccessExcepti } -} \ No newline at end of file +} diff --git a/core-services/src/test/java/org/zalando/nakadi/enrichment/MetadataEnrichmentStrategyTest.java b/core-services/src/test/java/org/zalando/nakadi/enrichment/MetadataEnrichmentStrategyTest.java index 5a28c63a3d..61dd088cfa 100644 --- a/core-services/src/test/java/org/zalando/nakadi/enrichment/MetadataEnrichmentStrategyTest.java +++ b/core-services/src/test/java/org/zalando/nakadi/enrichment/MetadataEnrichmentStrategyTest.java @@ -22,11 +22,11 @@ import java.util.Optional; import java.util.UUID; -import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.isEmptyString; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; import static org.mockito.Mockito.when; import static org.zalando.nakadi.utils.TestUtils.buildBusinessEvent; import static org.zalando.nakadi.utils.TestUtils.buildDefaultEventType; diff --git a/core-services/src/test/java/org/zalando/nakadi/partitioning/EventKeyExtractorTest.java b/core-services/src/test/java/org/zalando/nakadi/partitioning/EventKeyExtractorTest.java index 10ce0606f5..1855969450 100644 --- a/core-services/src/test/java/org/zalando/nakadi/partitioning/EventKeyExtractorTest.java +++ b/core-services/src/test/java/org/zalando/nakadi/partitioning/EventKeyExtractorTest.java @@ -11,7 +11,7 @@ import java.util.function.Function; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.IsEqual.equalTo; +import static org.hamcrest.Matchers.equalTo; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.zalando.nakadi.partitioning.PartitionStrategy.HASH_STRATEGY; @@ -45,4 +45,4 @@ public void whenPayloadIsMissingPartitionKeysThenItThrows() throws IOException { extractor.apply(item); } -} \ No newline at end of file +} diff --git a/core-services/src/test/java/org/zalando/nakadi/partitioning/HashPartitionStrategyCrutchTest.java b/core-services/src/test/java/org/zalando/nakadi/partitioning/HashPartitionStrategyCrutchTest.java index e88ff62cc2..c6d5224b9b 100644 --- a/core-services/src/test/java/org/zalando/nakadi/partitioning/HashPartitionStrategyCrutchTest.java +++ b/core-services/src/test/java/org/zalando/nakadi/partitioning/HashPartitionStrategyCrutchTest.java @@ -6,8 +6,8 @@ import java.util.List; -import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/core-services/src/test/java/org/zalando/nakadi/partitioning/HashPartitionStrategyTest.java b/core-services/src/test/java/org/zalando/nakadi/partitioning/HashPartitionStrategyTest.java index 72efe2557e..4348380894 100644 --- a/core-services/src/test/java/org/zalando/nakadi/partitioning/HashPartitionStrategyTest.java +++ b/core-services/src/test/java/org/zalando/nakadi/partitioning/HashPartitionStrategyTest.java @@ -31,12 +31,12 @@ import static java.util.stream.Stream.generate; import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.isIn; import static org.hamcrest.Matchers.lessThan; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; diff --git a/core-services/src/test/java/org/zalando/nakadi/partitioning/StringHashTest.java b/core-services/src/test/java/org/zalando/nakadi/partitioning/StringHashTest.java index 0e9be870b0..25a1120e5e 100644 --- a/core-services/src/test/java/org/zalando/nakadi/partitioning/StringHashTest.java +++ b/core-services/src/test/java/org/zalando/nakadi/partitioning/StringHashTest.java @@ -5,8 +5,8 @@ import java.util.Map; -import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.both; public class StringHashTest { diff --git a/core-services/src/test/java/org/zalando/nakadi/service/AuthorizationValidatorTest.java b/core-services/src/test/java/org/zalando/nakadi/service/AuthorizationValidatorTest.java index 4b21333e2b..3c155de667 100644 --- a/core-services/src/test/java/org/zalando/nakadi/service/AuthorizationValidatorTest.java +++ b/core-services/src/test/java/org/zalando/nakadi/service/AuthorizationValidatorTest.java @@ -22,8 +22,8 @@ import org.zalando.nakadi.plugin.api.exceptions.PluginException; import org.zalando.nakadi.utils.EventTypeTestBuilder; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; diff --git a/core-services/src/test/java/org/zalando/nakadi/service/CursorOperationsServiceTest.java b/core-services/src/test/java/org/zalando/nakadi/service/CursorOperationsServiceTest.java index ead5e10905..446efe74df 100644 --- a/core-services/src/test/java/org/zalando/nakadi/service/CursorOperationsServiceTest.java +++ b/core-services/src/test/java/org/zalando/nakadi/service/CursorOperationsServiceTest.java @@ -1,7 +1,7 @@ package org.zalando.nakadi.service; import com.google.common.collect.Lists; -import org.hamcrest.CoreMatchers; +import org.hamcrest.Matchers; import org.junit.Test; import org.mockito.Mockito; import org.zalando.nakadi.config.NakadiSettings; @@ -23,8 +23,8 @@ import java.util.Collections; import java.util.List; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.zalando.nakadi.exceptions.runtime.InvalidCursorOperation.Reason.CURSORS_WITH_DIFFERENT_PARTITION; @@ -43,7 +43,7 @@ public void whenCursorsAreInTheSameTimeline() throws Exception { final Long distance = service.calculateDistance(initialCursor, finalCursor); - assertThat(distance, CoreMatchers.equalTo(1L)); + assertThat(distance, Matchers.equalTo(1L)); } @Test @@ -53,7 +53,7 @@ public void whenCursorsOffsetsAreInvertedThenNegativeDistance() throws Exception final Long distance = service.calculateDistance(initialCursor, finalCursor); - assertThat(distance, CoreMatchers.equalTo(-1L)); + assertThat(distance, Matchers.equalTo(-1L)); } @Test @@ -69,7 +69,7 @@ public void whenCursorTimelinesAreInvertedThenNegativeDistance() throws Exceptio final Long distance = service.calculateDistance(finalCursor, initialCursor); - assertThat(distance, CoreMatchers.equalTo(-20L)); // Carefully calculated value + assertThat(distance, Matchers.equalTo(-20L)); // Carefully calculated value } @Test @@ -91,7 +91,7 @@ public void whenTimelinesAreAdjacent() throws Exception { final NakadiCursor finalCursor = NakadiCursor.of(finalTimeline, "0", "0000000000000001"); final Long distance = service.calculateDistance(initialCursor, finalCursor); - assertThat(distance, CoreMatchers.equalTo(9L)); + assertThat(distance, Matchers.equalTo(9L)); } @@ -106,7 +106,7 @@ public void whenTimelinesAreNotAdjacent() throws Exception { final NakadiCursor initialCursor = NakadiCursor.of(initialTimeline, "0", "0000000000000003"); final NakadiCursor finalCursor = NakadiCursor.of(finalTimeline, "0", "0000000000000001"); - assertThat(service.calculateDistance(initialCursor, finalCursor), CoreMatchers.equalTo(7L + 10L + 2L)); + assertThat(service.calculateDistance(initialCursor, finalCursor), Matchers.equalTo(7L + 10L + 2L)); } @Test(expected = InvalidCursorOperation.class) @@ -157,7 +157,7 @@ public void shiftCursorBackInTheSameTimelineClosed() { final NakadiCursor cursor = service.shiftCursor( NakadiCursor.of(initialTimeline, "0", "000000000000000003"), -3L); - assertThat(cursor.getOffset(), CoreMatchers.equalTo("000000000000000000")); + assertThat(cursor.getOffset(), Matchers.equalTo("000000000000000000")); } @Test @@ -172,8 +172,8 @@ public void shiftCursorBackToPreviousTimeline() throws Exception { final NakadiCursor cursor = service.shiftCursor(shiftedCursor, -15L); - assertThat(cursor.getTimeline().getOrder(), CoreMatchers.equalTo(0)); - assertThat(cursor.getOffset(), CoreMatchers.equalTo("000000000000000009")); + assertThat(cursor.getTimeline().getOrder(), Matchers.equalTo(0)); + assertThat(cursor.getOffset(), Matchers.equalTo("000000000000000009")); } @Test @@ -190,7 +190,7 @@ public void shiftCursorToExpiredTimeline() throws Exception { service.shiftCursor(shiftedCursor, -15L); fail(); } catch (final InvalidCursorOperation e) { - assertThat(e.getReason(), CoreMatchers.equalTo(TIMELINE_NOT_FOUND)); + assertThat(e.getReason(), Matchers.equalTo(TIMELINE_NOT_FOUND)); } catch (final Exception e) { fail(); } @@ -205,7 +205,7 @@ public void shiftCursorToTheRightSameClosedTimeline() throws Exception { final NakadiCursor cursor = service.shiftCursor(shiftedCursor, 2L); - assertThat(cursor.getOffset(), CoreMatchers.equalTo("000000000000000005")); + assertThat(cursor.getOffset(), Matchers.equalTo("000000000000000005")); } @Test @@ -218,8 +218,8 @@ public void shiftCursorRightToNextTimeline() throws Exception { final NakadiCursor cursor = service.shiftCursor(shiftedCursor, 9L); - assertThat(cursor.getTimeline().getOrder(), CoreMatchers.equalTo(2)); - assertThat(cursor.getOffset(), CoreMatchers.equalTo("000000000000000001")); + assertThat(cursor.getTimeline().getOrder(), Matchers.equalTo(2)); + assertThat(cursor.getOffset(), Matchers.equalTo("000000000000000001")); } @Test @@ -229,7 +229,7 @@ public void shiftCursorForwardInTheSameTimelineOpen() { final NakadiCursor cursor = service.shiftCursor(shiftedCursor, 3L); - assertThat(cursor.getOffset(), CoreMatchers.equalTo("000000000000000006")); + assertThat(cursor.getOffset(), Matchers.equalTo("000000000000000006")); } @Test @@ -280,7 +280,7 @@ private void expectException(final NakadiCursor initialCursor, final NakadiCurso service.calculateDistance(initialCursor, finalCursor); fail(); } catch (final InvalidCursorOperation e) { - assertThat(e.getReason(), CoreMatchers.equalTo(invertedOffsetOrder)); + assertThat(e.getReason(), Matchers.equalTo(invertedOffsetOrder)); } catch (final Throwable e) { e.printStackTrace(); fail(); diff --git a/core-services/src/test/java/org/zalando/nakadi/service/SubscriptionValidationServiceTest.java b/core-services/src/test/java/org/zalando/nakadi/service/SubscriptionValidationServiceTest.java index fb8838b19c..d27612c96f 100644 --- a/core-services/src/test/java/org/zalando/nakadi/service/SubscriptionValidationServiceTest.java +++ b/core-services/src/test/java/org/zalando/nakadi/service/SubscriptionValidationServiceTest.java @@ -34,8 +34,8 @@ import java.util.Map; import java.util.Optional; -import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.isOneOf; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; diff --git a/core-services/src/test/java/org/zalando/nakadi/service/publishing/EventPublisherTest.java b/core-services/src/test/java/org/zalando/nakadi/service/publishing/EventPublisherTest.java index 7b618d17d5..6762bc7a44 100644 --- a/core-services/src/test/java/org/zalando/nakadi/service/publishing/EventPublisherTest.java +++ b/core-services/src/test/java/org/zalando/nakadi/service/publishing/EventPublisherTest.java @@ -57,11 +57,11 @@ import java.util.UUID; import java.util.concurrent.TimeoutException; -import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.isEmptyString; import static org.hamcrest.Matchers.startsWith; -import static org.hamcrest.core.IsEqual.equalTo; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Matchers.anyBoolean; diff --git a/core-services/src/test/java/org/zalando/nakadi/service/publishing/NakadiKpiPublisherTest.java b/core-services/src/test/java/org/zalando/nakadi/service/publishing/NakadiKpiPublisherTest.java index 3594f6b6b6..66d4964a6f 100644 --- a/core-services/src/test/java/org/zalando/nakadi/service/publishing/NakadiKpiPublisherTest.java +++ b/core-services/src/test/java/org/zalando/nakadi/service/publishing/NakadiKpiPublisherTest.java @@ -25,8 +25,8 @@ import java.io.IOException; import java.util.function.Supplier; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; diff --git a/core-services/src/test/java/org/zalando/nakadi/validation/JSONSchemaValidationTest.java b/core-services/src/test/java/org/zalando/nakadi/validation/JSONSchemaValidationTest.java index c95d769637..04c851d4a5 100644 --- a/core-services/src/test/java/org/zalando/nakadi/validation/JSONSchemaValidationTest.java +++ b/core-services/src/test/java/org/zalando/nakadi/validation/JSONSchemaValidationTest.java @@ -1,6 +1,5 @@ package org.zalando.nakadi.validation; -import org.hamcrest.CoreMatchers; import org.hamcrest.Matchers; import org.json.JSONObject; import org.junit.Assert; @@ -42,7 +41,7 @@ public void validationOfBusinessEventShouldRequiredMetadata() { Assert.assertThat( error.get().getMessage(), - CoreMatchers.equalTo("#: required key [metadata] not found")); + Matchers.equalTo("#: required key [metadata] not found")); } @Test @@ -79,7 +78,7 @@ public void validationOfBusinessEventShouldAllowSpanCtxtInMetadata() { final Optional error = eventValidatorBuilder.build(et).validate(invalidEvent); Assert.assertThat(error.get().getMessage(), - CoreMatchers.equalTo("#/metadata/span_ctx/ot-tracer-spanid: expected type: String, found: Integer")); + Matchers.equalTo("#/metadata/span_ctx/ot-tracer-spanid: expected type: String, found: Integer")); } @Test @@ -95,7 +94,7 @@ public void validationOfDataChangeEventRequiresExtraFields() { Assert.assertThat( error.get().getMessage(), - CoreMatchers.equalTo("#: 3 schema violations found\n#: required key [metadata] " + + Matchers.equalTo("#: 3 schema violations found\n#: required key [metadata] " + "not found\n#: required key [data_op] not found\n#: required key [data_type] not found")); } @@ -112,7 +111,7 @@ public void validationOfDataChangeEventShouldNotAllowAdditionalFieldsAtTheRootLe Assert.assertThat( error.get().getMessage(), - CoreMatchers.equalTo("#: extraneous key [foo] is not permitted")); + Matchers.equalTo("#: extraneous key [foo] is not permitted")); } @Test @@ -128,7 +127,7 @@ public void requireMetadataEventTypeToBeTheSameAsEventTypeName() { Assert.assertThat( error.get().getMessage(), - CoreMatchers.equalTo( + Matchers.equalTo( "#/metadata/event_type: different-from-event-name is not a valid enum value")); } @@ -145,7 +144,7 @@ public void requireMetadataOccurredAt() { Assert.assertThat( error.get().getMessage(), - CoreMatchers.equalTo("#/metadata: required key [occurred_at] not found")); + Matchers.equalTo("#/metadata: required key [occurred_at] not found")); } @Test @@ -161,7 +160,7 @@ public void requireEidToBeFormattedAsUUID() { Assert.assertThat( error.get().getMessage(), - CoreMatchers.equalTo("#/metadata/eid: string [x] does not match pattern " + + Matchers.equalTo("#/metadata/eid: string [x] does not match pattern " + "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$")); } diff --git a/core-services/src/test/java/org/zalando/nakadi/validation/JsonSchemaEnrichmentTest.java b/core-services/src/test/java/org/zalando/nakadi/validation/JsonSchemaEnrichmentTest.java index 08cf027ab2..e2e4659b99 100644 --- a/core-services/src/test/java/org/zalando/nakadi/validation/JsonSchemaEnrichmentTest.java +++ b/core-services/src/test/java/org/zalando/nakadi/validation/JsonSchemaEnrichmentTest.java @@ -13,8 +13,8 @@ import java.io.IOException; import java.util.UUID; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; import static org.zalando.nakadi.utils.TestUtils.readFile; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONObjectAs; diff --git a/core-services/src/test/java/org/zalando/nakadi/validation/SchemaEvolutionServiceTest.java b/core-services/src/test/java/org/zalando/nakadi/validation/SchemaEvolutionServiceTest.java index 6dd46a5dbb..6370c397d0 100644 --- a/core-services/src/test/java/org/zalando/nakadi/validation/SchemaEvolutionServiceTest.java +++ b/core-services/src/test/java/org/zalando/nakadi/validation/SchemaEvolutionServiceTest.java @@ -34,8 +34,8 @@ import java.util.function.BiFunction; import static java.util.stream.Collectors.toList; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.zalando.nakadi.domain.SchemaChange.Type.ADDITIONAL_ITEMS_CHANGED; diff --git a/core-services/src/test/java/org/zalando/nakadi/validation/schema/CategoryChangeConstraintTest.java b/core-services/src/test/java/org/zalando/nakadi/validation/schema/CategoryChangeConstraintTest.java index 7dfab57ca8..dc834ecbde 100644 --- a/core-services/src/test/java/org/zalando/nakadi/validation/schema/CategoryChangeConstraintTest.java +++ b/core-services/src/test/java/org/zalando/nakadi/validation/schema/CategoryChangeConstraintTest.java @@ -5,7 +5,7 @@ import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.utils.EventTypeTestBuilder; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.zalando.nakadi.utils.IsOptional.isPresent; public class CategoryChangeConstraintTest { @@ -18,4 +18,4 @@ public void cannotChangeCategory() throws Exception { assertThat(constraint.validate(oldET, newET), isPresent()); } -} \ No newline at end of file +} diff --git a/core-services/src/test/java/org/zalando/nakadi/validation/schema/SchemaDiffTest.java b/core-services/src/test/java/org/zalando/nakadi/validation/schema/SchemaDiffTest.java index 4906909bb4..fcf3459d48 100644 --- a/core-services/src/test/java/org/zalando/nakadi/validation/schema/SchemaDiffTest.java +++ b/core-services/src/test/java/org/zalando/nakadi/validation/schema/SchemaDiffTest.java @@ -13,8 +13,8 @@ import java.util.List; import static java.util.stream.Collectors.toList; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.zalando.nakadi.utils.TestUtils.readFile; @@ -67,4 +67,4 @@ public void testSchemaAddsProperties() { final List changes = service.collectChanges(first, second); assertTrue(changes.isEmpty()); } -} \ No newline at end of file +}