2015-01-26 11:52:50 +01:00
|
|
|
package de.svenkubiak.jpushover;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
2015-12-10 11:22:15 +01:00
|
|
|
import static org.junit.Assert.assertTrue;
|
2015-01-26 11:52:50 +01:00
|
|
|
|
2018-08-16 15:32:26 +08:00
|
|
|
import org.apache.http.HttpHost;
|
2015-01-26 11:52:50 +01:00
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import de.svenkubiak.jpushover.enums.Priority;
|
|
|
|
import de.svenkubiak.jpushover.enums.Sound;
|
|
|
|
|
|
|
|
public class TestJPushover {
|
|
|
|
private static final String USER = "user";
|
|
|
|
private static final String URL_TITLE = "urlTitle";
|
|
|
|
private static final String URL = "url";
|
|
|
|
private static final String TOKEN = "token";
|
|
|
|
private static final String TITLE = "title";
|
|
|
|
private static final String TIMESTAMP = "timestamp";
|
|
|
|
private static final String RETRY = "retry";
|
|
|
|
private static final String MESSAGE = "message";
|
|
|
|
private static final String EXPIRE = "expire";
|
|
|
|
private static final String DEVICE = "device";
|
|
|
|
private static final String CALLBACK = "callback";
|
2018-08-16 15:32:26 +08:00
|
|
|
private static final HttpHost PROXY = new HttpHost("localhost");
|
2015-12-08 22:03:44 +01:00
|
|
|
|
2015-01-26 11:52:50 +01:00
|
|
|
@Test
|
|
|
|
public void TestValues(){
|
2015-12-08 22:03:44 +01:00
|
|
|
final JPushover push = new JPushover();
|
|
|
|
|
2016-10-20 08:35:08 +02:00
|
|
|
push.withCallback(CALLBACK);
|
2015-01-26 11:52:50 +01:00
|
|
|
assertEquals(push.getCallback(), CALLBACK);
|
2015-12-08 22:03:44 +01:00
|
|
|
|
2016-10-20 08:35:08 +02:00
|
|
|
push.withDevice(DEVICE);
|
2015-01-26 11:52:50 +01:00
|
|
|
assertEquals(push.getDevice(), DEVICE);
|
2015-12-08 22:03:44 +01:00
|
|
|
|
2016-10-20 08:35:08 +02:00
|
|
|
push.withExpire(EXPIRE);
|
2015-01-26 11:52:50 +01:00
|
|
|
assertEquals(push.getExpire(), EXPIRE);
|
2015-12-08 22:03:44 +01:00
|
|
|
|
2016-10-20 08:35:08 +02:00
|
|
|
push.withMessage(MESSAGE);
|
2015-01-26 11:52:50 +01:00
|
|
|
assertEquals(push.getMessage(), MESSAGE);
|
2015-12-08 22:03:44 +01:00
|
|
|
|
2016-10-20 08:35:08 +02:00
|
|
|
push.withPriority(Priority.HIGH);
|
2015-01-26 11:52:50 +01:00
|
|
|
assertEquals(push.getPriority(), Priority.HIGH);
|
2015-12-08 22:03:44 +01:00
|
|
|
|
2016-10-20 08:35:08 +02:00
|
|
|
push.withRetry(RETRY);
|
2015-01-26 11:52:50 +01:00
|
|
|
assertEquals(push.getRetry(), RETRY);
|
2015-12-08 22:03:44 +01:00
|
|
|
|
2016-10-20 08:35:08 +02:00
|
|
|
push.withSound(Sound.ALIEN);
|
2015-01-26 11:52:50 +01:00
|
|
|
assertEquals(push.getSound(), Sound.ALIEN);
|
2015-12-08 22:03:44 +01:00
|
|
|
|
2016-10-20 08:35:08 +02:00
|
|
|
push.withTimestamp(TIMESTAMP);
|
2015-01-26 11:52:50 +01:00
|
|
|
assertEquals(push.getTimestamp(), TIMESTAMP);
|
2015-12-08 22:03:44 +01:00
|
|
|
|
2016-10-20 08:35:08 +02:00
|
|
|
push.withTitle(TITLE);
|
2015-01-26 11:52:50 +01:00
|
|
|
assertEquals(push.getTitle(), TITLE);
|
2015-12-08 22:03:44 +01:00
|
|
|
|
2016-10-20 08:35:08 +02:00
|
|
|
push.withToken(TOKEN);
|
2015-01-26 11:52:50 +01:00
|
|
|
assertEquals(push.getToken(), TOKEN);
|
2015-12-08 22:03:44 +01:00
|
|
|
|
2016-10-20 08:35:08 +02:00
|
|
|
push.withUrl(URL);
|
2015-01-26 11:52:50 +01:00
|
|
|
assertEquals(push.getUrl(), URL);
|
2015-12-08 22:03:44 +01:00
|
|
|
|
2016-10-20 08:35:08 +02:00
|
|
|
push.withUrlTitle(URL_TITLE);
|
2015-01-26 11:52:50 +01:00
|
|
|
assertEquals(push.getUrlTitle(), URL_TITLE);
|
2015-12-08 22:03:44 +01:00
|
|
|
|
2016-10-20 08:35:08 +02:00
|
|
|
push.withUser(USER);
|
2015-01-26 11:52:50 +01:00
|
|
|
assertEquals(push.getUser(), USER);
|
2015-12-08 22:03:44 +01:00
|
|
|
|
2016-10-20 08:35:08 +02:00
|
|
|
push.enableHtml();
|
2015-12-10 11:22:15 +01:00
|
|
|
assertTrue(push.isHtml());
|
2018-01-24 17:00:42 +01:00
|
|
|
|
2018-08-16 15:32:26 +08:00
|
|
|
push.withProxy(PROXY);
|
|
|
|
assertEquals(push.getProxy(), PROXY);
|
|
|
|
|
|
|
|
final JPushoverResponse response = push.push();
|
2018-01-31 15:55:01 +01:00
|
|
|
assertTrue(response != null);
|
2015-01-26 11:52:50 +01:00
|
|
|
}
|
|
|
|
}
|