Skip to content

Commit 59fb412

Browse files
committed
Tidy up updateUserIdentityTest to esnure it cleans up on failure
1 parent 983a598 commit 59fb412

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

src/main/java/org/zendesk/client/v2/model/Identity.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,19 @@ public Date getUpdatedAt() {
105105
public void setUpdatedAt(Date updatedAt) {
106106
this.updatedAt = updatedAt;
107107
}
108+
109+
@Override
110+
public String toString() {
111+
return "Identity{" +
112+
"id=" + id +
113+
", url='" + url + '\'' +
114+
", userId=" + userId +
115+
", type='" + type + '\'' +
116+
", value='" + value + '\'' +
117+
", verified=" + verified +
118+
", primary=" + primary +
119+
", createdAt=" + createdAt +
120+
", updatedAt=" + updatedAt +
121+
'}';
122+
}
108123
}

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,14 +375,18 @@ public void updateUserIdentity() throws Exception {
375375
identity.setValue("first@test.com");
376376

377377
Identity createdIdentity = instance.createUserIdentity(user, identity);
378-
assertThat(createdIdentity.getValue(), is("first@test.com"));
379-
380-
createdIdentity.setValue("second@test.com");
381-
Identity updatedIdentity = instance.updateUserIdentity(user, createdIdentity);
378+
try {
379+
assertThat(createdIdentity.getValue(), is("first@test.com"));
382380

383-
assertThat(updatedIdentity.getValue(), is("second@test.com"));
381+
createdIdentity.setValue("second@test.com");
382+
Identity updatedIdentity = instance.updateUserIdentity(user, createdIdentity);
384383

385-
instance.deleteUserIdentity(user, identity);
384+
assertThat(updatedIdentity.getValue(), is("second@test.com"));
385+
} finally {
386+
if (createdIdentity != null) {
387+
instance.deleteUserIdentity(user, createdIdentity.getId());
388+
}
389+
}
386390
}
387391

388392
@Test

0 commit comments

Comments
 (0)