Ignore:
Timestamp:
01/28/20 10:19:54 (4 years ago)
Author:
bart
Message:

Update 28 jan 2020

File:
1 edited

Legend:

Unmodified
Added
Removed
  • profile/src/test/java/geniusweb/profile/utilityspace/NumberValueSetUtilTest.java

    r9 r10  
    33import static org.junit.Assert.assertEquals;
    44
     5import java.io.IOException;
    56import java.math.BigDecimal;
    67import java.util.Arrays;
     
    89
    910import org.junit.Test;
     11
     12import com.fasterxml.jackson.core.JsonParseException;
     13import com.fasterxml.jackson.core.JsonProcessingException;
     14import com.fasterxml.jackson.databind.JsonMappingException;
     15import com.fasterxml.jackson.databind.ObjectMapper;
    1016
    1117import geniusweb.issuevalue.DiscreteValue;
     
    3541                        lowval1, low1util, highvalb, highutil);
    3642        private static final BigDecimal ZERO_1 = new BigDecimal("0.1");
     43        private final String utilstring = "{\"numberutils\":{\"lowValue\":12.5,\"lowUtility\":0.5,\"highValue\":18.5,\"highUtility\":0.9}}";
     44
     45        private static final ObjectMapper jackson = new ObjectMapper();
    3746
    3847        @Override
     
    173182        }
    174183
     184        @Test
     185        public void testSerialize() throws JsonProcessingException {
     186
     187                String json = jackson.writeValueAsString(valueset1);
     188                System.out.println(json);
     189                assertEquals(utilstring, json);
     190        }
     191
     192        @Test
     193        public void testDeserialize()
     194                        throws JsonParseException, JsonMappingException, IOException {
     195                ValueSetUtilities valueutils = jackson.readValue(utilstring,
     196                                ValueSetUtilities.class);
     197                assertEquals(valueset1, valueutils);
     198
     199        }
     200
    175201}
Note: See TracChangeset for help on using the changeset viewer.