コード例 #1
0
ファイル: SetTest.java プロジェクト: SabinaIdrisova/Homeworks
 /** Test of isEmpty method, of class Set. */
 @Test
 public void testIsEmpty() {
   Set<Integer> set = new Set<Integer>();
   assertTrue(set.isEmpty());
   set.addElement(0);
   assertFalse(set.isEmpty());
 }
コード例 #2
0
  @Test
  public void testRemoveService() {
    ServiceHolder tested = new ServiceHolder();
    Object service = new Object();

    // Get the hash set.
    Set<Object> servicesSet = getField(tested, Set.class);
    servicesSet.add(service);

    tested.removeService(service);

    assertTrue("Set should be empty after removeal.", servicesSet.isEmpty());
  }
コード例 #3
0
 private void checkValue(
     List<BusinessObject.Value> boValues, boolean strict, String name, Object... values) {
   Set<Object> expected = CollectionUtils.newSetFromIterator(Arrays.asList(values).iterator());
   Set<Object> actual = CollectionUtils.newSet();
   for (BusinessObject.Value boValue : boValues) {
     Map<?, ?> data = (Map<?, ?>) boValue.getValue();
     actual.add(data.get(name));
   }
   if (strict) {
     Assert.assertEquals("Values: ", expected, actual);
   } else {
     expected.removeAll(actual);
     Assert.assertTrue("Missing values: " + expected, expected.isEmpty());
   }
 }