--- /dev/null
+package net.pterodactylus.rhynodge.engine
+
+import com.google.inject.AbstractModule
+import com.google.inject.Provides
+import jakarta.inject.Named
+import net.pterodactylus.rhynodge.Action
+import net.pterodactylus.rhynodge.actions.EmailAction
+import net.pterodactylus.rhynodge.loader.ChainWatcher
+import net.pterodactylus.rhynodge.states.StateManager
+
+class RhynodgeModule : AbstractModule() {
+
+ @Provides
+ @Named("email")
+ fun getEmailAction(options: Options): Action =
+ EmailAction(options.smtpHostname, options.emailSender, options.emailRecipient)
+
+ @Provides
+ @Named("errorEmail")
+ fun getErrorEmailAction(options: Options): Action =
+ EmailAction(options.smtpHostname, options.errorEmailSender, options.errorEmailRecipient)
+
+ @Provides
+ fun getChainDirectory(options: Options): ChainWatcher.ChainDirectory =
+ ChainWatcher.ChainDirectory.of(options.chainDirectory)
+
+ @Provides
+ fun getStateDirectory(options: Options): StateManager.StateDirectory =
+ StateManager.StateDirectory.of(options.stateDirectory)
+
+}
--- /dev/null
+package net.pterodactylus.rhynodge.engine
+
+import com.google.inject.Guice.createInjector
+import net.pterodactylus.rhynodge.loader.ChainWatcher
+import net.pterodactylus.rhynodge.loader.ReactionLoader
+import net.pterodactylus.rhynodge.utils.toOptional
+import net.pterodactylus.util.envopt.Parser
+import net.pterodactylus.util.inject.ObjectBinding
+import org.junit.jupiter.api.Test
+
+class RhynodgeModuleTest {
+
+ @Test
+ fun `can create rhynodge module`() {
+ RhynodgeModule()
+ }
+
+ @Test
+ fun `chain watcher can be created`() {
+ injector.getInstance(ChainWatcher::class.java)
+ }
+
+ @Test
+ fun `reaction loader can be created`() {
+ injector.getInstance(ReactionLoader::class.java)
+ }
+
+ @Test
+ fun `engine can be created`() {
+ injector.getInstance(Engine::class.java)
+ }
+
+ private val injector = createInjector(
+ ObjectBinding.forClass(Options::class.java).shallBe(supplyOptions()),
+ RhynodgeModule()
+ )
+
+}
+
+private fun supplyOptions(): Options {
+ val environment = mapOf(
+ "SMTP_HOSTNAME" to "host.local",
+ "EMAIL_SENDER" to "send@r",
+ "EMAIL_RECIPIENT" to "recipi@nt",
+ "ERROR_EMAIL_SENDER" to "error-send@r",
+ "ERROR_EMAIL_RECIPIENT" to "error-recipient@nt",
+ )
+ return Parser { environment[it].toOptional() }
+ .parseEnvironment(::Options)
+}