import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

public class Aufgabe2Test {

    @Test
    public void testEP2() {
        // create three bodies
        Body sun = new Body(SolSystem.SUN);
        Body earth = new Body(SolSystem.EARTH);
        Body mercury = new Body(SolSystem.MERCURY);

        // check basic functions of 'BodyQueue'
        BodyQueue bq = new BodyQueue(2);
        bq.add(mercury);
        bq.add(sun);
        bq.add(earth);
        assertEquals(3, bq.size());

        assertEquals(mercury, bq.poll());
        assertEquals(sun, bq.poll());
        assertEquals(earth, bq.poll());

        assertEquals(0, bq.size());

        bq.add(mercury);
        bq.add(sun);
        assertEquals(2, bq.size());

        // check constructor of 'BodyQueue'
        BodyQueue bqCopy = new BodyQueue(bq);
        assertNotEquals(bq, bqCopy);
        assertEquals(bqCopy.poll(), bq.poll());
        bq.add(earth);
        assertEquals(2, bq.size());
        assertEquals(1, bqCopy.size());

        // check basic functions of 'BodyForceMap'
        BodyForceMap bfm = new BodyForceMap(5);
        bfm.put(earth, earth.gravitationalForce(sun));
        bfm.put(sun, sun.gravitationalForce(earth));

        assertEquals(0, bfm.get(earth).distanceTo(earth.gravitationalForce(sun)));
        assertEquals(0, bfm.get(sun).distanceTo(sun.gravitationalForce(earth)));

        bfm.put(earth, new Vector3(0, 0, 0));
        assertEquals(0, bfm.get(earth).distanceTo(new Vector3(0, 0, 0)));
        assertNull(bfm.get(mercury));
    }
}
