Skip to content

Commit

Permalink
Merge pull request #597 from enismustafaj/bug/remove-length-constrain…
Browse files Browse the repository at this point in the history
…t-lookup-organization-by-externalid
  • Loading branch information
PierreBtz authored Jul 24, 2023
2 parents bc1fb90 + 4319ff4 commit ac92f34
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/zendesk/client/v2/Zendesk.java
Original file line number Diff line number Diff line change
Expand Up @@ -1423,8 +1423,8 @@ public JobStatus deleteOrganizations(long... ids) {
}

public Iterable<Organization> lookupOrganizationsByExternalId(String externalId) {
if (externalId == null || externalId.length() < 2) {
throw new IllegalArgumentException("Name must be at least 2 characters long");
if (externalId == null || externalId.length() == 0) {
throw new IllegalArgumentException("External ID must not be null or length 0");
}
return new PagedIterable<>(
tmpl("/organizations/search.json{?external_id}").set("external_id", externalId),
Expand Down
16 changes: 16 additions & 0 deletions src/test/java/org/zendesk/client/v2/RealSmokeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assume.assumeThat;
Expand Down Expand Up @@ -1583,6 +1584,21 @@ public void createOrganizationMemberships() throws Exception {
}
}

@Test
public void lookupOrganizationByExternalId() throws Exception {
createClientWithTokenOrPassword();

Organization newOrganization = newTestOrganization();
newOrganization.setExternalId("i");
Organization resultOrganization = instance.createOrganization(newOrganization);
assertNotNull(resultOrganization);

Iterable<Organization> or = instance.lookupOrganizationsByExternalId("i");
assertEquals(1, StreamSupport.stream(or.spliterator(), false).count());

assertThrows(IllegalArgumentException.class, () -> instance.lookupOrganizationsByExternalId(""));
}

@Test
public void getGroups() throws Exception {
createClientWithTokenOrPassword();
Expand Down

0 comments on commit ac92f34

Please sign in to comment.