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 InsertTest { @Test public void test1() { test(1); } @Test public void test2() { test(2); } @Test public void testRandom() { test(635); } private void test(Integer numberOfObjectsToAdd) { test(numberOfObjectsToAdd, Person::new); test(numberOfObjectsToAdd, ActionFigure::new); } private void test(Integer numberOfObjectsToAdd, Supplier> supplier) { // Given Group> group = new Group<>(); // when for (int i = 0; i < numberOfObjectsToAdd; i++) { IdentifiableInterface identifiable = supplier.get(); //ID HAS TO BE SET, BECAUSE OF TYPE ERASURE IT CANNOT BE RETRIEVED AT RUNTIME identifiable.setId((TypeOfId) ""); group.insert(identifiable); // then Assert.assertTrue(group.has(identifiable)); } } }