Search in sources :

Example 11 with Visit

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

the class MyVisits method onTableFinish.

@Subscribe("table.finish")
protected void onTableFinish(Action.ActionPerformedEvent event) {
    final Visit visit = table.getSingleSelected();
    if (visit.hasFinished()) {
        petTreatmentWarningMessage("treatmentAlreadyFinished", visit.getPetName());
    } else {
        updateTreatmentTo(visit, VisitTreatmentStatus.DONE);
        petTreatmentSuccessMessage("treatmentFinished", visit.getPetName());
    }
}
Also used : Visit(io.jmix.petclinic.entity.visit.Visit) Subscribe(io.jmix.ui.screen.Subscribe)

Example 12 with Visit

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

the class VisitEditTest method aVisitCanBeCreated_whenAllFieldsAreFilled.

@Test
void aVisitCanBeCreated_whenAllFieldsAreFilled(UiTestAPI uiTestAPI) {
    StandardEditorTestAPI<Visit, VisitEdit> visitEdit = uiTestAPI.openStandardEditor(Visit.class, VisitEdit.class);
    // when:
    OperationResult outcome = (OperationResult) visitEdit.interact(enter(dateField("visitStartField"), LocalDateTime.now())).interact(enter(textField("descriptionField"), "Regular Visit")).interact(select(comboBox("typeField"), VisitType.RECHARGE)).interact(select(entityComboBox("petField"), pet)).andThenGet(closeEditor());
    // then:
    assertThat(outcome).isEqualTo(OperationResult.success());
}
Also used : VisitEdit(io.jmix.petclinic.screen.visit.VisitEdit) Visit(io.jmix.petclinic.entity.visit.Visit) OperationResult(io.jmix.ui.util.OperationResult) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 13 with Visit

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

the class VisitEditTest method aVisitCannotBeCreated_whenPetIsMissing.

@Test
void aVisitCannotBeCreated_whenPetIsMissing(UiTestAPI uiTestAPI) {
    StandardEditorTestAPI<Visit, VisitEdit> visitEdit = uiTestAPI.openStandardEditor(Visit.class, VisitEdit.class);
    // when:
    visitEdit.interact(enter(entityComboBox("petField"), null));
    // and:
    OperationResult outcome = (OperationResult) visitEdit.interact(enter(textField("descriptionField"), "Regular Visit")).interact(select(comboBox("typeField"), VisitType.RECHARGE)).andThenGet(closeEditor());
    // then:
    assertThat(outcome).isEqualTo(OperationResult.fail());
    // and:
    assertThat(visitEdit.screen().getWindow().validateAll()).isFalse();
}
Also used : VisitEdit(io.jmix.petclinic.screen.visit.VisitEdit) Visit(io.jmix.petclinic.entity.visit.Visit) OperationResult(io.jmix.ui.util.OperationResult) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 14 with Visit

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

the class GetLazyOpenedLookupScreenTest method given_screenIsOpenedAfterRetrievingTheLazyReference_when_accessingScreen_then_screenIsReturned.

@Test
void given_screenIsOpenedAfterRetrievingTheLazyReference_when_accessingScreen_then_screenIsReturned(Screens screens, UiTestAPI uiTestAPI) {
    // given:
    final StandardLookupTestAPI<Visit, VisitBrowse> lazyOpenedScreen = uiTestAPI.getLazyOpenedLookupScreen(VisitBrowse.class);
    // and: screen is opened through the application (or test in this case)
    final VisitBrowse screen = screens.create(VisitBrowse.class);
    screen.show();
    // expect: the previous retrieved lazy reference will return the correct reference to the screen
    assertThat(lazyOpenedScreen.screen()).isEqualTo(screen);
}
Also used : Visit(io.jmix.petclinic.entity.visit.Visit) VisitBrowse(io.jmix.petclinic.screen.visit.VisitBrowse) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest)

Example 15 with Visit

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

the class VisitTestDataCreation method createVisit.

Visit createVisit(LocalDate date, List<Pet> possiblePets, List<User> possibleNurses) {
    VisitEventRange visitEventRange = randomVisitDateTime.randomVisitEventRange(date);
    if (visitEventRange.isEmpty()) {
        return null;
    }
    Visit visit = dataManager.create(Visit.class);
    visit.setTreatmentStatus(treatmentStatusFor(date));
    if (nurseShouldBeAssigned(date)) {
        visit.setAssignedNurse(randomOfList(possibleNurses));
    }
    visit.setPet(randomOfList(possiblePets));
    visit.setType(randomVisitType());
    visit.setDescription(randomDescription());
    visit.setVisitStart(visitEventRange.getVisitStart());
    visit.setVisitEnd(visitEventRange.getVisitEnd());
    return visit;
}
Also used : Visit(io.jmix.petclinic.entity.visit.Visit)

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