Skip to content

Commit 7cd44ce

Browse files
committed
Conflicts solved
1 parent 36df4db commit 7cd44ce

9 files changed

Lines changed: 111 additions & 87 deletions

File tree

‎src/main/java/com/pubnub/api/endpoints/History.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ Call<JsonNode> fetchHistory(@Path("subKey") String subKey,
4747

4848
@Override
4949
protected void validateParams() throws PubNubException {
50-
if (channel==null || channel.isEmpty())
51-
{
50+
if (channel == null || channel.isEmpty()) {
5251
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_CHANNEL_MISSING).build();
5352
}
5453
}

‎src/main/java/com/pubnub/api/endpoints/access/Audit.java‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,35 @@
2121
@Accessors(chain = true, fluent = true)
2222
public class Audit extends Endpoint<Envelope<AccessManagerAuditPayload>, PNAccessManagerAuditResult> {
2323

24-
@Setter private List<String> authKeys;
25-
@Setter private String channel;
26-
@Setter private String channelGroup;
27-
28-
public Audit(PubNub pubnub)
29-
{
24+
@Setter
25+
private List<String> authKeys;
26+
@Setter
27+
private String channel;
28+
@Setter
29+
private String channelGroup;
30+
31+
public Audit(PubNub pubnub) {
3032
super(pubnub);
3133
authKeys = new ArrayList<>();
3234
}
3335

3436
@Override
3537
protected void validateParams() throws PubNubException {
36-
if (authKeys.size() == 0)
37-
{
38+
if (authKeys.size() == 0) {
3839
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_AUTH_KEYS_MISSING).build();
3940
}
40-
if (pubnub.getConfiguration().getSecretKey()==null || pubnub.getConfiguration().getSecretKey().isEmpty()) {
41+
if (pubnub.getConfiguration().getSecretKey() == null || pubnub.getConfiguration().getSecretKey().isEmpty()) {
4142
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_SECRET_KEY_MISSING).build();
4243
}
43-
if (pubnub.getConfiguration().getSubscribeKey()==null || pubnub.getConfiguration().getSubscribeKey().isEmpty()) {
44+
if (pubnub.getConfiguration().getSubscribeKey() == null || pubnub.getConfiguration().getSubscribeKey().isEmpty()) {
4445
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_SUBSCRIBE_KEY_MISSING).build();
4546
}
46-
if (pubnub.getConfiguration().getPublishKey()==null || pubnub.getConfiguration().getPublishKey().isEmpty()) {
47+
if (pubnub.getConfiguration().getPublishKey() == null || pubnub.getConfiguration().getPublishKey().isEmpty()) {
4748
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_PUBLISH_KEY_MISSING).build();
4849
}
50+
if (channel == null && channelGroup == null) {
51+
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_CHANNEL_MISSING).build();
52+
}
4953
}
5054

5155
@Override

‎src/main/java/com/pubnub/api/endpoints/access/Grant.java‎

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,22 @@
2828
@Accessors(chain = true, fluent = true)
2929
public class Grant extends Endpoint<Envelope<AccessManagerGrantPayload>, PNAccessManagerGrantResult> {
3030

31-
@Setter private boolean read;
32-
@Setter private boolean write;
33-
@Setter private boolean manage;
34-
@Setter private Integer ttl;
35-
36-
37-
@Setter private List<String> authKeys;
38-
@Setter private List<String> channels;
39-
@Setter private List<String> channelGroups;
31+
@Setter
32+
private boolean read;
33+
@Setter
34+
private boolean write;
35+
@Setter
36+
private boolean manage;
37+
@Setter
38+
private Integer ttl;
39+
40+
41+
@Setter
42+
private List<String> authKeys;
43+
@Setter
44+
private List<String> channels;
45+
@Setter
46+
private List<String> channelGroups;
4047

4148
public Grant(PubNub pubnub) {
4249
super(pubnub);
@@ -47,19 +54,21 @@ public Grant(PubNub pubnub) {
4754

4855
@Override
4956
protected void validateParams() throws PubNubException {
50-
if (authKeys.size() == 0)
51-
{
57+
if (authKeys.size() == 0) {
5258
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_AUTH_KEYS_MISSING).build();
5359
}
54-
if (pubnub.getConfiguration().getSecretKey()==null || pubnub.getConfiguration().getSecretKey().isEmpty()) {
60+
if (pubnub.getConfiguration().getSecretKey() == null || pubnub.getConfiguration().getSecretKey().isEmpty()) {
5561
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_SECRET_KEY_MISSING).build();
5662
}
57-
if (pubnub.getConfiguration().getSubscribeKey()==null || pubnub.getConfiguration().getSubscribeKey().isEmpty()) {
63+
if (pubnub.getConfiguration().getSubscribeKey() == null || pubnub.getConfiguration().getSubscribeKey().isEmpty()) {
5864
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_SUBSCRIBE_KEY_MISSING).build();
5965
}
60-
if (pubnub.getConfiguration().getPublishKey()==null || pubnub.getConfiguration().getPublishKey().isEmpty()) {
66+
if (pubnub.getConfiguration().getPublishKey() == null || pubnub.getConfiguration().getPublishKey().isEmpty()) {
6167
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_PUBLISH_KEY_MISSING).build();
6268
}
69+
if (channels.size() == 0 && channelGroups.size() == 0) {
70+
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_CHANNEL_AND_GROUP_MISSING).build();
71+
}
6372
}
6473

6574
@Override
@@ -126,7 +135,8 @@ protected PNAccessManagerGrantResult createResponse(Response<Envelope<AccessMana
126135
} else if (channelGroups.size() > 1) {
127136
try {
128137
HashMap<String, PNAccessManagerKeysData> channelGroupKeySet = mapper.readValue(data.getChannelGroups().toString(),
129-
new TypeReference<HashMap<String, PNAccessManagerKeysData>>() {});
138+
new TypeReference<HashMap<String, PNAccessManagerKeysData>>() {
139+
});
130140

131141
for (String fetchedChannelGroup : channelGroupKeySet.keySet()) {
132142
constructedGroups.put(fetchedChannelGroup, channelGroupKeySet.get(fetchedChannelGroup).getAuthKeys());

‎src/main/java/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.java‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
import java.util.Map;
2020

2121
@Accessors(chain = true, fluent = true)
22-
public class AddChannelChannelGroup extends Endpoint<Envelope, Boolean> {
23-
@Setter private String channelGroup;
24-
@Setter private List<String> channels;
22+
public class AddChannelChannelGroup extends Endpoint<Envelope, PNChannelGroupsAddChannelResult> {
23+
@Setter
24+
private String channelGroup;
25+
@Setter
26+
private List<String> channels;
2527

2628

2729
public AddChannelChannelGroup(PubNub pubnub) {
@@ -30,14 +32,11 @@ public AddChannelChannelGroup(PubNub pubnub) {
3032
}
3133

3234
@Override
33-
protected void validateParams() throws PubNubException
34-
{
35-
if (channelGroup==null || channelGroup.isEmpty())
36-
{
35+
protected void validateParams() throws PubNubException {
36+
if (channelGroup == null || channelGroup.isEmpty()) {
3737
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_GROUP_MISSING).build();
3838
}
39-
if (channels.size() == 0)
40-
{
39+
if (channels.size() == 0) {
4140
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_CHANNEL_MISSING).build();
4241
}
4342
}
@@ -54,8 +53,11 @@ protected Call<Envelope> doWork(final Map<String, String> params) {
5453
}
5554

5655
@Override
57-
protected Boolean createResponse(Response<Envelope> input) throws PubNubException {
58-
return !input.body().isError();
56+
protected PNChannelGroupsAddChannelResult createResponse(Response<Envelope> input) throws PubNubException {
57+
if (input.body() == null) {
58+
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_PARSING_ERROR).build();
59+
}
60+
return PNChannelGroupsAddChannelResult.builder().build();
5961
}
6062

6163
protected int getConnectTimeout() {

‎src/main/java/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.java‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
import java.util.Map;
1616

1717
@Accessors(chain = true, fluent = true)
18-
public class DeleteChannelGroup extends Endpoint<Envelope, Boolean> {
19-
@Setter private String channelGroup;
18+
public class DeleteChannelGroup extends Endpoint<Envelope, PNChannelGroupsDeleteGroupResult> {
19+
@Setter
20+
private String channelGroup;
2021

2122
public DeleteChannelGroup(PubNub pubnub) {
2223
super(pubnub);
2324
}
2425

2526
@Override
2627
protected void validateParams() throws PubNubException {
27-
if (channelGroup==null || channelGroup.isEmpty())
28-
{
28+
if (channelGroup == null || channelGroup.isEmpty()) {
2929
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_GROUP_MISSING).build();
3030
}
3131
}
@@ -38,8 +38,11 @@ protected Call<Envelope> doWork(Map<String, String> params) {
3838
}
3939

4040
@Override
41-
protected Boolean createResponse(Response<Envelope> input) throws PubNubException {
42-
return !input.body().isError();
41+
protected PNChannelGroupsDeleteGroupResult createResponse(Response<Envelope> input) throws PubNubException {
42+
if (input.body() == null) {
43+
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_PARSING_ERROR).build();
44+
}
45+
return PNChannelGroupsDeleteGroupResult.builder().build();
4346
}
4447

4548
protected int getConnectTimeout() {

‎src/main/java/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.java‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
import java.util.Map;
1919

2020
@Accessors(chain = true, fluent = true)
21-
public class RemoveChannelChannelGroup extends Endpoint<Envelope, Boolean> {
22-
@Setter private String channelGroup;
23-
@Setter private List<String> channels;
21+
public class RemoveChannelChannelGroup extends Endpoint<Envelope, PNChannelGroupsRemoveChannelResult> {
22+
@Setter
23+
private String channelGroup;
24+
@Setter
25+
private List<String> channels;
2426

2527

2628
public RemoveChannelChannelGroup(PubNub pubnub) {
@@ -30,12 +32,10 @@ public RemoveChannelChannelGroup(PubNub pubnub) {
3032

3133
@Override
3234
protected void validateParams() throws PubNubException {
33-
if (channelGroup==null || channelGroup.isEmpty())
34-
{
35+
if (channelGroup == null || channelGroup.isEmpty()) {
3536
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_GROUP_MISSING).build();
3637
}
37-
if (channels.size() == 0)
38-
{
38+
if (channels.size() == 0) {
3939
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_CHANNEL_MISSING).build();
4040
}
4141
}
@@ -52,8 +52,11 @@ protected Call<Envelope> doWork(Map<String, String> params) {
5252
}
5353

5454
@Override
55-
protected Boolean createResponse(Response<Envelope> input) throws PubNubException {
56-
return !input.body().isError();
55+
protected PNChannelGroupsRemoveChannelResult createResponse(Response<Envelope> input) throws PubNubException {
56+
if (input.body() == null) {
57+
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_PARSING_ERROR).build();
58+
}
59+
return PNChannelGroupsRemoveChannelResult.builder().build();
5760
}
5861

5962
protected int getConnectTimeout() {

‎src/test/java/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroupEndpointTest.java‎

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,33 @@ public void testSyncSuccess() throws IOException, PubNubException, InterruptedEx
3030
stubFor(get(urlPathEqualTo("/v1/channel-registration/sub-key/mySubscribeKey/channel-group/groupA"))
3131
.willReturn(aResponse().withBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {} , \"service\": \"ChannelGroups\"}")));
3232

33-
boolean response = partialAddChannelChannelGroup.channelGroup("groupA").channels(Arrays.asList("ch1", "ch2")).sync();
34-
assertThat(response, org.hamcrest.Matchers.equalTo(true));
33+
PNChannelGroupsAddChannelResult response = partialAddChannelChannelGroup.channelGroup("groupA").channels(Arrays.asList("ch1", "ch2")).sync();
34+
35+
assertNotNull(response);
36+
}
37+
38+
@org.junit.Test(expected = PubNubException.class)
39+
public void testSyncGroupMissing() throws IOException, PubNubException, InterruptedException {
40+
stubFor(get(urlPathEqualTo("/v1/channel-registration/sub-key/mySubscribeKey/channel-group/groupA"))
41+
.willReturn(aResponse().withBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {} , \"service\": \"ChannelGroups\"}")));
42+
43+
PNChannelGroupsAddChannelResult response = partialAddChannelChannelGroup.channels(Arrays.asList("ch1", "ch2")).sync();
3544
}
3645

37-
// @org.junit.Test(expected=PubNubException.class)
38-
// public void testSyncGroupMissing() throws IOException, PubNubException, InterruptedException {
39-
// stubFor(get(urlPathEqualTo("/v1/channel-registration/sub-key/mySubscribeKey/channel-group/groupA"))
40-
// .willReturn(aResponse().withBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {} , \"service\": \"ChannelGroups\"}")));
41-
//
42-
// boolean response = partialAddChannelChannelGroup.channels(Arrays.asList("ch1", "ch2")).sync();
43-
// }
44-
//
45-
// @org.junit.Test(expected=PubNubException.class)
46-
// public void testSyncGroupIsEmpty() throws IOException, PubNubException, InterruptedException {
47-
// stubFor(get(urlPathEqualTo("/v1/channel-registration/sub-key/mySubscribeKey/channel-group/groupA"))
48-
// .willReturn(aResponse().withBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {} , \"service\": \"ChannelGroups\"}")));
49-
//
50-
// boolean response = partialAddChannelChannelGroup.channelGroup("").channels(Arrays.asList("ch1", "ch2")).sync();
51-
// }
52-
//
53-
// @org.junit.Test(expected=PubNubException.class)
54-
// public void testSyncChannelMissing() throws IOException, PubNubException, InterruptedException {
55-
// stubFor(get(urlPathEqualTo("/v1/channel-registration/sub-key/mySubscribeKey/channel-group/groupA"))
56-
// .willReturn(aResponse().withBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {} , \"service\": \"ChannelGroups\"}")));
57-
//
58-
// boolean response = partialAddChannelChannelGroup.channelGroup("groupA").sync();
59-
// }
46+
@org.junit.Test(expected = PubNubException.class)
47+
public void testSyncGroupIsEmpty() throws IOException, PubNubException, InterruptedException {
48+
stubFor(get(urlPathEqualTo("/v1/channel-registration/sub-key/mySubscribeKey/channel-group/groupA"))
49+
.willReturn(aResponse().withBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {} , \"service\": \"ChannelGroups\"}")));
50+
51+
PNChannelGroupsAddChannelResult response = partialAddChannelChannelGroup.channelGroup("").channels(Arrays.asList("ch1", "ch2")).sync();
52+
}
53+
54+
@org.junit.Test(expected = PubNubException.class)
55+
public void testSyncChannelMissing() throws IOException, PubNubException, InterruptedException {
56+
stubFor(get(urlPathEqualTo("/v1/channel-registration/sub-key/mySubscribeKey/channel-group/groupA"))
57+
.willReturn(aResponse().withBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {} , \"service\": \"ChannelGroups\"}")));
58+
59+
PNChannelGroupsAddChannelResult response = partialAddChannelChannelGroup.channelGroup("groupA").sync();
60+
}
6061

6162
}

‎src/test/java/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroupEndpointTest.java‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package com.pubnub.api.endpoints.channel_groups;
22

33
import com.github.tomakehurst.wiremock.junit.WireMockRule;
4+
import com.github.tomakehurst.wiremock.verification.LoggedRequest;
45
import com.pubnub.api.PubNubException;
56
import com.pubnub.api.endpoints.TestHarness;
67
import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult;
78
import org.junit.Before;
89
import org.junit.Rule;
910

1011
import java.io.IOException;
12+
import java.util.List;
1113

1214
import static com.github.tomakehurst.wiremock.client.WireMock.*;
1315
import static org.junit.Assert.assertNotNull;
@@ -28,15 +30,15 @@ public void testSyncSuccess() throws IOException, PubNubException, InterruptedEx
2830
stubFor(get(urlPathEqualTo("/v1/channel-registration/sub-key/mySubscribeKey/channel-group/groupA/remove"))
2931
.willReturn(aResponse().withBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {}, \"service\": \"ChannelGroups\"}")));
3032

31-
boolean response = partialDeleteChannelGroup.channelGroup("groupA").sync();
33+
PNChannelGroupsDeleteGroupResult response = partialDeleteChannelGroup.channelGroup("groupA").sync();
3234
assertNotNull(response);
3335
}
3436

35-
@org.junit.Test(expected=PubNubException.class)
37+
@org.junit.Test(expected = PubNubException.class)
3638
public void testSyncMissingGroup() throws IOException, PubNubException, InterruptedException {
3739
stubFor(get(urlPathEqualTo("/v1/channel-registration/sub-key/mySubscribeKey/channel-group/groupA/remove"))
3840
.willReturn(aResponse().withBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {}, \"service\": \"ChannelGroups\"}")));
3941

40-
boolean response = partialDeleteChannelGroup.sync();
42+
PNChannelGroupsDeleteGroupResult response = partialDeleteChannelGroup.sync();
4143
}
4244
}

‎src/test/java/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroupEndpointTest.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,23 @@ public void testSyncSuccess() throws IOException, PubNubException, InterruptedEx
2929
stubFor(get(urlPathEqualTo("/v1/channel-registration/sub-key/mySubscribeKey/channel-group/groupA"))
3030
.willReturn(aResponse().withBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {}, \"service\": \"ChannelGroups\"}")));
3131

32-
boolean response = partialRemoveChannelChannelGroup.channelGroup("groupA").channels(Arrays.asList("ch1", "ch2")).sync();
32+
PNChannelGroupsRemoveChannelResult response = partialRemoveChannelChannelGroup.channelGroup("groupA").channels(Arrays.asList("ch1", "ch2")).sync();
3333
assertNotNull(response);
3434
}
3535

36-
@org.junit.Test(expected=PubNubException.class)
36+
@org.junit.Test(expected = PubNubException.class)
3737
public void testSyncMissinGroup() throws IOException, PubNubException, InterruptedException {
3838
stubFor(get(urlPathEqualTo("/v1/channel-registration/sub-key/mySubscribeKey/channel-group/groupA"))
3939
.willReturn(aResponse().withBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {}, \"service\": \"ChannelGroups\"}")));
4040

41-
boolean response = partialRemoveChannelChannelGroup.channels(Arrays.asList("ch1", "ch2")).sync();
41+
PNChannelGroupsRemoveChannelResult response = partialRemoveChannelChannelGroup.channels(Arrays.asList("ch1", "ch2")).sync();
4242
}
4343

44-
@org.junit.Test(expected=PubNubException.class)
44+
@org.junit.Test(expected = PubNubException.class)
4545
public void testSyncMissinChannel() throws IOException, PubNubException, InterruptedException {
4646
stubFor(get(urlPathEqualTo("/v1/channel-registration/sub-key/mySubscribeKey/channel-group/groupA"))
4747
.willReturn(aResponse().withBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {}, \"service\": \"ChannelGroups\"}")));
4848

49-
boolean response = partialRemoveChannelChannelGroup.channelGroup("groupA").sync();
49+
PNChannelGroupsRemoveChannelResult response = partialRemoveChannelChannelGroup.channelGroup("groupA").sync();
5050
}
5151
}

0 commit comments

Comments
 (0)