show detail test

master
Markus Kreth 7 years ago
parent 53f4169735
commit 08a5358795
  1. 28
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/SingleEventView.java
  2. 1
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/MainView.java
  3. 27
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/MainViewDesktopSmokeTest.java

@ -28,14 +28,17 @@ public class SingleEventView extends CustomComponent {
private static final long serialVersionUID = 4701035948083549772L;
private final TextField textTitle;
private final TextField textLocation;
private DateField startDate;
private DateField endDate;
private ComboBox<CompetitionType.Type> competitionType;
private Binder<ClubEvent> binder;
private DefaultDataUpdateHandler updateHandler = new DefaultDataUpdateHandler();
private Button deleteButton;
@ -43,6 +46,7 @@ public class SingleEventView extends CustomComponent {
private CalendarAdapter calendarAdapter;
private EventBusiness eventBusiness;
private Runnable deletedHandler;
public SingleEventView(boolean showCompetitionType) {
@ -88,7 +92,8 @@ public class SingleEventView extends CustomComponent {
competitionType.setItems(Type.values());
binder.forField(competitionType).bind(ClubEvent::getType, ClubEvent::setType);
layout = new GridLayout(2, 3);
} else {
}
else {
layout = new GridLayout(2, 2);
}
@ -120,11 +125,13 @@ public class SingleEventView extends CustomComponent {
if (deletedHandler != null) {
deletedHandler.run();
}
} else {
}
else {
Notification.show("Fehler beim Löschen von " + bean, "Bitte erneut versuchen.",
Notification.Type.ERROR_MESSAGE);
}
} catch (IOException e) {
}
catch (IOException e) {
Notification.show("Fehler beim Löschen von " + bean, e.toString(),
Notification.Type.ERROR_MESSAGE);
}
@ -140,7 +147,8 @@ public class SingleEventView extends CustomComponent {
if (start.until(end, ChronoUnit.DAYS) > 0) {
endDate.setValue(end.toLocalDate());
endDate.setVisible(true);
} else {
}
else {
endDate.setValue(null);
endDate.setVisible(false);
}
@ -158,13 +166,6 @@ public class SingleEventView extends CustomComponent {
this.deletedHandler = deletedHandler;
}
void setTitle(String value) {
if (value == null) {
value = "";
}
textTitle.setValue(value);
}
void setLocation(String value) {
if (value == null) {
value = "";
@ -178,8 +179,9 @@ public class SingleEventView extends CustomComponent {
if (ev != null) {
deleteButton.setEnabled(true);
} else {
setTitle("");
}
else {
textTitle.setValue("");
setLocation("");
endDate.setVisible(false);
deleteButton.setEnabled(false);

@ -76,6 +76,7 @@ public abstract class MainView extends VerticalLayout implements View {
navigator = (ClubNavigator) event.getNavigator();
eventView = new SingleEventView(false);
eventView.setId(eventView.getClass().getName());
eventView.setVisible(false);
personGrid = new PersonGrid(groupDao, personDao);

@ -1,5 +1,6 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@ -19,12 +20,16 @@ import org.springframework.test.context.junit4.SpringRunner;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.ui.Component;
import com.vaadin.ui.HasComponents;
import com.vaadin.ui.TextField;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEventBuilder;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.CalendarView;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.SingleEventView;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@ -55,6 +60,28 @@ public class MainViewDesktopSmokeTest {
mainView.initUI(event);
}
@Test
void detailShowingEventOnClick() {
assertNull(find(mainView, SingleEventView.class.getName()));
ClubEvent ev = new ClubEventBuilder()
.withAllDay(true)
.withCaption("caption")
.withDescription("description")
.withLocation("location")
.withStart(ZonedDateTime.now())
.withEnd(ZonedDateTime.now())
.build();
mainView.openDetailForEvent(ev);
SingleEventView view = (SingleEventView) find(mainView, SingleEventView.class.getName());
assertNotNull(view);
TextField title = (TextField) find(view, "event.title");
assertNotNull(title);
assertEquals("caption", title.getValue());
mainView.detailClosed();
assertNull(find(mainView, SingleEventView.class.getName()));
view.setEvent(null);
}
@Test
void calendarComponentPresentAndShowsThisMonth() {

Loading…
Cancel
Save