Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
Big cleanup of Hamcrest imports (#1563)
Browse files Browse the repository at this point in the history
It got messy over the time, mainly due to auto-import suggestions from IDEs.
  • Loading branch information
a1exsh authored and 1u0 committed Dec 7, 2023
1 parent 17d932e commit 2a77a31
Show file tree
Hide file tree
Showing 44 changed files with 174 additions and 173 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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<StreamBatch> batches = client.getJsonBatches();

// validate the content of events
Expand All @@ -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);
Expand Down Expand Up @@ -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<StreamBatch> batches = client.getJsonBatches();

// validate the events metadata
Expand Down
Loading

0 comments on commit 2a77a31

Please sign in to comment.