### Question:
MetaDataEditorFieldRenderer extends FieldRenderer<MetaDataEditorFieldDefinition, DefaultFormGroup> implements MetaDataEditorWidgetView.Presenter { @Override public boolean isDuplicateAttribute(final String attribute) { if (attribute == null || attribute.trim().isEmpty()) { return false; } List<MetaDataRow> as = view.getMetaDataRows(); if (as != null && !as.isEmpty()) { int nameCount = 0; String currName = attribute.trim(); for (MetaDataRow row : as) { String rowName = row.getAttribute(); if (rowName != null && currName.compareTo(rowName.trim()) == 0) { nameCount++; if (nameCount > 1) { return true; } } } } return false; } @Inject  MetaDataEditorFieldRenderer(final MetaDataEditorWidgetView metaDataEditor,
                                       final SessionManager sessionManager,
                                       final ErrorPopupPresenter errorPopupPresenter,
                                       final Event<NotificationEvent> notification); @Override String getName(); @Override void doSave(); @Override void addAttribute(); @Override void notifyModelChanged(); @Override List<MetaDataRow> deserializeMetaDataAttributes(final String s); @Override String serializeMetaDataAttributes(final List<MetaDataRow> metaDataRows); @Override boolean isDuplicateAttribute(final String attribute); @Override void removeMetaData(final MetaDataRow metaDataRow); @Override Path getDiagramPath(); @Override void showErrorMessage(String message);  }### Answer:
@Test public void testIsDuplicateAttribute() { List<MetaDataRow> metaDataRows = new ArrayList<>(); metaDataRows.add(new MetaDataRow("att1", "val1")); metaDataRows.add(new MetaDataRow("att2", "val2")); metaDataRows.add(new MetaDataRow("att3", "val3,val4")); metaDataRows.add(new MetaDataRow("att2", "val2")); metaDataRows.add(new MetaDataRow(null, "Object")); metaDataRows.add(new MetaDataRow(null, null)); when(metaDataEditorWidgetView.getMetaDataRows()).thenReturn(metaDataRows); assertTrue(metaDataEditor.isDuplicateAttribute("att2")); assertFalse(metaDataEditor.isDuplicateAttribute("att1")); }
@Test public void testIsDuplicateAttributeNullOrEmpty() { assertFalse(metaDataEditor.isDuplicateAttribute(null)); assertFalse(metaDataEditor.isDuplicateAttribute(" ")); }
@Test public void testIsDuplicateRowsNull() { when(metaDataEditorWidgetView.getMetaDataRows()).thenReturn(null); assertFalse(metaDataEditor.isDuplicateAttribute("test")); }
@Test public void testIsDuplicateRowsEmpty() { when(metaDataEditorWidgetView.getMetaDataRows()).thenReturn(new ArrayList<>()); assertFalse(metaDataEditor.isDuplicateAttribute("test")); }