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
78 lines (67 loc) · 3.36 KB
/
EntryTest.java
File metadata and controls
78 lines (67 loc) · 3.36 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
/*
* Copyright (C) 2004-2017, GoodData(R) Corporation. All rights reserved.
* This source code is licensed under the BSD-style license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
package com.gooddata.md;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.testng.annotations.Test;
import java.util.Set;
import static com.gooddata.util.ResourceUtils.readObjectFromResource;
import static java.util.Collections.singleton;
import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
import static net.javacrumbs.jsonunit.core.util.ResourceUtils.resource;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.text.MatchesPattern.matchesPattern;
public class EntryTest {
public static final String OBJ_ID = "ENTRY_ID";
public static final String URI = "/gdc/md/PROJECT_ID/obj/" + OBJ_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 Set<String> TAGS = singleton("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;
@SuppressWarnings("deprecation")
@Test
public void testDeserialize() throws Exception {
final Entry entry = readObjectFromResource("/md/entry.json", Entry.class);
assertThat(entry, is(notNullValue()));
assertThat(entry.getId(), is(OBJ_ID));
assertThat(entry.getLink(), is(URI));
assertThat(entry.getUri(), is(URI));
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(URI, TITLE, SUMMARY, CATEGORY, AUTHOR, CONTRIBUTOR, DEPRECATED, IDENTIFIER, TAGS,
CREATED, UPDATED, LOCKED, UNLISTED);
assertThat(entry, jsonEquals(resource("md/entry.json")));
}
@Test
public void testToStringFormat() {
final Entry entry = new Entry(URI, TITLE, SUMMARY, CATEGORY, AUTHOR, CONTRIBUTOR, DEPRECATED, IDENTIFIER, TAGS,
CREATED, UPDATED, LOCKED, UNLISTED);
assertThat(entry.toString(), matchesPattern(Entry.class.getSimpleName() + "\\[.*\\]"));
}
}