class FormManager implements OnFormRowChangeListener, OnFormRowValueChangedListener {

    public void setup(FormDescriptor formDescriptor, final ListView listView, Activity activity){

        Context context = activity;

//        activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
        mFormDescriptor = formDescriptor;
        mFormDescriptor.setOnFormRowChangeListener(this);
        mFormDescriptor.setOnFormRowValueChangedListener(this);

        final FormAdapter adapter = FormAdapter.newInstance(mFormDescriptor, context);
        listView.setAdapter(adapter);
        listView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                FormItemDescriptor itemDescriptor = adapter.getItem(position);

                Cell cell = itemDescriptor.getCell();
                if (cell != null && itemDescriptor instanceof RowDescriptor){
                    RowDescriptor rowDescriptor = (RowDescriptor) itemDescriptor;
                    if (!rowDescriptor.getDisabled()){
                        cell.onCellSelected();
                    }
                }

                OnFormRowClickListener descriptorListener = itemDescriptor.getOnFormRowClickListener();
                if (descriptorListener != null){
                    descriptorListener.onFormRowClick(itemDescriptor);
                }

                if (mOnFormRowClickListener != null){
                    mOnFormRowClickListener.onFormRowClick(itemDescriptor);
                }
            }
        });
        mListView = listView;

    }

}

class FormManagerTest {

    private FormManager formManager;
    private Activity activity;

    @Test
    public void shouldSetupListView(){


        ListView listView = new ListView(activity);
        FormDescriptor formDescriptor = new FormDescriptor();
        formManager.setup(formDescriptor, listView, activity);

        assertThat(listView.getAdapter(), is(notNullValue()));

    }

}