websocket notification now takes entry filtering into account (#1191)

This commit is contained in:
Athou
2024-01-24 12:49:20 +01:00
parent 9354fb8e18
commit c624955ea4
6 changed files with 136 additions and 36 deletions

View File

@@ -38,6 +38,8 @@ import lombok.Getter;
@ExtendWith(MockServerExtension.class)
public abstract class BaseIT {
private static final HttpRequest FEED_REQUEST = HttpRequest.request().withMethod("GET").withPath("/");
private final CommaFeedDropwizardAppExtension extension = buildExtension();
private Client client;
@@ -50,6 +52,8 @@ public abstract class BaseIT {
private String webSocketUrl;
private MockServerClient mockServerClient;
protected CommaFeedDropwizardAppExtension buildExtension() {
return new CommaFeedDropwizardAppExtension() {
@Override
@@ -61,9 +65,10 @@ public abstract class BaseIT {
@BeforeEach
void init(MockServerClient mockServerClient) throws IOException {
this.mockServerClient = mockServerClient;
URL resource = Objects.requireNonNull(getClass().getResource("/feed/rss.xml"));
mockServerClient.when(HttpRequest.request().withMethod("GET").withPath("/"))
.respond(HttpResponse.response().withBody(IOUtils.toString(resource, StandardCharsets.UTF_8)));
mockServerClient.when(FEED_REQUEST).respond(HttpResponse.response().withBody(IOUtils.toString(resource, StandardCharsets.UTF_8)));
this.client = extension.client();
this.feedUrl = "http://localhost:" + mockServerClient.getPort() + "/";
@@ -77,6 +82,13 @@ public abstract class BaseIT {
this.client.close();
}
protected void feedNowReturnsMoreEntries() throws IOException {
mockServerClient.clear(FEED_REQUEST);
URL resource = Objects.requireNonNull(getClass().getResource("/feed/rss_2.xml"));
mockServerClient.when(FEED_REQUEST).respond(HttpResponse.response().withBody(IOUtils.toString(resource, StandardCharsets.UTF_8)));
}
protected String login() {
LoginRequest req = new LoginRequest();
req.setName("admin");
@@ -112,4 +124,8 @@ public abstract class BaseIT {
.get();
return response.readEntity(Entries.class);
}
protected void forceRefreshAllFeeds() {
client.target(apiBaseUrl + "feed/refreshAll").request().get(Void.class);
}
}