@@ -0,0 +1,2153 @@
+package org.sagebionetworks.web.unitclient.widget.search;%0A%0Aimport static org.junit.Assert.*;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport static org.mockito.Mockito.*;%0Aimport org.sagebionetworks.web.client.GlobalApplicationState;%0Aimport org.sagebionetworks.web.client.PlaceChanger;%0Aimport org.sagebionetworks.web.client.SynapseClientAsync;%0Aimport org.sagebionetworks.web.client.place.Search;%0Aimport org.sagebionetworks.web.client.place.Synapse;%0Aimport org.sagebionetworks.web.client.widget.search.HomeSearchBox;%0Aimport org.sagebionetworks.web.test.helper.AsyncMockStubber;%0A%0Aimport com.google.gwt.place.shared.Place;%0Aimport com.google.gwt.user.client.rpc.AsyncCallback;%0A%0Apublic class HomeSearchBoxTest %7B%0A%0A%09private GlobalApplicationState mockGlobalAppState;%0A%09private PlaceChanger mockPlaceChanger;%0A%09private SynapseClientAsync mockSynapseClient;%0A%09%0A%09@Before%0A%09public void before() %7B%0A%09%09mockGlobalAppState = mock(GlobalApplicationState.class);%0A%09%09mockPlaceChanger = mock(PlaceChanger.class);%0A%09%09mockSynapseClient = mock(SynapseClientAsync.class);%0A%09%09when(mockGlobalAppState.getPlaceChanger()).thenReturn(mockPlaceChanger);%0A%09%09AsyncMockStubber.callSuccessWith(null).when(mockSynapseClient).getEntity(anyString(), any(AsyncCallback.class));%0A%09%7D%0A%09%0A%09@Test%0A%09public void testSearchForTerm() %7B%0A%09%09//search for something that does not look like a Synapse ID%0A%09%09HomeSearchBox.searchForTerm(%22not_an_id%22, mockGlobalAppState, mockSynapseClient);%0A%09%09verify(mockPlaceChanger).goTo(any(Search.class));%0A%09%7D%0A%09%0A%09@Test%0A%09public void testSearchForSynId() %7B%0A%09%09//mocking successful verification of the syn id, should change to Synapse entity place%0A%09%09HomeSearchBox.searchForTerm(%22syn123%22, mockGlobalAppState, mockSynapseClient);%0A%09%09verify(mockPlaceChanger).goTo(any(Synapse.class));%0A%09%7D%0A%09%0A%09@Test%0A%09public void testSearchForInvalidSynId() %7B%0A%09%09//mocking failed verification of the syn id, should change to Search place%0A%09%09AsyncMockStubber.callFailureWith(new Exception()).when(mockSynapseClient).getEntity(anyString(), any(AsyncCallback.class));%0A%09%09HomeSearchBox.searchForTerm(%22syn123%22, mockGlobalAppState, mockSynapseClient);%0A%09%09verify(mockPlaceChanger).goTo(any(Search.class));%0A%09%7D%0A%7D%0A%0A%0A%0A%0A%0A

add new test around HomeSearchBox