import org.junit.jupiter.api.Test;

import java.util.NoSuchElementException;

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

public class Aufgabe8Test {

    @Test
    public void testEP2() {
        MassiveForceTreeMap map = new MassiveForceTreeMap();
        NamedBody mars;

        map.put(new NamedBody("Oumuamua", 8e6, new Vector3(), new Vector3()), new Vector3());
        map.put(new NamedBody("Earth", 5.972E24, new Vector3(), new Vector3()), new Vector3());
        map.put(new NamedBody("Moon", 7.349E22, new Vector3(), new Vector3()), new Vector3());
        map.put(mars = new NamedBody("Mars", 6.41712E23, new Vector3(), new Vector3()), new Vector3());
        map.put(new NamedBody("Deimos", 1.8E20, new Vector3(), new Vector3()), new Vector3());
        map.put(new NamedBody("Phobos", 1.08E20, new Vector3(), new Vector3()), new Vector3());
        map.put(new NamedBody("Mercury", 3.301E23, new Vector3(), new Vector3()), new Vector3());
        map.put(new NamedBody("Venus", 4.86747E24, new Vector3(), new Vector3()), new Vector3());
        map.put(new NamedBody("Vesta", 2.5908E20, new Vector3(), new Vector3()), new Vector3());
        map.put(new NamedBody("Pallas", 2.14E20, new Vector3(), new Vector3()), new Vector3());
        map.put(new NamedBody("Hygiea", 8.32E19, new Vector3(), new Vector3()), new Vector3());
        map.put(new NamedBody("Ceres", 9.394E20, new Vector3(), new Vector3()), new Vector3());

        assertEquals(12, map.size());

        MassiveIterator iterator = map.getKeys().iterator();
        int count;
        for (count = 0; iterator.hasNext(); count++) {
            if (iterator.next().equals(mars)) {
                iterator.remove();
            }
        }
        assertEquals(12, count);
        assertEquals(11, map.getKeys().size());
        assertEquals(11, map.size());
        assertFalse(map.getKeys().contains(mars));

        assertThrows(NoSuchElementException.class, iterator::next);

        iterator = map.getKeys().iterator();
        while (iterator.hasNext()) {
            iterator.next();
            iterator.remove();
        }
        assertEquals(0, map.getKeys().size());
    }
}
