@Test
public void shouldSetTheMenuBasedOnAsynTask() throws IOException {

    RapidFtrApplication instance = RapidFtrApplication.getApplicationInstance();
    SynchronisationAsyncTask mockAsyncTask = mock(SynchronisationAsyncTask.class);
    instance.setSyncTask(mockAsyncTask);
    instance.setCurrentUser(createUser());
    Menu mockMenu = mock(Menu.class);
    MenuItem syncAllMenuItem = mock(MenuItem.class);
    MenuItem cancelSyncAllMenuItem = mock(MenuItem.class);
    MenuItem changePasswordMenuItem = mock(MenuItem.class);
    doReturn(syncAllMenuItem).when(mockMenu).getItem(0);
    doReturn(cancelSyncAllMenuItem).when(mockMenu).getItem(1);
    doReturn(changePasswordMenuItem).when(mockMenu).findItem(R.id.change_password);
    RapidFtrActivity mainActivity = new ViewAllChildrenActivity();
    mainActivity.onCreateOptionsMenu(mockMenu);
    verify(syncAllMenuItem).setVisible(false);
    verify(cancelSyncAllMenuItem).setVisible(true);
    instance.setSyncTask(null);
    mainActivity.onCreateOptionsMenu(mockMenu);
    verify(syncAllMenuItem).setVisible(true);
    verify(cancelSyncAllMenuItem).setVisible(false);
}