Skip to content

Commit fe3e72b

Browse files
author
Javen
committed
Add package-info.java for docs; tiny refactor code.
1 parent 16c4c7b commit fe3e72b

File tree

8 files changed

+53
-32
lines changed

8 files changed

+53
-32
lines changed

pom.xml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,33 +41,35 @@
4141
<artifactId>gson</artifactId>
4242
<version>2.3</version>
4343
</dependency>
44+
<dependency>
45+
<groupId>com.google.guava</groupId>
46+
<artifactId>guava</artifactId>
47+
<version>17.0</version>
48+
</dependency>
4449
<dependency>
4550
<groupId>org.slf4j</groupId>
4651
<artifactId>slf4j-api</artifactId>
4752
<version>1.7.7</version>
4853
</dependency>
54+
4955
<dependency>
5056
<groupId>org.slf4j</groupId>
5157
<artifactId>slf4j-log4j12</artifactId>
5258
<version>1.7.7</version>
59+
<scope>test</scope>
5360
</dependency>
5461
<dependency>
5562
<groupId>log4j</groupId>
5663
<artifactId>log4j</artifactId>
5764
<version>1.2.17</version>
65+
<scope>test</scope>
5866
</dependency>
5967
<dependency>
6068
<groupId>junit</groupId>
6169
<artifactId>junit</artifactId>
6270
<version>4.11</version>
6371
<scope>test</scope>
6472
</dependency>
65-
<dependency>
66-
<groupId>com.google.guava</groupId>
67-
<artifactId>guava</artifactId>
68-
<version>17.0</version>
69-
</dependency>
70-
7173
<dependency>
7274
<groupId>com.squareup.okhttp</groupId>
7375
<artifactId>mockwebserver</artifactId>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Examples for demo API usage.
3+
*/
4+
package cn.jpush.api.examples;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Push API features.
3+
*
4+
* Url: https://api.jpush.cn/v3/push
5+
*/
6+
package cn.jpush.api.push;

src/cn/jpush/api/push/package.html

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Report API features.
3+
*
4+
* Url: https://report.jpush.cn/v3/report/
5+
*/
6+
package cn.jpush.api.report;

test/cn/jpush/api/push/model/MessageTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package cn.jpush.api.push.model;
22

3+
import static org.hamcrest.CoreMatchers.is;
4+
import static org.junit.Assert.assertThat;
5+
36
import java.util.HashMap;
47
import java.util.Map;
58

6-
import org.junit.Assert;
79
import org.junit.Test;
810

11+
import com.google.gson.JsonElement;
912
import com.google.gson.JsonObject;
1013
import com.google.gson.JsonPrimitive;
1114

@@ -23,8 +26,7 @@ public void testMsgContent() {
2326
JsonObject json = new JsonObject();
2427
json.add("msg_content", new JsonPrimitive("msg content"));
2528

26-
Assert.assertEquals("", json, message.toJSON());
27-
29+
assertThat(message.toJSON(), is((JsonElement) json));
2830
}
2931

3032
@Test
@@ -45,7 +47,7 @@ public void testMsgContentAndExtras() {
4547

4648
json.add("extras", extras);
4749

48-
Assert.assertEquals("", json, message.toJSON());
50+
assertThat(message.toJSON(), is((JsonElement) json));
4951
}
5052

5153
@Test
@@ -66,8 +68,7 @@ public void testMsgContentAndExtrasMap() {
6668
extras.add("key2", new JsonPrimitive("value2"));
6769
json.add("extras", extras);
6870

69-
Assert.assertEquals("", json, message.toJSON());
70-
71+
assertThat(message.toJSON(), is((JsonElement) json));
7172
}
7273

7374

test/cn/jpush/api/push/model/OptionsTest.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package cn.jpush.api.push.model;
22

3-
import org.junit.Assert;
3+
import static org.hamcrest.CoreMatchers.is;
4+
import static org.junit.Assert.assertThat;
5+
46
import org.junit.Test;
57

