package geniusweb.actions; import static org.junit.Assert.assertEquals; import java.io.IOException; import java.net.URISyntaxException; import java.util.Arrays; import java.util.List; import org.junit.Before; import org.junit.Test; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import tudelft.utilities.junit.GeneralTests; public class PartyIdTest1 extends GeneralTests { private PartyId party1, party1a, party2, party3; private String asJson = "\"party1\""; @Before public void before() throws URISyntaxException { party1 = new PartyId("party1"); party1a = new PartyId("party1"); party2 = new PartyId("party2"); party3 = new PartyId("party3"); } @Override public List> getGeneralTestData() { return Arrays.asList(Arrays.asList(party1, party1a), Arrays.asList(party2), Arrays.asList(party3)); } @Override public List getGeneralTestStrings() { return Arrays.asList("party1", "party2", "party3"); } @SuppressWarnings("unused") @Test(expected = IllegalArgumentException.class) public void smokeTest() throws URISyntaxException { new PartyId("*Csh789&@#^!^@^&"); } @SuppressWarnings("unused") @Test(expected = IllegalArgumentException.class) public void nullTest() throws URISyntaxException { new PartyId(null); } @Test public void testSerialize() throws JsonProcessingException { ObjectMapper jackson = new ObjectMapper(); String json = jackson.writeValueAsString(party1); System.out.println(json); assertEquals(asJson, json); } @Test public void testDeserialize() throws JsonParseException, JsonMappingException, IOException { ObjectMapper jackson = new ObjectMapper(); PartyId p = jackson.readValue(asJson, PartyId.class); System.out.println(p); assertEquals(party1, p); } }