### Question:
Shard { public void clearData() { dataStore.clear(); } Shard(final int id); void storeData(Data data); void clearData(); Data getDataById(final int id); int getId();  }### Answer:
@Test public void testClearData() { try { var dataMap = new HashMap<Integer, Data>(); dataMap.put(1, data); var field = Shard.class.getDeclaredField("dataStore"); field.setAccessible(true); field.set(shard, dataMap); shard.clearData(); dataMap = (HashMap<Integer, Data>) field.get(shard); Assert.assertEquals(0, dataMap.size()); } catch (NoSuchFieldException | IllegalAccessException e) { Assert.fail("Fail to modify field access."); } }