Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/test/java/com/intercom/api/integration/ContactsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void before() {
.externalId(Utils.randomString())
.phone("+353871234567")
.build()));
contactId = contact.getId().orElseThrow(() -> new RuntimeException("Contact ID is required"));
contactId = contact.getId();

// act
company = client.companies()
Expand Down Expand Up @@ -151,8 +151,7 @@ public void testCreateLead() {
try {
client.contacts()
.delete(DeleteContactRequest.builder()
.contactId(
response.getId().orElseThrow(() -> new RuntimeException("Contact ID is required")))
.contactId(response.getId())
.build());
} catch (Exception e) {
throw new RuntimeException("Failed to delete contact.", e);
Expand Down Expand Up @@ -218,7 +217,7 @@ public void testDelete() {
.role("lead")
.name("Roman Bowling")
.build()));
String createdId = created.getId().orElseThrow(() -> new RuntimeException("Contact ID is required"));
String createdId = created.getId();
ContactDeleted response = client.contacts()
.delete(DeleteContactRequest.builder().contactId(createdId).build());

Expand All @@ -234,7 +233,7 @@ public void testMergeLeadInUser() {
.role("lead")
.name("Roman Bowling")
.build()));
String leadId = lead.getId().orElseThrow(() -> new RuntimeException("Lead ID is required"));
String leadId = lead.getId();
ContactsMergeLeadInUserResponse response = client.contacts()
.mergeLeadInUser(MergeContactsRequest.builder()
.leadId(leadId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,19 @@ public void before() {
.externalId(Utils.randomString())
.name("Baba Booey")
.build()));
userId = user.getId().orElseThrow(() -> new RuntimeException("User ID is required"));
userId = user.getId();
secondUser = client.contacts()
.create(CreateContactRequest.of(CreateContactRequest.WithExternalId.builder()
.externalId(Utils.randomString())
.name("Babusha Boy")
.build()));
secondUserId = secondUser.getId().orElseThrow(() -> new RuntimeException("Second user ID is required"));
secondUserId = secondUser.getId();
lead = client.contacts()
.create(CreateContactRequest.of(CreateContactRequest.WithExternalId.builder()
.externalId(Utils.randomString())
.name("Babushka Lead")
.build()));
leadId = lead.getId().orElseThrow(() -> new RuntimeException("Lead ID is required"));
leadId = lead.getId();

Message conversationMessage = client.conversations()
.create(CreateConversationRequest.builder()
Expand All @@ -120,14 +120,12 @@ public void before() {
after();
}

String msgConversationId = conversationMessage
.getConversationId()
.orElseThrow(() -> new RuntimeException("Conversation ID is required"));
String msgConversationId = conversationMessage.getConversationId();
conversation = client.conversations()
.find(FindConversationRequest.builder()
.conversationId(msgConversationId)
.build());
conversationId = conversation.getId().orElseThrow(() -> new RuntimeException("Conversation ID is required"));
conversationId = conversation.getId();
}

@AfterEach
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/intercom/api/integration/NotesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ public void before() {
.create(CreateContactRequest.of(CreateContactRequest.WithExternalId.builder()
.externalId(Utils.randomString())
.build()));
contactId = contact.getId().orElseThrow(() -> new RuntimeException("Contact ID is required"));
contactId = contact.getId();

note = client.notes()
.create(CreateContactNoteRequest.builder()
.contactId(contactId)
.body(Utils.randomString())
.adminId(adminId)
.build());
noteId = Integer.parseInt(note.getId().orElseThrow(() -> new RuntimeException("Note ID is required")));
noteId = Integer.parseInt(note.getId());
}

@AfterEach
Expand Down
11 changes: 4 additions & 7 deletions src/test/java/com/intercom/api/integration/TagsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void testTagContact() {
.create(CreateContactRequest.of(CreateContactRequest.WithExternalId.builder()
.externalId(Utils.randomString())
.build()));
String contactId = contact.getId().orElseThrow(() -> new RuntimeException("Contact ID is required"));
String contactId = contact.getId();

// act
Tag response = client.tags()
Expand Down Expand Up @@ -204,7 +204,7 @@ public void testTagConversation() {
.externalId(Utils.randomString())
.name("John Smith")
.build()));
String contactId = contact.getId().orElseThrow(() -> new RuntimeException("Contact ID is required"));
String contactId = contact.getId();

Message conversationMessage = client.conversations()
.create(CreateConversationRequest.builder()
Expand All @@ -228,12 +228,9 @@ public void testTagConversation() {

Conversation conversation = client.conversations()
.find(FindConversationRequest.builder()
.conversationId(conversationMessage
.getConversationId()
.orElseThrow(() -> new RuntimeException("Conversation ID is required")))
.conversationId(conversationMessage.getConversationId())
.build());
String conversationId =
conversation.getId().orElseThrow(() -> new RuntimeException("Conversation ID is required"));
String conversationId = conversation.getId();

// act
Tag response = client.tags()
Expand Down
Loading