68
import cn.jpush.api.common.ServiceHelper;
79

10+
import com.google.gson.JsonElement;
811
import com.google.gson.JsonObject;
912
import com.google.gson.JsonPrimitive;
1013

@@ -31,7 +34,8 @@ public void testSendno() {
3134
json.add("sendno", new JsonPrimitive(111));
3235
json.add("apns_production", new JsonPrimitive(false));
3336
Options options = Options.newBuilder().setSendno(111).build();
34-
Assert.assertEquals("", json, options.toJSON());
37+
38+
assertThat(options.toJSON(), is((JsonElement) json));
3539
}
3640

3741
@Test
@@ -44,7 +48,8 @@ public void testTimeToLive_int() {
4448
Options options = Options.newBuilder()
4549
.setSendno(111)
4650
.setTimeToLive(640).build();
47-
Assert.assertEquals("", json, options.toJSON());
51+
52+
assertThat(options.toJSON(), is((JsonElement) json));
4853
}
4954

5055
@Test
@@ -57,7 +62,8 @@ public void testTimeToLive_0() {
5762
Options options = Options.newBuilder()
5863
.setSendno(111)
5964
.setTimeToLive(0).build();
60-
Assert.assertEquals("", json, options.toJSON());
65+
66+
assertThat(options.toJSON(), is((JsonElement) json));
6167
}
6268

6369
@Test
@@ -69,7 +75,8 @@ public void testTimeToLive_default() {
6975
Options options = Options.newBuilder()
7076
.setSendno(111)
7177
.setTimeToLive(-1).build();
72-
Assert.assertEquals("", json, options.toJSON());
78+
79+
assertThat(options.toJSON(), is((JsonElement) json));
7380
}
7481

7582
@Test
@@ -84,7 +91,7 @@ public void testApnsProduction_defaultFalse() {
8491
.setSendno(sendno)
8592
.build();
8693

87-
Assert.assertEquals("", json, options.toJSON());
94+
assertThat(options.toJSON(), is((JsonElement) json));
8895
}
8996

9097
@Test
@@ -100,7 +107,7 @@ public void testApnsProduction_True() {
100107
.setApnsProduction(true)
101108
.build();
102109

103-
Assert.assertEquals("", json, options.toJSON());
110+
assertThat(options.toJSON(), is((JsonElement) json));
104111
}
105112

106113

test/cn/jpush/api/push/model/PlatformTesst.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package cn.jpush.api.push.model;
22

3+
import static org.hamcrest.CoreMatchers.is;
4+
import static org.junit.Assert.assertThat;
5+
36
import org.junit.Assert;
47
import org.junit.Test;
58

69
import cn.jpush.api.common.DeviceType;
7-
import cn.jpush.api.push.model.Platform;
810

911
import com.google.gson.JsonArray;
12+
import com.google.gson.JsonElement;
1013
import com.google.gson.JsonPrimitive;
1114

1215
public class PlatformTesst {
@@ -20,15 +23,17 @@ public void testAll() {
2023
@Test(expected = IllegalArgumentException.class)
2124
public void testNotAll() {
2225
Platform all = Platform.newBuilder().setAll(false).build();
23-
Assert.assertNotEquals("test", new JsonPrimitive("all"), all.toJSON());
26+
27+
assertThat(all.toJSON(), is((JsonElement) new JsonPrimitive("all")));
2428
}
2529

2630
@Test
2731
public void testAndroid() {
2832
Platform android = Platform.newBuilder().addDeviceType(DeviceType.Android).build();
2933
JsonArray array = new JsonArray();
3034
array.add(new JsonPrimitive("android"));
31-
Assert.assertEquals("test", array, android.toJSON());
35+
36+
assertThat(android.toJSON(), is((JsonElement) array));
3237
}
3338

3439
}

0 commit comments

Comments
 (0)