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 HasByIdTest { @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 void test(Integer numberOfObjectsToAdd, Supplier> supplier) { // Given Group> group = new Group<>(); // when for (int i = 0; i < numberOfObjectsToAdd; i++) { IdentifiableInterface identifiable = supplier.get(); group.insert(identifiable); // then Assert.assertFalse(group.has(identifiable.getIdentity())); } } }