-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDeleteItemTest.java
53 lines (42 loc) · 1.72 KB
/
DeleteItemTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package ai.pluggy.client.integration;
import static ai.pluggy.client.integration.helper.ItemHelper.NON_EXISTING_ITEM_ID;
import static ai.pluggy.client.integration.helper.ItemHelper.createItem;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import ai.pluggy.client.response.DeleteItemResponse;
import ai.pluggy.client.response.ErrorResponse;
import ai.pluggy.client.response.ItemResponse;
import java.io.IOException;
import org.junit.jupiter.api.Test;
import retrofit2.Response;
public class DeleteItemTest extends BaseApiIntegrationTest {
@Test
void deleteItem_existingItemId_ok() throws IOException {
// ensure item exists
Integer connectorId = 0;
ItemResponse item = createItem(client, connectorId);
assertNotNull(item);
String existingItemId = item.getId();
// delete item by id
Response<DeleteItemResponse> deleteItemResponse = client.service()
.deleteItem(existingItemId)
.execute();
// expect response to be OK
assertEquals(deleteItemResponse.code(), 200);
DeleteItemResponse itemResponse = deleteItemResponse.body();
assertNotNull(itemResponse);
}
@Test
void deleteItem_nonExistingItemId_error404() throws IOException {
// delete item by non-existing id
Response<DeleteItemResponse> deleteItemResponse = client.service()
.deleteItem(NON_EXISTING_ITEM_ID)
.execute();
// expect response to not be OK
assertFalse(deleteItemResponse.isSuccessful());
ErrorResponse errorResponse = client.parseError(deleteItemResponse);
assertNotNull(errorResponse);
assertEquals(errorResponse.getCode(), 404);
}
}