Skip to content

Commit ac92f34

Browse files
authored
Merge pull request #597 from enismustafaj/bug/remove-length-constraint-lookup-organization-by-externalid
2 parents bc1fb90 + 4319ff4 commit ac92f34

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/main/java/org/zendesk/client/v2/Zendesk.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,8 +1423,8 @@ public JobStatus deleteOrganizations(long... ids) {
14231423
}
14241424

14251425
public Iterable<Organization> lookupOrganizationsByExternalId(String externalId) {
1426-
if (externalId == null || externalId.length() < 2) {
1427-
throw new IllegalArgumentException("Name must be at least 2 characters long");
1426+
if (externalId == null || externalId.length() == 0) {
1427+
throw new IllegalArgumentException("External ID must not be null or length 0");
14281428
}
14291429
return new PagedIterable<>(
14301430
tmpl("/organizations/search.json{?external_id}").set("external_id", externalId),

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
import static org.junit.Assert.assertEquals;
9898
import static org.junit.Assert.assertNotEquals;
9999
import static org.junit.Assert.assertNotNull;
100+
import static org.junit.Assert.assertThrows;
100101
import static org.junit.Assert.assertTrue;
101102
import static org.junit.Assert.assertFalse;
102103
import static org.junit.Assume.assumeThat;
@@ -1583,6 +1584,21 @@ public void createOrganizationMemberships() throws Exception {
15831584
}
15841585
}
15851586

1587+
@Test
1588+
public void lookupOrganizationByExternalId() throws Exception {
1589+
createClientWithTokenOrPassword();
1590+
1591+
Organization newOrganization = newTestOrganization();
1592+
newOrganization.setExternalId("i");
1593+
Organization resultOrganization = instance.createOrganization(newOrganization);
1594+
assertNotNull(resultOrganization);
1595+
1596+
Iterable<Organization> or = instance.lookupOrganizationsByExternalId("i");
1597+
assertEquals(1, StreamSupport.stream(or.spliterator(), false).count());
1598+
1599+
assertThrows(IllegalArgumentException.class, () -> instance.lookupOrganizationsByExternalId(""));
1600+
}
1601+
15861602
@Test
15871603
public void getGroups() throws Exception {
15881604
createClientWithTokenOrPassword();

0 commit comments

Comments
 (0)