Skip to content

Commit b5e87a0

Browse files
committed
Add integration tests for #387
1 parent a3dc3a0 commit b5e87a0

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

src/test/java/org/zendesk/client/v2/RealSmokeTest.java

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.zendesk.client.v2.model.events.Event;
4242
import org.zendesk.client.v2.model.hc.Article;
4343
import org.zendesk.client.v2.model.hc.Category;
44+
import org.zendesk.client.v2.model.hc.PermissionGroup;
4445
import org.zendesk.client.v2.model.hc.Section;
4546
import org.zendesk.client.v2.model.hc.Subscription;
4647
import org.zendesk.client.v2.model.hc.Translation;
@@ -77,9 +78,10 @@
7778
import static org.hamcrest.MatcherAssert.assertThat;
7879
import static org.hamcrest.Matchers.containsInAnyOrder;
7980
import static org.hamcrest.Matchers.empty;
80-
import static org.hamcrest.Matchers.isEmptyString;
8181
import static org.hamcrest.Matchers.greaterThan;
8282
import static org.hamcrest.Matchers.hasSize;
83+
import static org.hamcrest.Matchers.isEmptyString;
84+
import static org.hamcrest.Matchers.lessThan;
8385
import static org.hamcrest.Matchers.lessThanOrEqualTo;
8486
import static org.hamcrest.core.StringContains.containsString;
8587
import static org.junit.Assert.assertEquals;
@@ -1245,6 +1247,49 @@ public void getGroups() throws Exception {
12451247
}
12461248
}
12471249

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+
12481293
@Test
12491294
public void getArticles() throws Exception {
12501295
createClientWithTokenOrPassword();

0 commit comments

Comments
 (0)