@Test public void editDeleteAreDisabledWithoutRights() { expectSetActionEnabled(); replay(view); createPresenter(); presenter.onSelectionChanged(viewableDb); assertThat(disabledActions, hasItems(UIActions.EDIT, UIActions.DELETE)); }
@Test public void deleteAndEditAreDisabledIfNoDatabaseIsSelected() { expectSetActionEnabled(); replay(view); createPresenter(); presenter.onSelectionChanged(null); assertThat(disabledActions, hasItems(UIActions.EDIT, UIActions.DELETE)); }
@Test public void editIsEnabledIfUserHasDesignRights() { expectSetActionEnabled(); replay(view); createPresenter(); presenter.onSelectionChanged(designableDb); assertThat(disabledActions, hasItem(UIActions.DELETE)); assertThat(disabledActions, not(hasItem(UIActions.EDIT))); }
@Test public void deleteAndEditAreEnabledIfDatabaseIsOwned() { expectSetActionEnabled(); replay(view); createPresenter(); presenter.onSelectionChanged(ownedDb); assertThat(disabledActions, not(hasItem(UIActions.EDIT))); assertThat(disabledActions, not(hasItem(UIActions.DELETE))); }
@Test public void loaderPopulatesStore() { ignoreView(); expectDispatch(new GetSchema(), schema); replay(dispatcher); createPresenter(); ListStore<UserDatabaseDTO> store = presenter.getStore(); assertThat("store.getCount()", store.getCount(), is(equalTo(3))); verify(dispatcher); }
@Test public void commandShouldBePreparedProperly() { Capture<CreateEntity> cmd = new Capture<CreateEntity>(); expectDispatch(new GetSchema(), schema); captureDispatch(cmd); replay(dispatcher); UserDatabaseDTO newDb = new UserDatabaseDTO(); newDb.setCountry(new CountryDTO(31, "Haiti")); newDb.setName("My Db"); createPresenter(); presenter.save(newDb, niceFormDialogMock()); assertTrue("command was dispatched", cmd.hasCaptured()); assertThat((Integer) cmd.getValue().getProperties().get("countryId"), is(equalTo(31))); }