use of com.canoo.dp.impl.platform.core.IdentitySet in project dolphin-platform by canoo.
the class IdentitySetTest method testSize.
@Test
public void testSize() {
IdentitySet<Date> identitySet = new IdentitySet<>();
Date date1 = new Date();
Date date2 = new Date(date1.getTime());
Assert.assertTrue(identitySet.isEmpty());
Assert.assertEquals(identitySet.size(), 0);
identitySet.add(date1);
Assert.assertFalse(identitySet.isEmpty());
Assert.assertEquals(identitySet.size(), 1);
identitySet.add(date2);
Assert.assertFalse(identitySet.isEmpty());
Assert.assertEquals(identitySet.size(), 2);
identitySet.remove(date2);
Assert.assertFalse(identitySet.isEmpty());
Assert.assertEquals(identitySet.size(), 1);
identitySet.clear();
Assert.assertTrue(identitySet.isEmpty());
Assert.assertEquals(identitySet.size(), 0);
}
use of com.canoo.dp.impl.platform.core.IdentitySet in project dolphin-platform by canoo.
the class IdentitySetTest method testAddAll.
@Test
public void testAddAll() {
IdentitySet<Date> identitySet = new IdentitySet<>();
Date date1 = new Date();
Date date2 = new Date(date1.getTime());
identitySet.addAll(Arrays.asList(date1, date2));
Assert.assertEquals(identitySet.size(), 2);
Assert.assertTrue(identitySet.contains(date1));
Assert.assertTrue(identitySet.contains(date2));
}
use of com.canoo.dp.impl.platform.core.IdentitySet in project dolphin-platform by canoo.
the class IdentitySetTest method testIterator.
@Test
public void testIterator() {
IdentitySet<Date> identitySet = new IdentitySet<>();
Date date1 = new Date();
Date date2 = new Date(date1.getTime());
identitySet.add(date1);
identitySet.add(date2);
Iterator<Date> iterator = identitySet.iterator();
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals(iterator.next(), date1);
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals(iterator.next(), date2);
Assert.assertFalse(iterator.hasNext());
}
use of com.canoo.dp.impl.platform.core.IdentitySet in project dolphin-platform by canoo.
the class IdentitySetTest method testContains.
@Test
public void testContains() {
IdentitySet<Date> identitySet = new IdentitySet<>();
Date date1 = new Date();
Date date2 = new Date(date1.getTime());
Assert.assertFalse(identitySet.contains(date1));
Assert.assertFalse(identitySet.contains(date2));
Assert.assertTrue(identitySet.containsAll(new ArrayList<>()));
Assert.assertFalse(identitySet.containsAll(Arrays.asList(date1)));
Assert.assertFalse(identitySet.containsAll(Arrays.asList(date2)));
Assert.assertFalse(identitySet.containsAll(Arrays.asList(date1, date2)));
Assert.assertFalse(identitySet.containsAll(Arrays.asList(date2, date1)));
identitySet.add(date1);
Assert.assertTrue(identitySet.contains(date1));
Assert.assertFalse(identitySet.contains(date2));
Assert.assertTrue(identitySet.containsAll(new ArrayList<>()));
Assert.assertTrue(identitySet.containsAll(Arrays.asList(date1)));
Assert.assertFalse(identitySet.containsAll(Arrays.asList(date2)));
Assert.assertFalse(identitySet.containsAll(Arrays.asList(date1, date2)));
Assert.assertFalse(identitySet.containsAll(Arrays.asList(date2, date1)));
identitySet.add(date2);
Assert.assertTrue(identitySet.contains(date1));
Assert.assertTrue(identitySet.contains(date2));
Assert.assertTrue(identitySet.containsAll(new ArrayList<>()));
Assert.assertTrue(identitySet.containsAll(Arrays.asList(date1)));
Assert.assertTrue(identitySet.containsAll(Arrays.asList(date2)));
Assert.assertTrue(identitySet.containsAll(Arrays.asList(date1, date2)));
Assert.assertTrue(identitySet.containsAll(Arrays.asList(date2, date1)));
identitySet.remove(date2);
Assert.assertTrue(identitySet.contains(date1));
Assert.assertFalse(identitySet.contains(date2));
Assert.assertTrue(identitySet.containsAll(new ArrayList<>()));
Assert.assertTrue(identitySet.containsAll(Arrays.asList(date1)));
Assert.assertFalse(identitySet.containsAll(Arrays.asList(date2)));
Assert.assertFalse(identitySet.containsAll(Arrays.asList(date1, date2)));
Assert.assertFalse(identitySet.containsAll(Arrays.asList(date2, date1)));
identitySet.clear();
Assert.assertFalse(identitySet.contains(date1));
Assert.assertFalse(identitySet.contains(date2));
Assert.assertTrue(identitySet.containsAll(new ArrayList<>()));
Assert.assertFalse(identitySet.containsAll(Arrays.asList(date1)));
Assert.assertFalse(identitySet.containsAll(Arrays.asList(date2)));
Assert.assertFalse(identitySet.containsAll(Arrays.asList(date1, date2)));
Assert.assertFalse(identitySet.containsAll(Arrays.asList(date2, date1)));
}
use of com.canoo.dp.impl.platform.core.IdentitySet in project dolphin-platform by canoo.
the class IdentitySetTest method testWithDate.
@Test
public void testWithDate() {
// given:
final IdentitySet<Date> set = new IdentitySet<>();
final long time = System.currentTimeMillis();
final Date date1 = new Date(time);
final Date date2 = new Date(time);
final Date date3 = new Date(time + 1);
// when:
set.add(date1);
set.add(date2);
set.add(date3);
// then:
Assert.assertEquals(set.size(), 3);
}
Aggregations