-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTestAssetLibrary.java
More file actions
98 lines (83 loc) · 3.58 KB
/
TestAssetLibrary.java
File metadata and controls
98 lines (83 loc) · 3.58 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package com.contentstack.sdk;
import org.junit.jupiter.api.*;
import java.util.List;
import java.util.logging.Logger;
import static org.junit.jupiter.api.Assertions.assertEquals;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class TestAssetLibrary {
private final Logger logger = Logger.getLogger(TestAssetLibrary.class.getName());
private final Stack stack = Credentials.getStack();
@Test
@Order(1)
void testNewAssetLibrary() {
AssetLibrary assets = stack.assetLibrary();
assets.fetchAll(new FetchAssetsCallback() {
@Override
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
Asset model = assets.get(0);
Assertions.assertTrue(model.getAssetUid().startsWith("blt"));
assertEquals("image/jpeg", model.getFileType());
assertEquals("1775299", model.getFileSize());
assertEquals("phoenix2.jpg", model.getFileName());
Assertions.assertTrue(model.getUrl().endsWith("phoenix2.jpg"));
Assertions.assertTrue(model.toJSON().has("created_at"));
Assertions.assertTrue(model.getCreatedBy().startsWith("blt"));
assertEquals("gregory", model.getUpdateAt().getCalendarType());
Assertions.assertTrue(model.getUpdatedBy().startsWith("blt"));
assertEquals("", model.getDeletedBy());
logger.info("passed...");
}
});
}
@Test
void testAssetSetHeader() {
AssetLibrary assetLibrary = stack.assetLibrary();
assetLibrary.setHeader("headerKey", "headerValue");
Assertions.assertTrue(assetLibrary.headers.containsKey("headerKey"));
}
@Test
void testAssetRemoveHeader() {
AssetLibrary assetLibrary = stack.assetLibrary();
assetLibrary.setHeader("headerKey", "headerValue");
assetLibrary.removeHeader("headerKey");
Assertions.assertFalse(assetLibrary.headers.containsKey("headerKey"));
}
@Test
void testAssetSortAscending() {
AssetLibrary assetLibrary = stack.assetLibrary().sort("ascending", AssetLibrary.ORDERBY.ASCENDING);
Assertions.assertFalse(assetLibrary.headers.containsKey("asc"));
}
@Test
void testAssetSortDescending() {
AssetLibrary assetLibrary = stack.assetLibrary();
assetLibrary.sort("descending", AssetLibrary.ORDERBY.DESCENDING);
Assertions.assertFalse(assetLibrary.headers.containsKey("desc"));
}
@Test
void testAssetIncludeCount() {
AssetLibrary assetLibrary = stack.assetLibrary().includeCount();
Assertions.assertFalse(assetLibrary.headers.containsKey("include_count"));
}
@Test
void testAssetIncludeRelativeUrl() {
AssetLibrary assetLibrary = stack.assetLibrary();
assetLibrary.includeRelativeUrl();
Assertions.assertFalse(assetLibrary.headers.containsKey("relative_urls"));
}
@Test
void testAssetGetCount() {
AssetLibrary assetLibrary = stack.assetLibrary().includeRelativeUrl();
Assertions.assertEquals(0, assetLibrary.getCount());
}
@Test
void testIncludeFallback() {
AssetLibrary assetLibrary = stack.assetLibrary().includeFallback();
Assertions.assertFalse(assetLibrary.headers.containsKey("include_fallback"));
}
@Test
void testIncludeOwner() {
AssetLibrary assetLibrary = stack.assetLibrary().includeMetadata();
Assertions.assertFalse(assetLibrary.headers.containsKey("include_owner"));
}
}