-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
133 additions
and
56 deletions.
There are no files selected for viewing
30 changes: 0 additions & 30 deletions
30
src/test/java/com/github/imdmk/automessage/DurationUtilTest.java
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
src/test/java/com/github/imdmk/automessage/NotificationFormatterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.github.imdmk.automessage; | ||
|
||
import com.github.imdmk.automessage.notification.Notification; | ||
import com.github.imdmk.automessage.notification.NotificationFormatter; | ||
import com.github.imdmk.automessage.notification.implementation.ChatNotification; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class NotificationFormatterTest { | ||
|
||
@Test | ||
void testFormat() { | ||
ChatNotification notificationToFormat = new ChatNotification("This plugin is called {PLUGIN} and its author is {AUTHOR}."); | ||
|
||
Notification excepted = new ChatNotification("This plugin is called AutoMessage and its author is imDMK."); | ||
Notification result = new NotificationFormatter(notificationToFormat) | ||
.placeholder("{PLUGIN}", "AutoMessage") | ||
.placeholder("{AUTHOR}", "imDMK") | ||
.build(); | ||
|
||
assertEquals(excepted, result); | ||
} | ||
} |
26 changes: 0 additions & 26 deletions
26
src/test/java/com/github/imdmk/automessage/StringUtilTest.java
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
src/test/java/com/github/imdmk/automessage/util/ComponentUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.github.imdmk.automessage.util; | ||
|
||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.format.NamedTextColor; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class ComponentUtilTest { | ||
|
||
@Test | ||
void testDeserialize() { | ||
String resultContent = "<red>DMK"; | ||
|
||
Component result = ComponentUtil.deserialize(resultContent); | ||
Component excepted = Component.text("DMK").color(NamedTextColor.RED); | ||
|
||
assertEquals(excepted, result); | ||
} | ||
|
||
@Test | ||
void testLegacyDeserialize() { | ||
String resultContent = "§4DMK"; | ||
|
||
Component result = ComponentUtil.deserialize(resultContent); | ||
Component excepted = Component.text("DMK").color(NamedTextColor.DARK_RED); | ||
|
||
assertEquals(excepted, result); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/test/java/com/github/imdmk/automessage/util/DurationUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.github.imdmk.automessage.util; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.Duration; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class DurationUtilTest { | ||
|
||
@Test | ||
void testHumanReadable() { | ||
Duration ofSeconds = Duration.ofSeconds(5); | ||
String secondsExcepted = "5s"; | ||
String secondsResult = DurationUtil.toHumanReadable(ofSeconds); | ||
|
||
Duration ofMinutes = Duration.ofMinutes(5); | ||
String minutesExcepted = "5m"; | ||
String minutesResult = DurationUtil.toHumanReadable(ofMinutes); | ||
|
||
Duration ofHours = Duration.ofHours(10); | ||
String hoursExcepted = "10h"; | ||
String hoursResult = DurationUtil.toHumanReadable(ofHours); | ||
|
||
assertEquals(secondsExcepted, secondsResult); | ||
assertEquals(minutesExcepted, minutesResult); | ||
assertEquals(hoursExcepted, hoursResult); | ||
} | ||
|
||
@Test | ||
void testToTicks() { | ||
Duration ofSeconds = Duration.ofSeconds(6); | ||
long ofSecondsExcepted = 120; | ||
long ofSecondsResult = DurationUtil.toTicks(ofSeconds); | ||
|
||
Duration ofMinutes = Duration.ofMinutes(3); | ||
long ofMinutesExcepted = 3600; | ||
long ofMinutesResult = DurationUtil.toTicks(ofMinutes); | ||
|
||
assertEquals(ofSecondsExcepted, ofSecondsResult); | ||
assertEquals(ofMinutesExcepted, ofMinutesResult); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/test/java/com/github/imdmk/automessage/util/RandomUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.github.imdmk.automessage.util; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class RandomUtilTest { | ||
|
||
@Test | ||
void testRandom() { | ||
List<String> strings = List.of("DMK", "AutoMessage"); | ||
|
||
Optional<String> randomString = RandomUtil.getRandom(strings); | ||
|
||
assertTrue(randomString.isPresent()); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/test/java/com/github/imdmk/automessage/util/StringUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.github.imdmk.automessage.util; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class StringUtilTest { | ||
|
||
@Test | ||
void isIntegerTest() { | ||
String integer = "10"; | ||
boolean excepted = true; | ||
|
||
assertEquals(excepted, StringUtil.isInteger(integer)); | ||
} | ||
} |