mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
add tests for the new insertedBefore mechanic
This commit is contained in:
@@ -101,7 +101,7 @@ public abstract class BaseIT {
|
|||||||
protected Entries getFeedEntries(long subscriptionId) {
|
protected Entries getFeedEntries(long subscriptionId) {
|
||||||
Response response = client.target(apiBaseUrl + "feed/entries")
|
Response response = client.target(apiBaseUrl + "feed/entries")
|
||||||
.queryParam("id", subscriptionId)
|
.queryParam("id", subscriptionId)
|
||||||
.queryParam("readType", "unread")
|
.queryParam("readType", "all")
|
||||||
.request()
|
.request()
|
||||||
.get();
|
.get();
|
||||||
return response.readEntity(Entries.class);
|
return response.readEntity(Entries.class);
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ package com.commafeed.integration.rest;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
@@ -17,7 +19,6 @@ import org.junit.jupiter.api.Assertions;
|
|||||||
import org.junit.jupiter.api.Nested;
|
import org.junit.jupiter.api.Nested;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import com.commafeed.frontend.model.Entries;
|
|
||||||
import com.commafeed.frontend.model.Entry;
|
import com.commafeed.frontend.model.Entry;
|
||||||
import com.commafeed.frontend.model.FeedInfo;
|
import com.commafeed.frontend.model.FeedInfo;
|
||||||
import com.commafeed.frontend.model.Subscription;
|
import com.commafeed.frontend.model.Subscription;
|
||||||
@@ -89,22 +90,43 @@ class FeedIT extends BaseIT {
|
|||||||
@Nested
|
@Nested
|
||||||
class Mark {
|
class Mark {
|
||||||
@Test
|
@Test
|
||||||
void mark() {
|
void markWithoutDates() {
|
||||||
long subscriptionId = subscribe(getFeedUrl());
|
long subscriptionId = subscribeAndWaitForEntries(getFeedUrl());
|
||||||
Entries entries = Awaitility.await()
|
markFeedEntries(subscriptionId, null, null);
|
||||||
.atMost(Duration.ofSeconds(15))
|
Assertions.assertTrue(getFeedEntries(subscriptionId).getEntries().stream().allMatch(Entry::isRead));
|
||||||
.until(() -> getFeedEntries(subscriptionId), e -> e.getEntries().size() == 2);
|
|
||||||
Assertions.assertTrue(entries.getEntries().stream().noneMatch(Entry::isRead));
|
|
||||||
|
|
||||||
markFeedEntries(subscriptionId);
|
|
||||||
Awaitility.await()
|
|
||||||
.atMost(Duration.ofSeconds(15))
|
|
||||||
.until(() -> getFeedEntries(subscriptionId), e -> e.getEntries().stream().allMatch(Entry::isRead));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void markFeedEntries(long subscriptionId) {
|
@Test
|
||||||
|
void markOlderThan() {
|
||||||
|
long subscriptionId = subscribeAndWaitForEntries(getFeedUrl());
|
||||||
|
markFeedEntries(subscriptionId, new GregorianCalendar(2023, Calendar.DECEMBER, 28).getTime(), null);
|
||||||
|
Assertions.assertEquals(1, getFeedEntries(subscriptionId).getEntries().stream().filter(Entry::isRead).count());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void markInsertedBeforeBeforeSubscription() {
|
||||||
|
Date insertedBefore = new Date();
|
||||||
|
|
||||||
|
long subscriptionId = subscribeAndWaitForEntries(getFeedUrl());
|
||||||
|
markFeedEntries(subscriptionId, null, insertedBefore);
|
||||||
|
Assertions.assertTrue(getFeedEntries(subscriptionId).getEntries().stream().noneMatch(Entry::isRead));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void markInsertedBeforeAfterSubscription() {
|
||||||
|
long subscriptionId = subscribeAndWaitForEntries(getFeedUrl());
|
||||||
|
|
||||||
|
Date insertedBefore = new Date();
|
||||||
|
|
||||||
|
markFeedEntries(subscriptionId, null, insertedBefore);
|
||||||
|
Assertions.assertTrue(getFeedEntries(subscriptionId).getEntries().stream().allMatch(Entry::isRead));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void markFeedEntries(long subscriptionId, Date olderThan, Date insertedBefore) {
|
||||||
MarkRequest request = new MarkRequest();
|
MarkRequest request = new MarkRequest();
|
||||||
request.setId(String.valueOf(subscriptionId));
|
request.setId(String.valueOf(subscriptionId));
|
||||||
|
request.setOlderThan(olderThan == null ? null : olderThan.getTime());
|
||||||
|
request.setInsertedBefore(insertedBefore == null ? null : insertedBefore.getTime());
|
||||||
getClient().target(getApiBaseUrl() + "feed/mark").request().post(Entity.json(request), Void.TYPE);
|
getClient().target(getApiBaseUrl() + "feed/mark").request().post(Entity.json(request), Void.TYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,15 +4,17 @@
|
|||||||
<title>CommaFeed test feed</title>
|
<title>CommaFeed test feed</title>
|
||||||
<link>https://hostname.local/commafeed</link>
|
<link>https://hostname.local/commafeed</link>
|
||||||
<description>CommaFeed test feed description</description>
|
<description>CommaFeed test feed description</description>
|
||||||
<item>
|
|
||||||
<title>Item 1</title>
|
|
||||||
<link>https://hostname.local/commafeed/1</link>
|
|
||||||
<description>Item 1 description</description>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<title>Item 2</title>
|
<title>Item 2</title>
|
||||||
<link>https://hostname.local/commafeed/2</link>
|
<link>https://hostname.local/commafeed/2</link>
|
||||||
<description>Item 2 description</description>
|
<description>Item 2 description</description>
|
||||||
|
<pubDate>Fri, 29 Dec 2023 15:02:00 +0100</pubDate>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<title>Item 1</title>
|
||||||
|
<link>https://hostname.local/commafeed/1</link>
|
||||||
|
<description>Item 1 description</description>
|
||||||
|
<pubDate>Wed, 27 Dec 2023 22:24:00 +0100</pubDate>
|
||||||
</item>
|
</item>
|
||||||
</channel>
|
</channel>
|
||||||
</rss>
|
</rss>
|
||||||
Reference in New Issue
Block a user