From: David ‘Bombe’ Roden Date: Tue, 30 Jul 2019 20:25:55 +0000 (+0200) Subject: 🎨 Update current edition of rescuer after fetch X-Git-Tag: v81^2~148 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=5896b708bc8ca0b4e3b8f240875b1fa0930a895e;p=Sone.git 🎨 Update current edition of rescuer after fetch --- diff --git a/src/main/java/net/pterodactylus/sone/core/SoneRescuer.java b/src/main/java/net/pterodactylus/sone/core/SoneRescuer.java index 93c77c2..adc0925 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneRescuer.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneRescuer.java @@ -108,17 +108,6 @@ public class SoneRescuer extends AbstractService { } /** - * Sets the edition to rescue. - * - * @param edition - * The edition to rescue - * @return This Sone rescuer - */ - public void setEdition(long edition) { - currentEdition = edition; - } - - /** * Sets whether the last fetch was successful. * * @return {@code true} if the last fetch was successful, {@code false} @@ -134,9 +123,7 @@ public class SoneRescuer extends AbstractService { // /** - * Starts the next fetch. If you want to fetch a different edition than “the - * next older one,” remember to call {@link #setEdition(long)} before - * calling this method. + * Starts the next fetch. */ public void startNextFetch() { fetching = true; @@ -165,6 +152,7 @@ public class SoneRescuer extends AbstractService { lastFetchSuccessful = (fetchedSone != null); if (lastFetchSuccessful) { core.updateSone(fetchedSone, true); + currentEdition = getNextEdition(); } fetching = false; } diff --git a/src/test/kotlin/net/pterodactylus/sone/core/SoneRescuerTest.kt b/src/test/kotlin/net/pterodactylus/sone/core/SoneRescuerTest.kt index 68e08e3..a74b874 100644 --- a/src/test/kotlin/net/pterodactylus/sone/core/SoneRescuerTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/core/SoneRescuerTest.kt @@ -74,6 +74,7 @@ class SoneRescuerTest { verify(core).updateSone(eq(fetchedSone), eq(true)) assertThat(soneRescuer.isLastFetchSuccessful, equalTo(true)) assertThat(soneRescuer.isFetching, equalTo(false)) + assertThat(soneRescuer.currentEdition, equalTo(currentEdition - 1)) } @Test @@ -85,6 +86,7 @@ class SoneRescuerTest { verify(core, never()).updateSone(any(Sone::class.java), eq(true)) assertThat(soneRescuer.isLastFetchSuccessful, equalTo(false)) assertThat(soneRescuer.isFetching, equalTo(false)) + assertThat(soneRescuer.currentEdition, equalTo(currentEdition)) } private fun returnUriOnInsert(fetchedSone: Sone?) {