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());
}
}
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());
}
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();
}
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);
}
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;
}
Aggregations