Changeset 9 for profile/src/test/java


Ignore:
Timestamp:
11/28/19 14:40:48 (5 years ago)
Author:
bart
Message:

Release 1.1.0

Location:
profile/src/test/java/geniusweb/profile/utilityspace
Files:
3 added
3 edited

Legend:

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

    r7 r9  
    33import static org.junit.Assert.assertEquals;
    44import static org.junit.Assert.assertFalse;
     5import static org.junit.Assert.assertTrue;
    56
    67import java.io.IOException;
     
    8182        @Override
    8283        public List<String> getGeneralTestStrings() {
    83                 return Arrays.asList("ValueSetUtilities\\{\"a\"=0.14\\}",
    84                                 "ValueSetUtilities\\{\"b\"=0.37\\}",
    85                                 "ValueSetUtilities\\{\"a\"=0.37\\}",
    86                                 "ValueSetUtilities\\{\"a\"=0.14, \"b\"=0.37\\}");
     84                return Arrays.asList("DiscreteValueSetUtilities\\{\"a\"=0.14\\}",
     85                                "DiscreteValueSetUtilities\\{\"b\"=0.37\\}",
     86                                "DiscreteValueSetUtilities\\{\"a\"=0.37\\}",
     87                                "DiscreteValueSetUtilities\\{\"a\"=0.14, \"b\"=0.37\\}");
    8788        }
    8889
     
    200201
    201202        }
     203
     204        @Test
     205        public void testDeserializeAsDiscrete()
     206                        throws JsonParseException, JsonMappingException, IOException {
     207                // Check that DiscreteValueSetUtilities properly deserializes
     208                // discreteutils.
     209                String utilstring = "{\"discreteutils\": {\"valueUtilities\": {\"Party Tent\": 0.52,\"Your Dorm\": 0.23,\"Party Room\": 0.99,\"Ballroom\": 0.77}}}";
     210                DiscreteValueSetUtilities valueutils = jackson.readValue(utilstring,
     211                                DiscreteValueSetUtilities.class);
     212                assertTrue(new BigDecimal("0.23").compareTo(
     213                                valueutils.getUtility(new DiscreteValue("Your Dorm"))) == 0);
     214
     215        }
     216
    202217}
  • profile/src/test/java/geniusweb/profile/utilityspace/LinearAdditiveTest.java

    r7 r9  
    2020
    2121import com.fasterxml.jackson.databind.ObjectMapper;
    22 import com.fasterxml.jackson.databind.exc.InvalidDefinitionException;
    2322
    2423import geniusweb.issuevalue.Bid;
     
    145144        public List<String> getGeneralTestStrings() {
    146145                return Arrays.asList(
    147                                 "LinearAdditive\\[\\{issue2=ValueSetUtilities\\{\"issue2value2\"=0.8, \"issue2value1\"=0.6\\}, issue1=ValueSetUtilities\\{\"issue1value1\"=0.3, \"issue1value2\"=0.2\\}\\},\\{issue2=0.6, issue1=0.4\\},Bid\\{issue2=\"issue2value1\", issue1=\"issue1value2\"\\}\\]",
    148                                 "LinearAdditive\\[\\{issue2=ValueSetUtilities\\{\"issue2value2\"=0.8, \"issue2value1\"=0.6\\}, issue1=ValueSetUtilities\\{\"issue1value1\"=0.3, \"issue1value2\"=0.2\\}\\},\\{issue2=0.7, issue1=0.3\\},Bid\\{issue2=\"issue2value1\", issue1=\"issue1value2\"\\}\\]",
    149                                 "LinearAdditive\\[\\{issue2=ValueSetUtilities\\{\"issue2value2\"=0.2, \"issue2value1\"=0.3\\}, issue1=ValueSetUtilities\\{\"issue1value1\"=0.6, \"issue1value2\"=0.8\\}\\},\\{issue2=0.6, issue1=0.4\\},Bid\\{issue2=\"issue2value1\", issue1=\"issue1value2\"\\}\\]",
    150                                 "LinearAdditive\\[\\{issue2=ValueSetUtilities\\{\"issue2value2\"=0.2, \"issue2value1\"=0.3\\}, issue1=ValueSetUtilities\\{\"issue1value1\"=0.6, \"issue1value2\"=0.8\\}\\},\\{issue2=0.6, issue1=0.4\\},Bid\\{issue2=\"issue2value1\", issue1=\"issue1value1\"\\}\\]");
     146                                "LinearAdditive\\[\\{issue2=DiscreteValueSetUtilities\\{\"issue2value2\"=0.8, \"issue2value1\"=0.6\\}, issue1=DiscreteValueSetUtilities\\{\"issue1value1\"=0.3, \"issue1value2\"=0.2\\}\\},\\{issue2=0.6, issue1=0.4\\},Bid\\{issue2=\"issue2value1\", issue1=\"issue1value2\"\\}\\]",
     147                                "LinearAdditive\\[\\{issue2=DiscreteValueSetUtilities\\{\"issue2value2\"=0.8, \"issue2value1\"=0.6\\}, issue1=DiscreteValueSetUtilities\\{\"issue1value1\"=0.3, \"issue1value2\"=0.2\\}\\},\\{issue2=0.7, issue1=0.3\\},Bid\\{issue2=\"issue2value1\", issue1=\"issue1value2\"\\}\\]",
     148                                "LinearAdditive\\[\\{issue2=DiscreteValueSetUtilities\\{\"issue2value2\"=0.2, \"issue2value1\"=0.3\\}, issue1=DiscreteValueSetUtilities\\{\"issue1value1\"=0.6, \"issue1value2\"=0.8\\}\\},\\{issue2=0.6, issue1=0.4\\},Bid\\{issue2=\"issue2value1\", issue1=\"issue1value2\"\\}\\]",
     149                                "LinearAdditive\\[\\{issue2=DiscreteValueSetUtilities\\{\"issue2value2\"=0.2, \"issue2value1\"=0.3\\}, issue1=DiscreteValueSetUtilities\\{\"issue1value1\"=0.6, \"issue1value2\"=0.8\\}\\},\\{issue2=0.6, issue1=0.4\\},Bid\\{issue2=\"issue2value1\", issue1=\"issue1value1\"\\}\\]");
    151150        }
    152151
     
    271270        }
    272271
    273         @Test(expected = InvalidDefinitionException.class)
     272        @Test
    274273        public void loadFullWithJson() throws IOException {
    275274                String profile = new String(
  • profile/src/test/java/geniusweb/profile/utilityspace/NumberValueSetUtilTest.java

    r3 r9  
    4444        @Override
    4545        public List<String> getGeneralTestStrings() {
    46                 return Arrays.asList("NumberValUtility\\(12.5->0.5,18.5->0.9\\)",
    47                                 "NumberValUtility\\(12.5->0.6,18.5->0.9\\)",
    48                                 "NumberValUtility\\(12.5->0.5,18.4->0.9\\)");
     46                return Arrays.asList("NumberValueSetUtilities\\(12.5->0.5,18.5->0.9\\)",
     47                                "NumberValueSetUtilities\\(12.5->0.6,18.5->0.9\\)",
     48                                "NumberValueSetUtilities\\(12.5->0.5,18.4->0.9\\)");
    4949        }
    5050
Note: See TracChangeset for help on using the changeset viewer.