|
41 | 41 | import org.zendesk.client.v2.model.events.Event;
|
42 | 42 | import org.zendesk.client.v2.model.hc.Article;
|
43 | 43 | import org.zendesk.client.v2.model.hc.Category;
|
| 44 | +import org.zendesk.client.v2.model.hc.PermissionGroup; |
44 | 45 | import org.zendesk.client.v2.model.hc.Section;
|
45 | 46 | import org.zendesk.client.v2.model.hc.Subscription;
|
46 | 47 | import org.zendesk.client.v2.model.hc.Translation;
|
|
77 | 78 | import static org.hamcrest.MatcherAssert.assertThat;
|
78 | 79 | import static org.hamcrest.Matchers.containsInAnyOrder;
|
79 | 80 | import static org.hamcrest.Matchers.empty;
|
80 |
| -import static org.hamcrest.Matchers.isEmptyString; |
81 | 81 | import static org.hamcrest.Matchers.greaterThan;
|
82 | 82 | import static org.hamcrest.Matchers.hasSize;
|
| 83 | +import static org.hamcrest.Matchers.isEmptyString; |
| 84 | +import static org.hamcrest.Matchers.lessThan; |
83 | 85 | import static org.hamcrest.Matchers.lessThanOrEqualTo;
|
84 | 86 | import static org.hamcrest.core.StringContains.containsString;
|
85 | 87 | import static org.junit.Assert.assertEquals;
|
@@ -1245,6 +1247,49 @@ public void getGroups() throws Exception {
|
1245 | 1247 | }
|
1246 | 1248 | }
|
1247 | 1249 |
|
| 1250 | + @Test |
| 1251 | + public void getPermissionGroups() throws Exception { |
| 1252 | + createClientWithTokenOrPassword(); |
| 1253 | + int count = 0; |
| 1254 | + for (PermissionGroup pg : instance.getPermissionGroups()) { |
| 1255 | + assertThat(pg.getId(), notNullValue()); |
| 1256 | + assertThat(pg.getName(), notNullValue()); |
| 1257 | + assertThat(pg.getBuiltIn(), notNullValue()); |
| 1258 | + assertThat(pg.getCreatedAt(), notNullValue()); |
| 1259 | + assertThat(pg.getUpdatedAt(), notNullValue()); |
| 1260 | + if (++count > 1) { |
| 1261 | + break; |
| 1262 | + } |
| 1263 | + } |
| 1264 | + } |
| 1265 | + |
| 1266 | + @Test |
| 1267 | + public void permissionGroupCRUD() throws Exception { |
| 1268 | + createClientWithTokenOrPassword(); |
| 1269 | + PermissionGroup pg = new PermissionGroup(); |
| 1270 | + pg.setName("[zendesk-java-client] This is a creation test " + UUID.randomUUID()); |
| 1271 | + pg = instance.createPermissionGroup(pg); |
| 1272 | + Long pgId = pg.getId(); |
| 1273 | + try { |
| 1274 | + assertThat(pg.getId(), notNullValue()); |
| 1275 | + assertThat(pg.getName(), containsString("[zendesk-java-client] This is a creation test")); |
| 1276 | + assertThat(pg.getCreatedAt(), notNullValue()); |
| 1277 | + assertThat(pg.getUpdatedAt(), notNullValue()); |
| 1278 | + assertThat(pg.getCreatedAt(), is(pg.getUpdatedAt())); |
| 1279 | + pg.setName("[zendesk-java-client] This is an update test" + UUID.randomUUID()); |
| 1280 | + pg = instance.updatePermissionGroup(pg); |
| 1281 | + assertThat(pg.getId(), is(pgId)); |
| 1282 | + assertThat(pg.getName(), containsString("[zendesk-java-client] This is an update test")); |
| 1283 | + assertThat(pg.getCreatedAt(), notNullValue()); |
| 1284 | + assertThat(pg.getUpdatedAt(), notNullValue()); |
| 1285 | + assertThat(pg.getCreatedAt(), lessThanOrEqualTo(pg.getUpdatedAt())); |
| 1286 | + } finally { |
| 1287 | + instance.deletePermissionGroup(pg); |
| 1288 | + } |
| 1289 | + PermissionGroup ghost = instance.getPermissionGroup(pgId); |
| 1290 | + assertThat(ghost, nullValue()); |
| 1291 | + } |
| 1292 | + |
1248 | 1293 | @Test
|
1249 | 1294 | public void getArticles() throws Exception {
|
1250 | 1295 | createClientWithTokenOrPassword();
|
|
0 commit comments