@SuppressWarnings("unchecked") @Test public void getHashMapTest() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { HashMap<String, String> map = new HashMap<String, String>(); map.put("nom", "test_nom"); map.put("num_dossier", "123"); map.put("num_instruction", "12"); map.put("num_parquet", "42"); DateFormat db = new SimpleDateFormat("yyyy-MM-dd"); map.put("date_ordre", db.format(new Date(0))); map.put("date_rendu", db.format(new Date(0))); map.put("delai", "0"); map.put("comment", "test_comment"); map.put("id_enqueteur", "0"); // La methode getHashMap est private, on passe donc par la reflection Method method = a.getClass().getDeclaredMethod("getHashMap"); method.setAccessible(true); HashMap<String, String> mapToCompare = (HashMap<String, String>) method.invoke(a); assertEquals(mapToCompare.toString(), map.toString()); }