forked from matomo-org/matomo-java-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPiwikJsonObjectTest.java
More file actions
74 lines (63 loc) · 1.7 KB
/
PiwikJsonObjectTest.java
File metadata and controls
74 lines (63 loc) · 1.7 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
/*
* Piwik Java Tracker
*
* @link https://github.com/piwik/piwik-java-tracker
* @license https://github.com/piwik/piwik-java-tracker/blob/master/LICENSE BSD-3 Clause
*/
package org.piwik.java.tracking;
import org.junit.After;
import org.junit.AfterClass;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
/**
*
* @author brettcsorba
*/
public class PiwikJsonObjectTest{
PiwikJsonObject obj;
public PiwikJsonObjectTest(){
}
@BeforeClass
public static void setUpClass(){
}
@AfterClass
public static void tearDownClass(){
}
@Before
public void setUp(){
obj = new PiwikJsonObject();
}
@After
public void tearDown(){
}
/**
* Test of get method, of class PiwikJsonObject.
*/
@Test
public void testMethods(){
assertTrue(obj.isEmpty());
assertEquals(0, obj.size());
assertNull(obj.put("key", "value"));
assertFalse(obj.isEmpty());
assertEquals(1, obj.size());
assertEquals("value", obj.get("key"));
assertEquals("value", obj.remove("key"));
assertNull(obj.remove("key"));
assertTrue(obj.isEmpty());
assertEquals(0, obj.size());
}
/**
* Test of toString method, of class PiwikJsonObject.
*/
@Test
public void testToString(){
obj.put("key", "value");
obj.put("key2", "value2");
assertEquals("{\"1\":[\"key2\",\"value2\"],\"2\":[\"key\",\"value\"]}", obj.toString());
}
}