Search in sources :

Example 6 with IdentitySet

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);
}
Also used : IdentitySet(com.canoo.dp.impl.platform.core.IdentitySet) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 7 with IdentitySet

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));
}
Also used : IdentitySet(com.canoo.dp.impl.platform.core.IdentitySet) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 8 with IdentitySet

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());
}
Also used : IdentitySet(com.canoo.dp.impl.platform.core.IdentitySet) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 9 with IdentitySet

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)));
}
Also used : IdentitySet(com.canoo.dp.impl.platform.core.IdentitySet) ArrayList(java.util.ArrayList) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 10 with IdentitySet

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);
}
Also used : IdentitySet(com.canoo.dp.impl.platform.core.IdentitySet) Date(java.util.Date) Test(org.testng.annotations.Test)

Aggregations

IdentitySet (com.canoo.dp.impl.platform.core.IdentitySet)11 Date (java.util.Date)9 Test (org.testng.annotations.Test)9 Field (java.lang.reflect.Field)2 ObservableList (com.canoo.platform.remoting.ObservableList)1 Property (com.canoo.platform.remoting.Property)1 ArrayList (java.util.ArrayList)1