use of com.vaadin.v7.data.fieldgroup.BeanFieldGroup in project SORMAS-Project by hzi-braunschweig.
the class LabMessageUiHelperUnitTest method testEstablishFinalCommitButtons.
@Test
public void testEstablishFinalCommitButtons() {
Mockito.mockConstruction(SampleCreateForm.class);
UserReferenceDto user = new UserReferenceDto();
CaseReferenceDto caze = new CaseReferenceDto();
SampleDto sample = SampleDto.build(user, caze);
SampleCreateForm createForm = new SampleCreateForm(Disease.CORONAVIRUS);
when(createForm.getFieldGroup()).thenReturn(new BeanFieldGroup(SampleDto.class));
CommitDiscardWrapperComponent<SampleCreateForm> sampleComponent = new CommitDiscardWrapperComponent<>(createForm, true, createForm.getFieldGroup());
when(sampleComponent.getWrappedComponent().getValue()).thenReturn(sample);
LabMessageUiHelper.establishFinalCommitButtons(sampleComponent);
HorizontalLayout buttonsPanel = sampleComponent.getButtonsPanel();
Button saveAndOpenEntryButton = (Button) buttonsPanel.getComponent(buttonsPanel.getComponentCount() - 2);
assertThat(saveAndOpenEntryButton.getStyleName(), equalTo(sampleComponent.getCommitButton().getStyleName()));
assertThat(saveAndOpenEntryButton.getId(), equalTo("saveAndOpenEntryButton"));
// Both commit buttons should do the same, except each one should trigger a different navigation
assertThat(saveAndOpenEntryButton.getListeners(Button.ClickEvent.class).size(), equalTo(sampleComponent.getCommitButton().getListeners(Button.ClickEvent.class).size()));
}
Aggregations