#5 Fixed incorrect setting of URL and URL Title
This commit is contained in:
@ -20,4 +20,4 @@ public class JPushoverTest {
|
||||
public void testNewMessage() {
|
||||
assertTrue(JPushover.newMessage() instanceof Message);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,8 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.post;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@ -13,6 +15,9 @@ import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import de.svenkubiak.jpushover.JPushover;
|
||||
import de.svenkubiak.jpushover.apis.Message;
|
||||
import de.svenkubiak.jpushover.enums.Priority;
|
||||
import de.svenkubiak.jpushover.enums.Sound;
|
||||
import de.svenkubiak.jpushover.http.PushoverResponse;
|
||||
import jpushover.MockServer;
|
||||
|
||||
@ -86,4 +91,69 @@ public class MessageTest {
|
||||
PushoverResponse response = JPushover.newMessage().withToken("foo").withUser("bla").withMessage("foobar").push();
|
||||
assertTrue(response.isSuccessful());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstruct() throws IOException, InterruptedException {
|
||||
//given
|
||||
String callback = "callback";
|
||||
String device = "device";
|
||||
String expire = "expire";
|
||||
String message = "message";
|
||||
String retry = "retry";
|
||||
String user = "user";
|
||||
String urlTitle = "urlTitle";
|
||||
String timestamp = "timestamp";
|
||||
String proxyHost = "proxyhost";
|
||||
String title = "tile";
|
||||
String token = "token";
|
||||
String url = "https://www.url.url";
|
||||
int proxyPort = 8080;
|
||||
Priority priority = Priority.HIGH;
|
||||
Sound sound = Sound.BUGLE;
|
||||
|
||||
//when
|
||||
Message m = JPushover.newMessage()
|
||||
.enableHtml()
|
||||
.withCallback(callback)
|
||||
.withDevice(device)
|
||||
.withExpire(expire)
|
||||
.withMessage(message)
|
||||
.withPriority(priority)
|
||||
.withProxy(proxyHost, proxyPort)
|
||||
.withRetry(retry)
|
||||
.withSound(sound)
|
||||
.withTimestamp(timestamp)
|
||||
.withTitle(title)
|
||||
.withToken(token)
|
||||
.withUrl(url)
|
||||
.withUser(user);
|
||||
|
||||
//then
|
||||
assertThat(m.isHtml(), equalTo(true));
|
||||
assertThat(m.isMonospace(), equalTo(false));
|
||||
assertThat(m.getCallback(), equalTo(callback));
|
||||
assertThat(m.getDevice(), equalTo(device));
|
||||
assertThat(m.getExpire(), equalTo(expire));
|
||||
assertThat(m.getMessage(), equalTo(message));
|
||||
assertThat(m.getPriority(), equalTo(Priority.HIGH));
|
||||
assertThat(m.getProxyHost(), equalTo(proxyHost));
|
||||
assertThat(m.getProxyPort(), equalTo(proxyPort));
|
||||
assertThat(m.getRetry(), equalTo(retry));
|
||||
assertThat(m.getSound(), equalTo(Sound.BUGLE));
|
||||
assertThat(m.getTimestamp(), equalTo(timestamp));
|
||||
assertThat(m.getTitle(), equalTo(title));
|
||||
assertThat(m.getToken(), equalTo(token));
|
||||
assertThat(m.getUrl(), equalTo(url));
|
||||
assertThat(m.getUrlTitle(), equalTo(url));
|
||||
assertThat(m.getUser(), equalTo(user));
|
||||
|
||||
//when
|
||||
m.withUrlTitle(urlTitle);
|
||||
m.enableMonospace();
|
||||
|
||||
//then
|
||||
assertThat(m.getUrlTitle(), equalTo(urlTitle));
|
||||
assertThat(m.isHtml(), equalTo(false));
|
||||
assertThat(m.isMonospace(), equalTo(true));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user