Skip to content

Commit 8b5f698

Browse files
committed
add unit test for timestamp to auditstamp mapper test
1 parent 49bc8d7 commit 8b5f698

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.linkedin.datahub.graphql.types.common.mappers;
2+
3+
import static org.testng.Assert.*;
4+
5+
import com.linkedin.common.TimeStamp;
6+
import com.linkedin.common.urn.Urn;
7+
import com.linkedin.datahub.graphql.generated.AuditStamp;
8+
import org.testng.annotations.Test;
9+
10+
public class TimeStampToAuditStampMapperTest {
11+
12+
private static final String TEST_ACTOR_URN = "urn:li:corpuser:testUser";
13+
private static final long TEST_TIME = 1234567890L;
14+
15+
@Test
16+
public void testMapWithActor() throws Exception {
17+
TimeStamp input = new TimeStamp();
18+
input.setTime(TEST_TIME);
19+
input.setActor(Urn.createFromString(TEST_ACTOR_URN));
20+
21+
AuditStamp result = TimeStampToAuditStampMapper.map(null, input);
22+
23+
assertNotNull(result);
24+
assertEquals(result.getTime().longValue(), TEST_TIME);
25+
assertEquals(result.getActor(), TEST_ACTOR_URN);
26+
}
27+
28+
@Test
29+
public void testMapWithoutActor() {
30+
TimeStamp input = new TimeStamp();
31+
input.setTime(TEST_TIME);
32+
33+
AuditStamp result = TimeStampToAuditStampMapper.map(null, input);
34+
35+
assertNotNull(result);
36+
assertEquals(result.getTime().longValue(), TEST_TIME);
37+
assertNull(result.getActor());
38+
}
39+
40+
@Test
41+
public void testMapNull() {
42+
AuditStamp result = TimeStampToAuditStampMapper.map(null, null);
43+
44+
assertNull(result);
45+
}
46+
}

0 commit comments

Comments
 (0)