Search in sources :

Example 6 with Visit

use of io.jmix.petclinic.entity.visit.Visit in project jmix-sneferu by mariodavid.

the class GetOpenedEditorScreenTest method given_editorScreenIsOpen_when_getOpenedScreen_then_screenIsReturned.

@Test
void given_editorScreenIsOpen_when_getOpenedScreen_then_screenIsReturned(Screens screens, UiTestAPI uiTestAPI) {
    // given:
    final VisitEdit screen = screens.create(VisitEdit.class);
    screen.setEntityToEdit(dataManager.create(Visit.class));
    // and:
    screen.show();
    // when:
    final StandardEditorTestAPI<Visit, VisitEdit> openedScreen = uiTestAPI.getOpenedEditorScreen(VisitEdit.class);
    // then:
    assertThat(openedScreen.screen()).isEqualTo(screen);
}
Also used : VisitEdit(io.jmix.petclinic.screen.visit.VisitEdit) Visit(io.jmix.petclinic.entity.visit.Visit) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with Visit

use of io.jmix.petclinic.entity.visit.Visit in project jmix-sneferu by mariodavid.

the class VisitBrowse method onCalendarCalendarEventClick.

@Subscribe("calendar")
protected void onCalendarCalendarEventClick(Calendar.CalendarEventClickEvent<LocalDateTime> event) {
    Screen visitEditor = screenBuilders.editor(Visit.class, this).editEntity((Visit) event.getEntity()).withOpenMode(OpenMode.DIALOG).build();
    visitEditor.addAfterCloseListener(afterCloseEvent -> {
        if (afterCloseEvent.closedWith(StandardOutcome.COMMIT)) {
            getScreenData().loadAll();
        }
    });
    visitEditor.show();
}
Also used : Screen(io.jmix.ui.screen.Screen) Visit(io.jmix.petclinic.entity.visit.Visit) Subscribe(io.jmix.ui.screen.Subscribe)

Example 8 with Visit

use of io.jmix.petclinic.entity.visit.Visit in project jmix-sneferu by mariodavid.

the class InteractionsTest method when_verifyIsPerformed_then_resultOfTheInteractionIsReturned.

@Test
void when_verifyIsPerformed_then_resultOfTheInteractionIsReturned(UiTestAPI uiTestAPI) {
    // given:
    final StandardEditorTestAPI<Visit, VisitEdit> openedScreen = uiTestAPI.openStandardEditor(Visit.class, VisitEdit.class);
    // and:
    assertThat(openedScreen.component(dateField("visitStartField"))).isNotNull();
    // and:
    final LocalDateTime startDate = LocalDateTime.of(2022, 1, 15, 6, 0);
    // and:
    openedScreen.interact(enter(dateField("visitStartField"), startDate));
    // when:
    final LocalDateTime enteredVisitStart = openedScreen.verify(entityValue("visitStart", LocalDateTime.class));
    // then:
    assertThat(enteredVisitStart).isEqualTo(startDate);
}
Also used : VisitEdit(io.jmix.petclinic.screen.visit.VisitEdit) LocalDateTime(java.time.LocalDateTime) Visit(io.jmix.petclinic.entity.visit.Visit) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with Visit

use of io.jmix.petclinic.entity.visit.Visit in project jmix-sneferu by mariodavid.

the class EditedEntityInteractionTest method when_interactionIsPerformed_then_editedEntityIsReturned.

@Test
void when_interactionIsPerformed_then_editedEntityIsReturned(UiTestAPI uiTestAPI) {
    // given:
    final Visit expectedVisit = dataManager.create(Visit.class);
    // and:
    StandardEditorTestAPI<Visit, VisitEdit> visitEdit = uiTestAPI.openStandardEditor(Visit.class, VisitEdit.class, expectedVisit);
    // when:
    final Visit actualVisitEntity = visitEdit.andThenGet(editedEntity());
    // then:
    assertThat(actualVisitEntity).isEqualTo(expectedVisit);
}
Also used : VisitEdit(io.jmix.petclinic.screen.visit.VisitEdit) Visit(io.jmix.petclinic.entity.visit.Visit) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest)

Example 10 with Visit

use of io.jmix.petclinic.entity.visit.Visit in project jmix-sneferu by mariodavid.

the class MyVisits method onStart.

@Subscribe("table.start")
protected void onStart(Action.ActionPerformedEvent event) {
    final Visit visit = table.getSingleSelected();
    if (visit.hasStarted()) {
        petTreatmentWarningMessage("treatmentAlreadyStarted", visit.getPetName());
    } else {
        updateTreatmentTo(visit, VisitTreatmentStatus.IN_PROGRESS);
        petTreatmentSuccessMessage("treatmentStarted", visit.getPetName());
    }
}
Also used : Visit(io.jmix.petclinic.entity.visit.Visit) Subscribe(io.jmix.ui.screen.Subscribe)

Aggregations

Visit (io.jmix.petclinic.entity.visit.Visit)31 SneferuUiTest (de.diedavids.sneferu.SneferuUiTest)25 Test (org.junit.jupiter.api.Test)25 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)25 VisitEdit (io.jmix.petclinic.screen.visit.VisitEdit)17 VisitBrowse (io.jmix.petclinic.screen.visit.VisitBrowse)9 LocalDateTime (java.time.LocalDateTime)5 VisitType (io.jmix.petclinic.entity.visit.VisitType)4 Subscribe (io.jmix.ui.screen.Subscribe)4 OperationResult (io.jmix.ui.util.OperationResult)3 ScreenNotOpenException (de.diedavids.sneferu.ScreenNotOpenException)2 TabsheetComponentDescriptor (de.diedavids.sneferu.components.descriptor.TabsheetComponentDescriptor)2 Interactions.screenOpenMode (de.diedavids.sneferu.Interactions.screenOpenMode)1 ButtonTestAPI (de.diedavids.sneferu.components.testapi.ButtonTestAPI)1 Pet (io.jmix.petclinic.entity.pet.Pet)1 Button (io.jmix.ui.component.Button)1 TabSheet (io.jmix.ui.component.TabSheet)1 OpenMode (io.jmix.ui.screen.OpenMode)1 Screen (io.jmix.ui.screen.Screen)1