-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathMiscTest.java
More file actions
84 lines (71 loc) · 2.01 KB
/
Copy pathMiscTest.java
File metadata and controls
84 lines (71 loc) · 2.01 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
79
80
81
82
83
84
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package communitycommons;
import communitycommons.proxies.SanitizerPolicy;
import java.util.List;
import java.util.Optional;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
/**
*
* @author reinout
*/
public class MiscTest {
public MiscTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of enumFromString method, of class Misc.
*/
@Test
public void testEnumFromString() {
System.out.println("enumFromString");
SanitizerPolicy expResult = SanitizerPolicy.BLOCKS;
Optional<SanitizerPolicy> result = Misc.enumFromString(SanitizerPolicy.class, "BLOCKS");
assertEquals(expResult, result.orElseThrow());
}
@Test
public void testEnumFromString_WithNonExistingValue() {
System.out.println("enumFromString_WithNonExistingValue");
Optional<SanitizerPolicy> result = Misc.enumFromString(SanitizerPolicy.class, "NOT_A_POLICY");
Assert.assertFalse(result.isPresent());
}
@Test
public void testEnumFromString_WithNull() {
System.out.println("enumFromString_WithNull");
Optional<SanitizerPolicy> result = Misc.enumFromString(SanitizerPolicy.class, null);
Assert.assertFalse(result.isPresent());
}
@Test
public void getApplicationURL() {
System.out.println("getApplicationURL");
String result = Misc.getApplicationURL();
Assert.assertEquals("http://localhost:8080", result); // No trailing slash!
}
@Test
public void testListTop() {
System.out.println("ListTop");
List<Integer> objects = List.of(1, 2, 3, 4, 5, 6, 7, 8);
List<Integer> result = Misc.listTop(objects, 3);
Assert.assertEquals(result, List.of(1, 2, 3));
}
}