Skip to content

Commit e3a2b15

Browse files
committed
testcases for timeline
1 parent bf6380c commit e3a2b15

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/test/java/com/contentstack/sdk/TestLivePreview.java

+42
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import java.io.IOException;
1212
import java.util.HashMap;
13+
import java.util.Map;
1314
import java.util.logging.Level;
1415
import java.util.logging.Logger;
1516

@@ -223,4 +224,45 @@ void testLivePreviewDisabled() throws IllegalAccessException, IOException {
223224
"Expected exception message does not match");
224225
}
225226

227+
@Test
228+
void testTimelinePreview() throws IllegalAccessException, IOException {
229+
Config config = new Config()
230+
.enableLivePreview(true)
231+
.setLivePreviewHost("rest-preview.contentstack.com")
232+
.setPreviewToken("preview_token");
233+
234+
Stack stack = Contentstack.stack("stackApiKey", "deliveryToken", "env1", config);
235+
236+
HashMap<String, String> hashMap = new HashMap<>();
237+
hashMap.put("live_preview", "hash167673");
238+
hashMap.put("content_type_uid", "page");
239+
hashMap.put("entry_uid", "entryUid");
240+
hashMap.put("release_id", "12345");
241+
hashMap.put("preview_timestamp", "2025-09-25 17:45:30.005");
242+
243+
244+
stack.livePreviewQuery(hashMap);
245+
Entry entry = stack.contentType("page").entry("entry_uid");
246+
entry.fetch(null);
247+
Assertions.assertNotNull(entry);
248+
}
249+
250+
@Test
251+
void testLivePreviewQueryWithoutReleaseId() throws Exception {
252+
Config config = new Config().enableLivePreview(true)
253+
.setLivePreviewHost("rest-preview.contentstack.com")
254+
.setPreviewToken("previewToken");
255+
Stack stack = Contentstack.stack("api_key", "access_token", "env", config);
256+
257+
Map<String, String> queryParams = new HashMap<>();
258+
queryParams.put("content_type_uid", "blog");
259+
queryParams.put("entry_uid", "entry_123");
260+
queryParams.put("preview_timestamp", "1710800000");
261+
262+
stack.livePreviewQuery(queryParams);
263+
264+
Assertions.assertNull(config.releaseId);
265+
Assertions.assertEquals("1710800000", config.previewTimestamp);
266+
}
267+
226268
}

0 commit comments

Comments
 (0)