### Question:
CyclicList { synchronized public T add(T e) { T oldEle = container[pointer]; container[pointer++] = e; if (pointer >= capacity) { pointer = 0; } return oldEle; } @SuppressWarnings("unchecked")  CyclicList(int capacity); synchronized T add(T e); @SuppressWarnings("unchecked") synchronized List<T> takeAll();  }### Answer:
@Test public void testAdd() { CyclicList<MasterHeartBeat.STATUS> list = new CyclicList<>(20); list.add(MasterHeartBeat.STATUS.SUCCESS); list.add(MasterHeartBeat.STATUS.SUCCESS); list.add(MasterHeartBeat.STATUS.SUCCESS); list.add(MasterHeartBeat.STATUS.FAILED); list.add(MasterHeartBeat.STATUS.FAILED); list.add(MasterHeartBeat.STATUS.FAILED); List<MasterHeartBeat.STATUS> contents = list.takeAll(); Assert.assertEquals(contents.size(), 6); Assert.assertEquals(contents.get(0), MasterHeartBeat.STATUS.SUCCESS); Assert.assertEquals(contents.get(5), MasterHeartBeat.STATUS.FAILED); }