ImageMetaData { public void add(Map<String, String> labels2) { if (this.labels == null) { this.labels = new ArrayList<>(); this.labels.add(labels2); } else { this.labels.get(0).putAll(labels2); } } ImageMetaData();  ImageMetaData(List<Map<String, String>> labels); List<Map<String, String>> getLabels(); void setLabels(List<Map<String, String>> labels); void add(Map<String, String> labels2); @Override String toString(); final static String LABEL_PREFIX; }
@Test public void add() { final ImageMetaData imageMetaData = new ImageMetaData(); final Map<String, String> labels = new HashMap<>(); labels.put("firstLabelsKey1", "firstLabelsValue1"); imageMetaData.add(labels); final Map<String, String> secondLabels = new HashMap<>(); secondLabels.put("secondLabelsKey1", "secondLabelsValue1"); imageMetaData.add(secondLabels); assertThat(imageMetaData.getLabels()).isNotNull(); assertThat(imageMetaData.getLabels()).hasSize(1); labels.putAll(secondLabels); assertThat(imageMetaData.getLabels().get(0)).hasSize(2); assertThat(imageMetaData.getLabels().get(0)).containsAllEntriesOf(labels); }