-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathVelocityUtilsTest.java
48 lines (45 loc) · 1.37 KB
/
VelocityUtilsTest.java
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
package com.spun.util.parser;
import com.spun.util.DateUtils;
import org.approvaltests.core.Options;
import org.approvaltests.scrubbers.NormalizeSpacesScrubber;
import org.approvaltests.utils.WithTimeZone;
import org.approvaltests.velocity.VelocityApprovals;
import org.junit.jupiter.api.Test;
import java.sql.Timestamp;
import java.util.Arrays;
//@UseReporter(FileLauncherReporter.class)
public class VelocityUtilsTest
{
@Test
public void testArray()
{
VelocityApprovals.verify(c -> c.put("array", new String[]{"one", "two", "three", "four", "five"}));
}
@Test
public void testList()
{
VelocityApprovals.verify(c -> c.put("array", Arrays.asList("one", "two", "three")),
new Options().forFile().withExtension(".html"));
}
@Test
public void testDate()
{
try (WithTimeZone tz = new WithTimeZone())
{
Timestamp date = DateUtils.parse("2001/02/03");
VelocityApprovals.verify(c -> c.put("date", date),
new Options().forFile().withExtension(".md").withScrubber(new NormalizeSpacesScrubber()));
}
}
@Test
public void testWithTimeZoneExample()
{
// begin-snippet: with_time_zone
try (WithTimeZone tz = new WithTimeZone("UTC"))
{
// All code within this block will see the computer as being in the UTC time zone
}
// The computer's time zone will revert to previous setting here
// end-snippet
}
}