### Question:
ButtonItem extends AbstractItem implements View.OnClickListener { protected Button createButton(ViewGroup parent) { if (button == null) { Context context = parent.getContext(); if (theme != 0) { context = new ContextThemeWrapper(context, theme); } button = createButton(context); button.setOnClickListener(this); } else { if (button.getParent() instanceof ViewGroup) { ((ViewGroup) button.getParent()).removeView(button); } } button.setEnabled(enabled); button.setText(text); button.setId(getViewId()); return button; } ButtonItem();  ButtonItem(Context context, AttributeSet attrs); void setOnClickListener(OnClickListener listener); void setText(CharSequence text); CharSequence getText(); void setTheme(int theme); int getTheme(); void setEnabled(boolean enabled); @Override int getCount(); @Override boolean isEnabled(); @Override int getLayoutResource(); @Override final void onBindView(View view); @Override void onClick(View v);  }### Answer:
@Test public void testCreateButton() { TestButtonItem item = new TestButtonItem(); final Button button = item.createButton(parent); assertThat(button.isEnabled()).named("enabled").isTrue(); assertThat(button.getText().toString()).isEmpty(); }
@Test public void testButtonItemSetsItsId() { TestButtonItem item = new TestButtonItem(); final int id = 12345; item.setId(id); assertWithMessage("Button's id should be set") .that(item.createButton(parent).getId()) .isEqualTo(id); }
@Test public void testCreateButtonTwice() { TestButtonItem item = new TestButtonItem(); final Button button = item.createButton(parent); FrameLayout frameLayout = new FrameLayout(context); frameLayout.addView(button); final Button button2 = item.createButton(parent); assertWithMessage("createButton should be reused").that(button2).isSameAs(button); assertWithMessage("Should be removed from parent after createButton") .that(button2.getParent()) .isNull(); }