projects
/
Sone.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
f4ac492
)
Add test for DI constructability of SoneDownloader
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Thu, 1 Feb 2018 17:55:43 +0000
(18:55 +0100)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Thu, 1 Feb 2018 19:33:43 +0000
(20:33 +0100)
src/main/java/net/pterodactylus/sone/core/SoneDownloader.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java
patch
|
blob
|
history
src/test/java/net/pterodactylus/sone/core/SoneDownloaderTest.java
patch
|
blob
|
history
src/test/java/net/pterodactylus/sone/web/AllPagesTest.kt
patch
|
blob
|
history
diff --git
a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java
b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java
index
be0be02
..
039faad
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/core/SoneDownloader.java
+++ b/
src/main/java/net/pterodactylus/sone/core/SoneDownloader.java
@@
-5,12
+5,15
@@
import net.pterodactylus.util.service.Service;
import freenet.keys.FreenetURI;
import freenet.keys.FreenetURI;
+import com.google.inject.ImplementedBy;
+
/**
* Downloads and parses Sone and {@link Core#updateSone(Sone) updates the
* core}.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
/**
* Downloads and parses Sone and {@link Core#updateSone(Sone) updates the
* core}.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
+@ImplementedBy(SoneDownloaderImpl.class)
public interface SoneDownloader extends Service {
void addSone(Sone sone);
public interface SoneDownloader extends Service {
void addSone(Sone sone);
diff --git
a/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java
b/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java
index
a859106
..
d3f23ed
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java
+++ b/
src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java
@@
-29,6
+29,8
@@
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.inject.Inject;
+
import net.pterodactylus.sone.core.FreenetInterface.Fetched;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.data.Sone.SoneStatus;
import net.pterodactylus.sone.core.FreenetInterface.Fetched;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.data.Sone.SoneStatus;
@@
-75,6
+77,7
@@
public class SoneDownloaderImpl extends AbstractService implements SoneDownloade
* @param freenetInterface
* The Freenet interface
*/
* @param freenetInterface
* The Freenet interface
*/
+ @Inject
public SoneDownloaderImpl(Core core, FreenetInterface freenetInterface) {
this(core, freenetInterface, new SoneParser(core));
}
public SoneDownloaderImpl(Core core, FreenetInterface freenetInterface) {
this(core, freenetInterface, new SoneParser(core));
}
diff --git
a/src/test/java/net/pterodactylus/sone/core/SoneDownloaderTest.java
b/src/test/java/net/pterodactylus/sone/core/SoneDownloaderTest.java
index
9043974
..
be697b3
100644
(file)
--- a/
src/test/java/net/pterodactylus/sone/core/SoneDownloaderTest.java
+++ b/
src/test/java/net/pterodactylus/sone/core/SoneDownloaderTest.java
@@
-6,8
+6,10
@@
import static java.util.concurrent.TimeUnit.DAYS;
import static net.pterodactylus.sone.data.Sone.SoneStatus.downloading;
import static net.pterodactylus.sone.data.Sone.SoneStatus.idle;
import static net.pterodactylus.sone.data.Sone.SoneStatus.unknown;
import static net.pterodactylus.sone.data.Sone.SoneStatus.downloading;
import static net.pterodactylus.sone.data.Sone.SoneStatus.idle;
import static net.pterodactylus.sone.data.Sone.SoneStatus.unknown;
+import static net.pterodactylus.sone.web.AllPagesTestKt.getBaseInjector;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
import static org.mockito.ArgumentCaptor.forClass;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentCaptor.forClass;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
@@
-193,4
+195,9
@@
public class SoneDownloaderTest {
return new Fetched(uri, fetchResult);
}
return new Fetched(uri, fetchResult);
}
+ @Test
+ public void soneDownloaderCanBeCreatedByDependencyInjection() {
+ assertThat(getBaseInjector().getInstance(SoneDownloader.class), notNullValue());
+ }
+
}
}
diff --git
a/src/test/java/net/pterodactylus/sone/web/AllPagesTest.kt
b/src/test/java/net/pterodactylus/sone/web/AllPagesTest.kt
index
da05926
..
9e395f2
100644
(file)
--- a/
src/test/java/net/pterodactylus/sone/web/AllPagesTest.kt
+++ b/
src/test/java/net/pterodactylus/sone/web/AllPagesTest.kt
@@
-1,6
+1,8
@@
package net.pterodactylus.sone.web
import com.google.inject.Guice.createInjector
package net.pterodactylus.sone.web
import com.google.inject.Guice.createInjector
+import net.pterodactylus.sone.core.Core
+import net.pterodactylus.sone.core.FreenetInterface
import net.pterodactylus.sone.main.SonePlugin.PluginHomepage
import net.pterodactylus.sone.main.SonePlugin.PluginVersion
import net.pterodactylus.sone.main.SonePlugin.PluginYear
import net.pterodactylus.sone.main.SonePlugin.PluginHomepage
import net.pterodactylus.sone.main.SonePlugin.PluginVersion
import net.pterodactylus.sone.main.SonePlugin.PluginYear
@@
-34,6
+36,8
@@
class AllPagesTest {
val baseInjector by lazy {
createInjector(
val baseInjector by lazy {
createInjector(
+ Core::class.isProvidedByMock(),
+ FreenetInterface::class.isProvidedByMock(),
Template::class.isProvidedByMock(),
WebInterface::class.isProvidedByMock()
)!!
Template::class.isProvidedByMock(),
WebInterface::class.isProvidedByMock()
)!!