Skip to content

Commit 5e73b4f

Browse files
author
Jacob Glickman
committed
Added unit test to improve code coverage.
1 parent 342b40b commit 5e73b4f

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.github.jsonldjava.core;
2+
3+
import org.junit.Test;
4+
5+
import java.util.HashMap;
6+
import java.util.List;
7+
import java.util.Map;
8+
9+
import static org.junit.Assert.assertEquals;
10+
11+
public class DecimalLiteralCanonicalTest {
12+
13+
@Test
14+
public void testDecimalIsNotCanonicalized() {
15+
double value = 6.5;
16+
17+
Map<String, Object> innerMap = new HashMap<>();
18+
innerMap.put("@value", value);
19+
innerMap.put("@type", "http://www.w3.org/2001/XMLSchema#decimal");
20+
21+
Map<String, Object> jsonMap = new HashMap<>();
22+
jsonMap.put("ex:id", innerMap);
23+
24+
JsonLdApi api = new JsonLdApi(jsonMap, new JsonLdOptions(""));
25+
RDFDataset dataset = api.toRDF();
26+
27+
List<Object> defaultList = (List<Object>) dataset.get("@default");
28+
Map<String, Object> tripleMap = (Map<String, Object>) defaultList.get(0);
29+
Map<String, String> objectMap = (Map<String, String>) tripleMap.get("object");
30+
31+
assertEquals("http://www.w3.org/2001/XMLSchema#decimal", objectMap.get("datatype"));
32+
assertEquals(Double.toString(value), objectMap.get("value"));
33+
}
34+
}

0 commit comments

Comments
 (0)