Changeset 2 for issuevalue/src/test
- Timestamp:
- 08/28/19 11:35:52 (5 years ago)
- Location:
- issuevalue/src/test/java/geniusweb/issuevalue
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issuevalue/src/test/java/geniusweb/issuevalue/DomainTest.java
r1 r2 21 21 import com.fasterxml.jackson.databind.ObjectMapper; 22 22 23 import geniusweb.issuevalue.Bid;24 import geniusweb.issuevalue.DiscreteValue;25 import geniusweb.issuevalue.DiscreteValueSet;26 import geniusweb.issuevalue.Domain;27 import geniusweb.issuevalue.NumberValue;28 import geniusweb.issuevalue.NumberValueSet;29 import geniusweb.issuevalue.ValueSet;30 23 import tudelft.utilities.junit.GeneralTests; 31 24 … … 38 31 private static final String ISSUE3 = "issue3"; 39 32 private static final ObjectMapper jackson = new ObjectMapper(); 40 private static final String domainstring = "{\"name\":\"testdomain\",\"issuesValues\":{\"issue2\":{\"range\":[ \"2\",\"3\",\"0.22\"]},\"issue1\":{\"values\":[\"i1v1\",\"i1v2\"]}}}";33 private static final String domainstring = "{\"name\":\"testdomain\",\"issuesValues\":{\"issue2\":{\"range\":[2,3,0.22]},\"issue1\":{\"values\":[\"i1v1\",\"i1v2\"]}}}"; 41 34 42 private static final String jobsstring = "{\"name\":\"jobs\"," 43 + "\"issuesValues\":{" 44 + "\"lease car\":{\"values\":[\"yes\",\"no\"]}," 45 + "\"permanent contract\":{\"values\":[\"yes\",\"no\"]}," 35 private static final String jobsstring = "{\"name\":\"jobs\"," + "\"issuesValues\":{" 36 + "\"lease car\":{\"values\":[\"yes\",\"no\"]}," + "\"permanent contract\":{\"values\":[\"yes\",\"no\"]}," 46 37 + "\"career development opportunities\":{\"values\":[\"low\",\"medium\",\"high\"]}," 47 38 + "\"fte\":{\"values\":[\"0.6\",\"0.8\",\"1.0\"]}," … … 73 64 Map<String, ValueSet> issues1 = new HashMap<>(); 74 65 issues1.put(ISSUE1, values1); 75 issues1.put(ISSUE2, new NumberValueSet(BigDecimal.ONE, TWO, 76 new BigDecimal("0.22"))); 66 issues1.put(ISSUE2, new NumberValueSet(BigDecimal.ONE, TWO, new BigDecimal("0.22"))); 77 67 domain3 = new Domain(DOMAINNAME, issues1); 78 68 … … 81 71 @Override 82 72 public List<List<Domain>> getGeneralTestData() { 83 return Arrays.asList(Arrays.asList(domain, domain1), 84 Arrays.asList(domain2), Arrays.asList(domain3)); 73 return Arrays.asList(Arrays.asList(domain, domain1), Arrays.asList(domain2), Arrays.asList(domain3)); 85 74 } 86 75 87 76 @Override 88 77 public List<String> getGeneralTestStrings() { 89 return Arrays.asList("Domain.*testdomain.*", "Domain.*testdomain1.*", 90 "Domain.*testdomain.*"); 78 return Arrays.asList("Domain.*testdomain.*", "Domain.*testdomain1.*", "Domain.*testdomain.*"); 91 79 } 92 80 … … 109 97 System.out.println(jobsstring); 110 98 Domain jobsdomain = jackson.readValue(jobsstring, Domain.class); 111 assertEquals(new HashSet<>(Arrays.asList("lease car", 112 "permanent contract", "career development opportunities", "fte", 113 "salary", "work from home")), jobsdomain.getIssues()); 99 assertEquals(new HashSet<>(Arrays.asList("lease car", "permanent contract", "career development opportunities", 100 "fte", "salary", "work from home")), jobsdomain.getIssues()); 114 101 115 102 } … … 134 121 public void testIsCompleteNoIssuesDefined() { 135 122 Bid bid = mock(Bid.class); 136 assertThat(domain.isComplete(bid), new PatternMatch( 137 "Issues in bid .* do not match issues in domain .*")); 123 assertThat(domain.isComplete(bid), new PatternMatch("Issues in bid .* do not match issues in domain .*")); 138 124 } 139 125 … … 154 140 // THREE is NOT a possible value in the NumberValueSet. 155 141 when(bid.getValue(ISSUE2)).thenReturn(new NumberValue(THREE)); 156 assertThat(domain.isComplete(bid), 157 new PatternMatch("bid issue issue2 has illegal value 3")); 142 assertThat(domain.isComplete(bid), new PatternMatch("bid issue issue2 has illegal value 3")); 158 143 } 159 144 … … 167 152 // THREE is NOT a possible value in the NumberValueSet. 168 153 when(bid.getValue(ISSUE2)).thenReturn(new NumberValue(THREE)); 169 assertThat(domain.isComplete(bid), new PatternMatch( 170 "Issues in bid .* do not match issues in domain .*")); 154 assertThat(domain.isComplete(bid), new PatternMatch("Issues in bid .* do not match issues in domain .*")); 171 155 } 172 156 -
issuevalue/src/test/java/geniusweb/issuevalue/NumberValueSetTest.java
r1 r2 16 16 import com.fasterxml.jackson.databind.ObjectMapper; 17 17 18 import geniusweb.issuevalue.NumberValue;19 import geniusweb.issuevalue.NumberValueSet;20 import geniusweb.issuevalue.ValueSet;21 18 import tudelft.utilities.immutablelist.Range; 22 19 … … 33 30 new BigDecimal("0.1")); 34 31 35 private final String asString = "{\"range\":[ \"12.2\",\"12.6\",\"0.3\"]}";32 private final String asString = "{\"range\":[12.2,12.6,0.3]}"; 36 33 private final static NumberValueSet bigset = new NumberValueSet(BigDecimal.ZERO, BigDecimal.TEN, 37 34 new BigDecimal("0.00003"));
Note:
See TracChangeset
for help on using the changeset viewer.