forked from gooddata/gooddata-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntryTest.java
More file actions
59 lines (51 loc) · 2.53 KB
/
Copy pathEntryTest.java
File metadata and controls
59 lines (51 loc) · 2.53 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
/*
* Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved.
*/
package com.gooddata.md;
import org.codehaus.jackson.map.ObjectMapper;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.testng.annotations.Test;
import static com.gooddata.JsonMatchers.serializesToJson;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
public class EntryTest {
public static final String LINK = "/gdc/md/PROJECT_ID/obj/ENTRY_ID";
public static final String AUTHOR = "/gdc/account/profile/AUTHOR_USER_ID";
public static final String CONTRIBUTOR = "/gdc/account/profile/CONTRIBUTOR_USER_ID";
public static final DateTime CREATED = new DateTime(2014, 4, 11, 13, 45, 54, DateTimeZone.UTC);
public static final String SUMMARY = "Entry summary";
public static final String TITLE = "Entry title";
public static final DateTime UPDATED = new DateTime(2014, 4, 11, 13, 45, 55, DateTimeZone.UTC);
public static final String CATEGORY = "ENTRY_CATEGORY";
public static final String TAGS = "TAG";
public static final boolean DEPRECATED = true;
public static final String IDENTIFIER = "ID";
public static final boolean LOCKED = true;
public static final boolean UNLISTED = false;
@Test
public void testDeserialize() throws Exception {
final Entry entry = new ObjectMapper().readValue(getClass().getResourceAsStream("/md/entry.json"), Entry.class);
assertThat(entry, is(notNullValue()));
assertThat(entry.getLink(), is(LINK));
assertThat(entry.getTitle(), is(TITLE));
assertThat(entry.getSummary(), is(SUMMARY));
assertThat(entry.getCategory(), is(CATEGORY));
assertThat(entry.getAuthor(), is(AUTHOR));
assertThat(entry.getContributor(), is(CONTRIBUTOR));
assertThat(entry.isDeprecated(), is(DEPRECATED));
assertThat(entry.getIdentifier(), is(IDENTIFIER));
assertThat(entry.getTags(), is(TAGS));
assertThat(entry.getCreated(), is(CREATED));
assertThat(entry.getUpdated(), is(UPDATED));
assertThat(entry.isLocked(), is(LOCKED));
assertThat(entry.isUnlisted(), is(UNLISTED));
}
@Test
public void testSerialization() throws Exception {
final Entry entry = new Entry(LINK, TITLE, SUMMARY, CATEGORY, AUTHOR, CONTRIBUTOR, DEPRECATED, IDENTIFIER, TAGS,
CREATED, UPDATED, LOCKED, UNLISTED);
assertThat(entry, serializesToJson("/md/entry.json"));
}
}