SmartAdapter { public static MultiAdaptersCreator empty() { return new MultiAdaptersCreator(new ArrayList<>()); } private  SmartAdapter(); static MultiAdaptersCreator items(@NonNull List<?> items); static MultiAdaptersCreator empty();  }
@Test public void test_map_add() { SmartAdapter.MultiAdaptersCreator creator = SmartAdapter.empty() .mapper(mockMapper); creator.map(MockModel.class, MockLayout.class); verify(mockMapper).add(MockModel.class, MockLayout.class); creator.mapper(new Mapper()); verifyNoMoreInteractions(mockMapper); }
@Test public void test_listener_adapter() { MultiAdapter adapter = SmartAdapter.empty().listener(mockListener).adapter(); Assert.assertEquals(adapter.getViewEventListener(), mockListener); adapter.notifyAction(NOTIFY_ACTION_ID, NOTIFY_MODEL, NOTIFY_POSITION, NOTIFY_VIEW); verify(mockListener).onViewEvent(NOTIFY_ACTION_ID, NOTIFY_MODEL, NOTIFY_POSITION, NOTIFY_VIEW); }
@Test public void test_listener_recycler_adapter() { RecyclerMultiAdapter adapter = SmartAdapter.empty().listener(mockListener).recyclerAdapter(); Assert.assertEquals(adapter.getViewEventListener(), mockListener); adapter.notifyAction(NOTIFY_ACTION_ID, NOTIFY_MODEL, NOTIFY_POSITION, NOTIFY_VIEW); verify(mockListener).onViewEvent(NOTIFY_ACTION_ID, NOTIFY_MODEL, NOTIFY_POSITION, NOTIFY_VIEW); }
@Test public void test_into_abslistview() { MultiAdapter adapter = SmartAdapter.empty().into(mockListView); verify(mockListView).setAdapter(adapter); }
@Test public void test_into_recycler() { RecyclerMultiAdapter adapter = SmartAdapter.empty().into(mockRecycler); verify(mockRecycler).setAdapter(adapter); }
@Test(expected = IllegalArgumentException.class) public void test_multimapping_fail_listview() { when(mockBuilder.allowsMultimapping()).thenReturn(false); SmartAdapter.empty() .mapper(trueMapper) .map(MockModel.class, MockLayout.class) .map(MockModel.class, MockLayout2.class) .builder(mockBuilder) .into(mockListView); }
@Test(expected = IllegalArgumentException.class) public void test_multimapping_fail_recyclerview() { when(mockBuilder.allowsMultimapping()).thenReturn(false); SmartAdapter.empty() .mapper(trueMapper) .map(MockModel.class, MockLayout.class) .map(MockModel.class, MockLayout2.class) .builder(mockBuilder) .into(mockRecycler); }
@Test public void test_multimapping_success() { when(mockBuilder.allowsMultimapping()).thenReturn(true); SmartAdapter.MultiAdaptersCreator builder = SmartAdapter.empty() .map(MockModel.class, MockLayout.class) .map(MockModel.class, MockLayout2.class) .builder(mockBuilder); builder.into(mockListView); builder.into(mockRecycler); }