| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package com.zipcodewilmington.generic.group;
-
- import com.zipcodewilmington.generic.identifiables.ActionFigure;
- import com.zipcodewilmington.generic.identifiables.IdentifiableInterface;
- import com.zipcodewilmington.generic.identifiables.Person;
- import org.junit.Assert;
- import org.junit.Test;
-
- import java.io.Serializable;
- import java.util.Random;
- import java.util.function.Supplier;
-
- /**
- * @author leon on 05/12/2018.
- */
- public class DeleteByValueTest {
- @Test
- public void test1() {
- test(1);
- }
-
- @Test
- public void test2() {
- test(2);
- }
-
- @Test
- public void testRandom() {
- test(Math.abs(new Random().nextInt()));
- }
-
- private void test(Integer numberOfObjectsToAdd) {
- test(numberOfObjectsToAdd, Person::new);
- test(numberOfObjectsToAdd, ActionFigure::new);
- }
-
- private <TypeOfId extends Serializable> void test(Integer numberOfObjectsToAdd, Supplier<IdentifiableInterface<TypeOfId>> supplier) {
- // Given
- Group<TypeOfId, IdentifiableInterface<TypeOfId>> group = new Group<>();
-
- // when
- for (int i = 0; i < numberOfObjectsToAdd; i++) {
- IdentifiableInterface<TypeOfId> identifiable = supplier.get();
- group.insert(identifiable);
- group.delete(identifiable);
-
- // then
- Assert.assertFalse(group.has(identifiable));
- }
- }
- }
|