Minor refactorings

This commit is contained in:
Sven Kubiak 2023-07-13 12:03:11 +02:00
parent 0cbcf27da7
commit f9ca3b8890
No known key found for this signature in database
3 changed files with 17 additions and 3 deletions

View File

@ -202,7 +202,7 @@
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId> <artifactId>junit-jupiter-engine</artifactId>
<version>5.10.0-M1</version> <version>5.10.0-RC1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -225,13 +225,15 @@ public class Message implements API {
} }
/** /**
* Adds a ttl to the Pushover message
* *
* @param ttl Seconds until this message should be automatically removed from the device. Needs to be positive * @param ttl Seconds until this message should be automatically removed from the device. Needs to be positive
* @see https://pushover.net/api#ttl
* @return Message instance * @return Message instance
*/ */
public Message withTTL(int ttl) { public Message withTTL(int ttl) {
body.put(Param.TTL.toString(), Integer.toString(ttl)); Validate.checkArgument(ttl > 0, "TTL must be a positive value");
body.put(Param.TTL.toString(), String.valueOf(ttl));
return this; return this;
} }

View File

@ -58,6 +58,18 @@ public class MessageTests {
assertTrue(message.getValue(Param.USER.toString()).equals(value)); assertTrue(message.getValue(Param.USER.toString()).equals(value));
} }
@Test
void testWithTTL() {
//given
int ttl = 5;
//when
Message message = JPushover.messageAPI().withTTL(5);
//then
assertTrue(message.getValue(Param.TTL.toString()).equals(String.valueOf(ttl)));
}
@Test @Test
void testWithRetry() { void testWithRetry() {
//given //given