From 5896b708bc8ca0b4e3b8f240875b1fa0930a895e Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 30 Jul 2019 22:25:55 +0200 Subject: [PATCH] =?utf8?q?=F0=9F=8E=A8=20Update=20current=20edition=20of?= =?utf8?q?=20rescuer=20after=20fetch?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../java/net/pterodactylus/sone/core/SoneRescuer.java | 16 ++-------------- .../net/pterodactylus/sone/core/SoneRescuerTest.kt | 2 ++ 2 files changed, 4 insertions(+), 14 deletions(-) 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?) { -- 2.7.4