source: java2python/geniuswebtranslator/geniuswebtest/geniusweb/issuevalue/DiscreteValueTest.java@ 889

Last change on this file since 889 was 846, checked in by wouter, 5 months ago

#264 small fixes

File size: 1.5 KB
RevLine 
[595]1package geniusweb.issuevalue;
2
3import static org.junit.Assert.assertEquals;
4
5import java.io.IOException;
6import java.util.Arrays;
7import java.util.LinkedList;
8import java.util.List;
9
10import org.junit.Test;
11
12import com.fasterxml.jackson.core.JsonProcessingException;
13import com.fasterxml.jackson.databind.ObjectMapper;
14
15import tudelft.utilities.junit.GeneralTests;
16
17public class DiscreteValueTest extends GeneralTests<DiscreteValue> {
18 private final DiscreteValue value = new DiscreteValue("a");
19 private final DiscreteValue value1 = new DiscreteValue("a");
20 private final DiscreteValue valueb = new DiscreteValue("b");
21 private final String serialized = "\"a\"";
22 private static final ObjectMapper jackson = new ObjectMapper();
23
24 @Test
25 public void testSerialize() throws JsonProcessingException {
26 assertEquals(serialized, jackson.writeValueAsString(value));
27 }
28
29 @Test
30 public void testDeserialize() throws IOException {
31 assertEquals(value, jackson.readValue(serialized, DiscreteValue.class));
32 }
33
34 @Test
35 public void testDeserializeFromValue() throws IOException {
36 assertEquals(value, jackson.readValue(serialized, Value.class));
37 }
38
39 @Override
40 public List<List<DiscreteValue>> getGeneralTestData() {
[846]41 List<List<DiscreteValue>> testlist = new LinkedList<>();
42 testlist.add(Arrays.asList(value, value1));
43 testlist.add(Arrays.asList(valueb));
44 return testlist;
[595]45 }
46
47 @Override
48 public List<String> getGeneralTestStrings() {
49 return Arrays.asList(serialized, "\"b\"");
50 }
51
52}
Note: See TracBrowser for help on using the repository browser.