Skip to content

Commit

Permalink
Test onShowOperationalAreaSelector shows error
Browse files Browse the repository at this point in the history
should show when extractLocationHierarchy returns null
linked to #1226
  • Loading branch information
LZRS committed Apr 6, 2021
1 parent bb1783d commit 04f8571
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private void populateLocationsFromPreferences() {
@Override
public void onShowOperationalAreaSelector() {
Pair<String, ArrayList<String>> locationHierarchy = extractLocationHierarchy();
if (locationHierarchy == null) {//try to evict location hierachy in cache
if (locationHierarchy == null) {//try to evict location hierarchy in cache
revealApplication.getContext().anmLocationController().evict();
locationHierarchy = extractLocationHierarchy();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
Expand Down Expand Up @@ -86,7 +88,7 @@ public class BaseDrawerPresenterTest extends BaseUnitTest {
private ArgumentCaptor<String> entireTreeString;

@Captor
private ArgumentCaptor<ArrayList<String>> arrayListArgumentCaptor;
private ArgumentCaptor<List<String>> arrayListArgumentCaptor;

@Captor
private ArgumentCaptor<Pair<String, ArrayList<String>>> pairArgumentCaptor;
Expand Down Expand Up @@ -298,7 +300,7 @@ public void testOnViewResumedWithViewInitialized() {
}

@Test
public void testIsChangedCurrentSelectio() {
public void testIsChangedCurrentSelection() {
Whitebox.setInternalState(presenter, "changedCurrentSelection", true);

boolean actualIsChangedCurrentSelection = presenter.isChangedCurrentSelection();
Expand All @@ -307,7 +309,7 @@ public void testIsChangedCurrentSelectio() {
}

@Test
public void testSetChangedCurrentSelectio() {
public void testSetChangedCurrentSelection() {
assertFalse(Whitebox.getInternalState(presenter, "changedCurrentSelection"));

presenter.setChangedCurrentSelection(true);
Expand All @@ -316,7 +318,7 @@ public void testSetChangedCurrentSelectio() {
}

@Test
public void testOnDraweClosed() {
public void testOnDrawerClosed() {
presenter.onDrawerClosed();
verify(drawerActivity).onDrawerClosed();
}
Expand Down Expand Up @@ -350,6 +352,16 @@ public void testOnPlanSelectorClicked() {
assertTrue(Whitebox.getInternalState(presenter, "changedCurrentSelection"));
}

@Test
public void testOnShowOperationalAreaSelectorNullShowsErrorProcessingHierarchy(){
Whitebox.setInternalState(presenter, "locationHelper", locationHelper);
when(locationHelper.generateDefaultLocationHierarchy(anyList()))
.thenReturn(null);
presenter.onShowOperationalAreaSelector();
verify(locationHelper, times(2)).generateDefaultLocationHierarchy(anyList());
verify(view).displayNotification(eq(R.string.error_fetching_location_hierarchy_title), eq(R.string.error_fetching_location_hierarchy));
}

@Test
public void testOnShowOperationalAreaSelector() {
when(preferencesUtil.getPreferenceValue(anyString())).thenReturn("akros_1");
Expand Down

0 comments on commit 04f8571

Please sign in to comment.