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

Last change on this file since 837 was 595, checked in by wouter, 15 months ago

#197 working on translating @Test annotations.
added (expected-..) support.
Fixed poms that suddenly require https and /maven2

File size: 1.4 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() {
41 List<List<DiscreteValue>> list = new LinkedList<>();
42 list.add(Arrays.asList(value, value1));
43 list.add(Arrays.asList(valueb));
44 return list;
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.