@@ -0,0 +1,2611 @@
+package org.sagebionetworks.web.unitclient.widget.entity.editor;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertFalse;%0Aimport static org.mockito.Mockito.verify;%0Aimport static org.mockito.Mockito.when;%0A%0Aimport java.util.Map;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.mockito.Mock;%0Aimport org.mockito.MockitoAnnotations;%0Aimport org.sagebionetworks.web.client.widget.entity.dialog.DialogCallback;%0Aimport org.sagebionetworks.web.client.widget.entity.editor.ButtonLinkConfigEditor;%0Aimport org.sagebionetworks.web.client.widget.entity.editor.ButtonLinkConfigView;%0Aimport org.sagebionetworks.web.shared.WebConstants;%0Aimport org.sagebionetworks.web.shared.WidgetConstants;%0Aimport org.sagebionetworks.web.shared.WikiPageKey;%0A%0Aimport com.google.gwt.dev.util.collect.HashMap;%0A%0Apublic class ButtonLinkConfigEditorTest %7B%0A%09%09%0A%09ButtonLinkConfigEditor editor;%0A%09@Mock%0A%09ButtonLinkConfigView mockView;%0A%09@Mock%0A%09WikiPageKey mockWikiPageKey;%0A%09@Mock%0A%09DialogCallback mockDialogCallback;%0A%09Map%3CString, String%3E widgetDescriptor;%0A%09%0A%09@Before%0A%09public void setup()%7B%0A%09%09MockitoAnnotations.initMocks(this);%0A%09%09editor = new ButtonLinkConfigEditor(mockView);%0A%09%09widgetDescriptor = new HashMap%3C%3E();%0A%09%09editor.configure(mockWikiPageKey, widgetDescriptor, mockDialogCallback);%0A%09%7D%0A%09%0A%09@Test%0A%09public void testAsWidget() %7B%0A%09%09editor.asWidget();%0A%09%09verify(mockView).asWidget();%0A%09%7D%0A%09%0A%09@Test%0A%09public void testConfigure() %7B%0A%09%09verify(mockView).configure(mockWikiPageKey, widgetDescriptor);%0A%09%7D%0A%09%0A%09@Test%0A%09public void testUpdateDescriptorFromViewNoHighlight() %7B%0A%09%09String buttonText = %22a button%22;%0A%09%09String url = %22a url%22;%0A%09%09boolean isHighlight = false;%0A%09%09when(mockView.getName()).thenReturn(buttonText);%0A%09%09when(mockView.getLinkUrl()).thenReturn(url);%0A%09%09when(mockView.isHighlightButtonStyle()).thenReturn(isHighlight);%0A%09%09String oldKeyValue = %22garbage%22;%0A%09%09widgetDescriptor.put(oldKeyValue, oldKeyValue);%0A%09%09%0A%09%09editor.updateDescriptorFromView();%0A%09%09%0A%09%09verify(mockView).checkParams();%0A%09%09// verify old key values have been cleared%0A%09%09assertFalse(widgetDescriptor.containsKey(oldKeyValue));%0A%09%09assertEquals(buttonText, widgetDescriptor.get(WidgetConstants.TEXT_KEY));%0A%09%09assertEquals(url, widgetDescriptor.get(WidgetConstants.LINK_URL_KEY));%0A%09%09assertFalse(widgetDescriptor.containsKey(WebConstants.HIGHLIGHT_KEY));%0A%09%7D%0A%09%0A%09@Test%0A%09public void testUpdateDescriptorFromViewWithButtonHighlight() %7B%0A%09%09boolean isHighlight = true;%0A%09%09when(mockView.isHighlightButtonStyle()).thenReturn(isHighlight);%0A%09%09%0A%09%09editor.updateDescriptorFromView();%0A%09%09%0A%09%09assertEquals(Boolean.toString(true), widgetDescriptor.get(WebConstants.HIGHLIGHT_KEY));%0A%09%7D%0A%7D%0A

add unit tests for ButtonLinkConfigEditor