mirror of
https://github.com/HMCore/Orbot.git
synced 2025-12-10 21:06:18 +00:00
Add more tests
This commit is contained in:
128
.idea/workspace.xml
generated
128
.idea/workspace.xml
generated
@@ -4,31 +4,14 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="1aabf22b-2f57-46ac-9973-367d8668ffd3" name="Default Changelist" comment="Bug fixes">
|
||||
<change afterPath="$PROJECT_DIR$/src/test/kotlin/org/hmcore/extensions/ColorTest.kt" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/test/kotlin/org/hmcore/extensions/EmbedTest.kt" afterDir="false" />
|
||||
<list default="true" id="1aabf22b-2f57-46ac-9973-367d8668ffd3" name="Default Changelist" comment="Refactoring, Tests">
|
||||
<change afterPath="$PROJECT_DIR$/src/test/kotlin/org/hmcore/model/BlogPostPreviewTest.kt" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/test/kotlin/org/hmcore/model/JobListingPreviewTest.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/build.gradle" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/Inaccessibles.java" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/org/hmcore/TwitterJob.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/org/hmcore/TwitterJob.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/Admin.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/Admin.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/AdminCli.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/AdminCli.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/Channels.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/Channels.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/DataIO.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/DataIO.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/DiscordRpc.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/DiscordRpc.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/ErrorHandler.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/ErrorHandler.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/Main.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/Main.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/OwnerCli.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/OwnerCli.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/extensions/Color.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/extensions/Color.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/extensions/Embed.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/extensions/Embed.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/extensions/File.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/extensions/File.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/extensions/Jsoup.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/extensions/Jsoup.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/extensions/Message.kt" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/model/BlogPostPreview.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/model/BlogPostPreview.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/model/JobListingPreview.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/model/JobListingPreview.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/web/Parser.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/web/Parser.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/web/SiteWatcher.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/web/SiteWatcher.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/webhook/WebhookCaller.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/webhook/WebhookCaller.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/extensions/Embed.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/extensions/Embed.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/model/BlogPostPreview.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/model/BlogPostPreview.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/model/JobListingPreview.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/org/hmcore/model/JobListingPreview.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/test/kotlin/org/hmcore/extensions/EmbedTest.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/kotlin/org/hmcore/extensions/EmbedTest.kt" afterDir="false" />
|
||||
</list>
|
||||
<list id="44283a45-f406-407f-bce2-a31bb9bfc0cc" name="Changes by Valentin" comment="Changes by Valentin" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@@ -54,6 +37,57 @@
|
||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
||||
<item name="HytaleUpdateBot" type="f1a62948:ProjectNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
||||
<item name="HytaleUpdateBot" type="f1a62948:ProjectNode" />
|
||||
<item name="Tasks" type="e4a08cd1:TasksNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
||||
<item name="HytaleUpdateBot" type="f1a62948:ProjectNode" />
|
||||
<item name="Tasks" type="e4a08cd1:TasksNode" />
|
||||
<item name="build" type="c8890929:TasksNode$1" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
||||
<item name="HytaleUpdateBot" type="f1a62948:ProjectNode" />
|
||||
<item name="Tasks" type="e4a08cd1:TasksNode" />
|
||||
<item name="build setup" type="c8890929:TasksNode$1" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
||||
<item name="HytaleUpdateBot" type="f1a62948:ProjectNode" />
|
||||
<item name="Tasks" type="e4a08cd1:TasksNode" />
|
||||
<item name="documentation" type="c8890929:TasksNode$1" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
||||
<item name="HytaleUpdateBot" type="f1a62948:ProjectNode" />
|
||||
<item name="Tasks" type="e4a08cd1:TasksNode" />
|
||||
<item name="help" type="c8890929:TasksNode$1" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
||||
<item name="HytaleUpdateBot" type="f1a62948:ProjectNode" />
|
||||
<item name="Tasks" type="e4a08cd1:TasksNode" />
|
||||
<item name="other" type="c8890929:TasksNode$1" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
||||
<item name="HytaleUpdateBot" type="f1a62948:ProjectNode" />
|
||||
<item name="Tasks" type="e4a08cd1:TasksNode" />
|
||||
<item name="verification" type="c8890929:TasksNode$1" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
||||
<item name="HytaleUpdateBot" type="f1a62948:ProjectNode" />
|
||||
<item name="Dependencies" type="6de06a37:ExternalSystemViewDefaultContributor$MyDependenciesNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
||||
<item name="HytaleUpdateBot" type="f1a62948:ProjectNode" />
|
||||
<item name="Run Configurations" type="7b0102dc:RunConfigurationsNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</tree_state>
|
||||
@@ -89,6 +123,14 @@
|
||||
</component>
|
||||
<component name="HighlightingSettingsPerFile">
|
||||
<setting file="file://$PROJECT_DIR$/build.gradle" root0="SKIP_INSPECTION" />
|
||||
<setting file="file://$PROJECT_DIR$/src/main/kotlin/org/hmcore/extensions/Embed.kt" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/src/main/kotlin/org/hmcore/extensions/File.kt" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/src/main/kotlin/org/hmcore/extensions/Jsoup.kt" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/src/main/kotlin/org/hmcore/model/JobListingPreview.kt" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/src/main/kotlin/org/hmcore/model/BlogPostPreview.kt" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/src/test/kotlin/org/hmcore/extensions/ColorTest.kt" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/src/main/kotlin/org/hmcore/extensions/Color.kt" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/src/test/kotlin/org/hmcore/extensions/EmbedTest.kt" root0="FORCE_HIGHLIGHTING" />
|
||||
</component>
|
||||
<component name="MacroExpansionManager">
|
||||
<option name="directoryName" value="o7p0t8es" />
|
||||
@@ -110,7 +152,7 @@
|
||||
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||
<property name="aspect.path.notification.shown" value="true" />
|
||||
<property name="codeWithMe.voiceChat.enabledByDefault" value="false" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/src/test" />
|
||||
<property name="node.js.detected.package.eslint" value="true" />
|
||||
<property name="node.js.detected.package.tslint" value="true" />
|
||||
<property name="node.js.selected.package.eslint" value="(autodetect)" />
|
||||
@@ -134,13 +176,14 @@
|
||||
<recent name="E:\Projects\Kotlin_Proj\HytaleUpdateBot\src\main\kotlin\de\wulkanat" />
|
||||
</key>
|
||||
<key name="MoveKotlinTopLevelDeclarationsDialog.RECENTS_KEY">
|
||||
<recent name="org.hmcore.model" />
|
||||
<recent name="de.wulkanat" />
|
||||
</key>
|
||||
<key name="MoveClassesOrPackagesDialog.RECENTS_KEY">
|
||||
<recent name="org" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunManager" selected="Gradle.EmbedTest">
|
||||
<component name="RunManager" selected="JUnit.All Tests">
|
||||
<configuration default="true" type="ArquillianJUnit" factoryName="" nameIsGenerated="true">
|
||||
<option name="arquillianRunConfiguration">
|
||||
<value>
|
||||
@@ -236,6 +279,16 @@
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="All Tests" type="JUnit" factoryName="JUnit">
|
||||
<module name="HytaleUpdateBot.test" />
|
||||
<option name="MAIN_CLASS_NAME" value="" />
|
||||
<option name="METHOD_NAME" value="" />
|
||||
<option name="TEST_OBJECT" value="directory" />
|
||||
<dir value="$PROJECT_DIR$/src/test" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<configuration name="Main" type="JetRunConfigurationType" temporary="true" nameIsGenerated="true">
|
||||
<option name="MAIN_CLASS_NAME" value="org.wulkanat.Main" />
|
||||
<module name="HytaleUpdateBot.main" />
|
||||
@@ -243,6 +296,14 @@
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<list>
|
||||
<item itemvalue="Gradle.ColorTest" />
|
||||
<item itemvalue="Gradle.EmbedTest" />
|
||||
<item itemvalue="Gradle.HytaleUpdateBot [build]" />
|
||||
<item itemvalue="Gradle.HytaleUpdateBot [fatJar]" />
|
||||
<item itemvalue="JUnit.All Tests" />
|
||||
<item itemvalue="Kotlin.Main" />
|
||||
</list>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Gradle.EmbedTest" />
|
||||
@@ -371,7 +432,14 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1622234477364</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="16" />
|
||||
<task id="LOCAL-00016" summary="Refactoring, Tests">
|
||||
<created>1622283383268</created>
|
||||
<option name="number" value="00016" />
|
||||
<option name="presentableId" value="LOCAL-00016" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1622283383268</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="17" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@@ -403,7 +471,8 @@
|
||||
<MESSAGE value="Update .gitignore" />
|
||||
<MESSAGE value="Bug fixes" />
|
||||
<MESSAGE value="Changes by Valentin" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Changes by Valentin" />
|
||||
<MESSAGE value="Refactoring, Tests" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Refactoring, Tests" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<watches-manager>
|
||||
@@ -412,6 +481,9 @@
|
||||
</configuration>
|
||||
</watches-manager>
|
||||
</component>
|
||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
||||
<SUITE FILE_PATH="coverage/HytaleUpdateBot$All_Tests.ic" NAME="All Tests Coverage Results" MODIFIED="1622283817250" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="idea" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" />
|
||||
</component>
|
||||
<component name="se.expertsystem.intellij.aop.aspectj.AspectJProjectComponent">
|
||||
<setting name="isActivated" value="false" />
|
||||
</component>
|
||||
|
||||
@@ -41,7 +41,7 @@ class EmbedBuilderBuilder {
|
||||
|
||||
fun title(builder: TitleBuilderBuilder.() -> Unit) =
|
||||
TitleBuilderBuilder().apply { builder() }.let {
|
||||
_embed.setTitle(it.title, it.url)
|
||||
_embed.setTitle(it.value, it.url)
|
||||
}
|
||||
|
||||
fun footer(builder: FooterBuilderBuilder.() -> Unit) =
|
||||
@@ -57,7 +57,7 @@ class FieldBuilderBuilder {
|
||||
}
|
||||
|
||||
class TitleBuilderBuilder {
|
||||
var title: String? = null
|
||||
var value: String? = null
|
||||
var url: String? = null
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ data class BlogPostPreview(
|
||||
) {
|
||||
fun toMessageEmbed() = embed {
|
||||
title {
|
||||
title = this@BlogPostPreview.title
|
||||
value = this@BlogPostPreview.title
|
||||
url = fullPostUrl
|
||||
}
|
||||
description = this@BlogPostPreview.description
|
||||
|
||||
@@ -2,8 +2,7 @@ package org.hmcore.model
|
||||
|
||||
import org.hmcore.extensions.hex2Rgb
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.dv8tion.jda.api.EmbedBuilder
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed
|
||||
import org.hmcore.extensions.embed
|
||||
|
||||
@Serializable
|
||||
data class JobListingPreview(
|
||||
@@ -12,12 +11,16 @@ data class JobListingPreview(
|
||||
val location: String,
|
||||
val fullListingUrl: String
|
||||
) {
|
||||
fun toMessageEmbed(): MessageEmbed {
|
||||
return EmbedBuilder()
|
||||
.setTitle(this.title, this.fullListingUrl)
|
||||
.setDescription(this.department)
|
||||
.setAuthor(this.location)
|
||||
.setColor(hex2Rgb("#337fb0"))
|
||||
.build()
|
||||
fun toMessageEmbed() = embed {
|
||||
title {
|
||||
value = this@JobListingPreview.title
|
||||
url = fullListingUrl
|
||||
}
|
||||
|
||||
description = department
|
||||
color = hex2Rgb("#337fb0")
|
||||
author {
|
||||
name = location
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ class EmbedTest {
|
||||
fun `Embed Title DSL should work`() {
|
||||
val dslEmbed = embed {
|
||||
title {
|
||||
title = "Title"
|
||||
value = "Title"
|
||||
url = "https://a.b.c"
|
||||
}
|
||||
}
|
||||
|
||||
34
src/test/kotlin/org/hmcore/model/BlogPostPreviewTest.kt
Normal file
34
src/test/kotlin/org/hmcore/model/BlogPostPreviewTest.kt
Normal file
@@ -0,0 +1,34 @@
|
||||
package org.hmcore.model
|
||||
|
||||
import org.hmcore.extensions.hex2Rgb
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNotNull
|
||||
|
||||
class BlogPostPreviewTest {
|
||||
@Test
|
||||
fun `Blog post should be correctly parsed to Embed`() {
|
||||
val embed = BlogPostPreview(
|
||||
title = "Title",
|
||||
description = "Description",
|
||||
date = "01.01.2000",
|
||||
author = "Nobody",
|
||||
imgUrl = "https://a.b.c",
|
||||
fullPostUrl = "https://d.e.f"
|
||||
).toMessageEmbed()
|
||||
|
||||
assertEquals("Title", embed.title)
|
||||
assertEquals("https://d.e.f", embed.url)
|
||||
assertEquals("Description", embed.description)
|
||||
assertEquals(hex2Rgb("#337FB0"), embed.color)
|
||||
assertNotNull(embed.thumbnail)
|
||||
assertEquals("https://a.b.c", embed.thumbnail!!.url)
|
||||
|
||||
assertNotNull(embed.footer)
|
||||
assertEquals("01.01.2000", embed.footer!!.text)
|
||||
assertEquals("https://www.hytale.com/static/images/logo-h.png", embed.footer!!.iconUrl)
|
||||
|
||||
assertNotNull(embed.author)
|
||||
assertEquals(embed.author!!.name, "Nobody")
|
||||
}
|
||||
}
|
||||
26
src/test/kotlin/org/hmcore/model/JobListingPreviewTest.kt
Normal file
26
src/test/kotlin/org/hmcore/model/JobListingPreviewTest.kt
Normal file
@@ -0,0 +1,26 @@
|
||||
package org.hmcore.model
|
||||
|
||||
import org.hmcore.extensions.hex2Rgb
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNotNull
|
||||
|
||||
class JobListingPreviewTest {
|
||||
@Test
|
||||
fun `Job listings should be correctly parsed to Embed`() {
|
||||
val embed = JobListingPreview(
|
||||
title = "Title",
|
||||
department = "Department",
|
||||
location = "Null Island",
|
||||
fullListingUrl = "https://d.e.f"
|
||||
).toMessageEmbed()
|
||||
|
||||
assertEquals("Title", embed.title)
|
||||
assertEquals("https://d.e.f", embed.url)
|
||||
assertEquals("Department", embed.description)
|
||||
assertEquals(hex2Rgb("#337FB0"), embed.color)
|
||||
|
||||
assertNotNull(embed.author)
|
||||
assertEquals(embed.author!!.name, "Null Island")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user