/******************************************************************************************************************* * * Specifies that the object to build can be renamed. * * @return itself * ******************************************************************************************************************/ @Nonnull public Builder<T> thatCanBeRenamed() { return thatCanBeRenamed(true); }
@Test public void aRenamableViewMustHaveAnId() { final HView view = hvManager.createView(). withDisplayName("My View 1"). thatCanBeRenamed(). build(); assertThat(view, is(notNullValue())); assertThat(view.getId(), is(notNullValue())); }
@Test public void aRenamableItemMustHaveAnId() { final HItem item = fixture.createChild(). withDisplayName("My Item 1"). thatCanBeRenamed(). build(); assertThat(item, is(notNullValue())); assertThat(item.getId(), is(notNullValue())); }
@Test public void aRenamableItemMustReturnTheRightView() { final HItem item = fixture.createChild(). withDisplayName("My Item 1"). thatCanBeRenamed(). build(); assertThat(item, is(notNullValue())); assertThat(item.getView(), is(sameInstance(fixture))); }
@Test public void aRenamableViewMustHaveTheCorrectName() { final HView view = hvManager.createView(). withDisplayName("My View 1"). thatCanBeRenamed(). build(); assertThat(view, is(notNullValue())); assertThat(view.as(Displayable).getDisplayName(), is("My View 1")); }
@Test public void aRenamableItemMustHaveTheCorrectName() { final HItem item = fixture.createChild(). withDisplayName("My Item 1"). thatCanBeRenamed(). build(); assertThat(item, is(notNullValue())); assertThat(item.as(Displayable).getDisplayName(), is("My Item 1")); }
@Test public void aRenamableItemMustReturnTheRightView() { final HItem item = fixture.createChild(). withDisplayName("My Item 1"). thatCanBeRenamed(). build(); assertThat(item, is(notNullValue())); assertThat(item.getView(), is(sameInstance(fixture.getView()))); }
@Test public void aRenamableViewCanBeRenamed() { final HView view = hvManager.createView(). withDisplayName("My View 1"). thatCanBeRenamed(). build(); assertThat(view, is(notNullValue())); view.as(MutableDisplayable.class).setDisplayName("New View Name"); assertThat(view.as(Displayable).getDisplayName(), is("New View Name")); }
@Test(expected=AsException.class) public void aRenamableItemMustNotBeMovable() { final HItem item = fixture.createChild(). withDisplayName("My Item 1"). thatCanBeRenamed(). build(); item.as(Movable); }
@Test public void aRenamableItemCanBeRenamed() { final HItem item = fixture.createChild(). withDisplayName("My Item 1"). thatCanBeRenamed(). build(); assertThat(item, is(notNullValue())); item.as(MutableDisplayable.class).setDisplayName("New Item Name"); assertThat(item.as(Displayable).getDisplayName(), is("New Item Name")); }
@Test(expected=AsException.class) public void aRenamableViewMustNotBeCopiable() { final HView view = hvManager.createView(). withDisplayName("My View 1"). thatCanBeRenamed(). build(); view.as(Copiable); }
@Test(expected=AsException.class) public void aRenamableViewMustNotBeMovable() { final HView view = hvManager.createView(). withDisplayName("My View 1"). thatCanBeRenamed(). build(); view.as(Movable); }
@Test public void aRenamableViewMustBeInitiallyEmpty() { final HView view = hvManager.createView(). withDisplayName("My View 1"). thatCanBeRenamed(). build(); assertThat(view.findChildren().count(), is(0)); }
@Test public void aRenamableItemMustBeInitiallyEmpty() { final HItem item = fixture.createChild(). withDisplayName("My Item 1"). thatCanBeRenamed(). build(); assertThat(item.findChildren().count(), is(0)); }
@Test(expected=AsException.class) public void aRenamableItemMustNotBeCopiable() { final HItem item = fixture.createChild(). withDisplayName("My Item 1"). thatCanBeRenamed(). build(); item.as(Copiable); }