Search in sources :

Example 1 with Pet

use of io.jmix.petclinic.entity.pet.Pet in project jmix-sneferu by mariodavid.

the class GetOpenedInputDialogScreenTest method storePikachu.

private Pet storePikachu(String identificationNumber) {
    Pet newPet = dataManager.create(Pet.class);
    newPet.setName("Pikachu");
    newPet.setIdentificationNumber(identificationNumber);
    return dataManager.save(newPet);
}
Also used : Pet(io.jmix.petclinic.entity.pet.Pet)

Example 2 with Pet

use of io.jmix.petclinic.entity.pet.Pet in project jmix-sneferu by mariodavid.

the class GetOpenedInputDialogScreenTest method given_inputDialogIsOpen_when_getOpenedInputDialog_then_inputDialogIsReturned.

@Test
void given_inputDialogIsOpen_when_getOpenedInputDialog_then_inputDialogIsReturned(UiTestAPI uiTestAPI) {
    // given:
    final String pikachuIdentifier = "025";
    final Pet pikachu = storePikachu(pikachuIdentifier);
    // and:
    openPetByIdInputDialog(uiTestAPI);
    // when:
    final InputDialogTestAPI openedInputDialog = uiTestAPI.getOpenedInputDialog();
    // and:
    final OperationResult operationResult = openedInputDialog.interact(enter(textInputField("id"), pikachuIdentifier)).andThenGet(closeInputDialogWith(InputDialog.INPUT_DIALOG_OK_ACTION));
    // then:
    assertThat(operationResult).isEqualTo(OperationResult.success());
    // and: after the input dialog, the Pet editor is opened
    final StandardEditorTestAPI<Pet, PetEdit> openedPetEditor = uiTestAPI.getOpenedEditorScreen(PetEdit.class);
    final Pet pet = openedPetEditor.get(editedEntity());
    assertThat(pet).isEqualTo(pikachu);
}
Also used : PetEdit(io.jmix.petclinic.screen.pet.pet.PetEdit) InputDialogTestAPI(de.diedavids.sneferu.screen.InputDialogTestAPI) OperationResult(io.jmix.ui.util.OperationResult) Pet(io.jmix.petclinic.entity.pet.Pet) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with Pet

use of io.jmix.petclinic.entity.pet.Pet in project jmix-sneferu by mariodavid.

the class PetBrowseTest method storePetForType.

@NotNull
private Pet storePetForType(PetType petType) {
    final Pet pikachu = dataManager.create(Pet.class);
    pikachu.setName("pet-" + UUID.randomUUID());
    pikachu.setIdentificationNumber(UUID.randomUUID().toString());
    pikachu.setType(petType);
    return dataManager.save(pikachu);
}
Also used : Pet(io.jmix.petclinic.entity.pet.Pet) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with Pet

use of io.jmix.petclinic.entity.pet.Pet in project jmix-sneferu by mariodavid.

the class PetBrowse method onPetsTableOpenPetById.

@Subscribe("petsTable.openPetById")
public void onPetsTableOpenPetById(Action.ActionPerformedEvent event) {
    FrameOwner frameOwner = this;
    dialogs.createInputDialog(frameOwner).withParameter(InputParameter.stringParameter("id").withRequired(true).withCaption(messageBundle.getMessage("id"))).withCloseListener(inputDialogCloseEvent -> {
        if (inputDialogCloseEvent.closedWith(DialogOutcome.OK)) {
            final String id = inputDialogCloseEvent.getValue("id");
            if (StringUtils.hasText(id)) {
                final Optional<Pet> pet = dataManager.load(Pet.class).query("e.identificationNumber = ?1", id).optional();
                if (pet.isPresent()) {
                    screenBuilders.editor(Pet.class, frameOwner).editEntity(pet.get()).withOpenMode(OpenMode.DIALOG).show();
                } else {
                    noPetFoundForIdWarning(id);
                }
            } else {
                noPetFoundForIdWarning(id);
            }
        }
    }).show();
}
Also used : Id(io.jmix.core.Id) MessageBundle(io.jmix.ui.screen.MessageBundle) Subscribe(io.jmix.ui.screen.Subscribe) FrameOwner(io.jmix.ui.screen.FrameOwner) Autowired(org.springframework.beans.factory.annotation.Autowired) UiDescriptor(io.jmix.ui.screen.UiDescriptor) Notifications(io.jmix.ui.Notifications) InputDialog(io.jmix.ui.app.inputdialog.InputDialog) ScreenBuilders(io.jmix.ui.ScreenBuilders) LookupComponent(io.jmix.ui.screen.LookupComponent) Owner(io.jmix.petclinic.entity.owner.Owner) Pet(io.jmix.petclinic.entity.pet.Pet) Slider(io.jmix.ui.component.Slider) DialogOutcome(io.jmix.ui.app.inputdialog.DialogOutcome) Action(io.jmix.ui.action.Action) TextField(io.jmix.ui.component.TextField) DataManager(io.jmix.core.DataManager) Route(io.jmix.ui.navigation.Route) UiController(io.jmix.ui.screen.UiController) PetType(io.jmix.petclinic.entity.pet.PetType) Dialogs(io.jmix.ui.Dialogs) UUID(java.util.UUID) StandardLookup(io.jmix.ui.screen.StandardLookup) OpenMode(io.jmix.ui.screen.OpenMode) EntityComboBox(io.jmix.ui.component.EntityComboBox) Optional(java.util.Optional) InputParameter(io.jmix.ui.app.inputdialog.InputParameter) StringUtils(org.springframework.util.StringUtils) FrameOwner(io.jmix.ui.screen.FrameOwner) Optional(java.util.Optional) Pet(io.jmix.petclinic.entity.pet.Pet) Subscribe(io.jmix.ui.screen.Subscribe)

Example 5 with Pet

use of io.jmix.petclinic.entity.pet.Pet in project jmix-sneferu by mariodavid.

the class CloseInputDialogInteractionTest method when_interactionIsPerformed_then_inputDialogIsClosedAndSuccessIsReturned.

@Test
void when_interactionIsPerformed_then_inputDialogIsClosedAndSuccessIsReturned(UiTestAPI uiTestAPI) {
    // given:
    final String pikachuIdentifier = "025";
    final Pet pikachu = storePikachu(pikachuIdentifier);
    // and:
    openPetByIdInputDialog(uiTestAPI);
    // when:
    final InputDialogTestAPI openedInputDialog = uiTestAPI.getOpenedInputDialog();
    // and:
    final OperationResult operationResult = openedInputDialog.interact(enter(textInputField("id"), pikachuIdentifier)).andThenGet(closeInputDialogWith(InputDialog.INPUT_DIALOG_OK_ACTION));
    // then:
    assertThat(operationResult).isEqualTo(OperationResult.success());
    // and: after the input dialog, the Pet editor is opened
    final StandardEditorTestAPI<Pet, PetEdit> openedPetEditor = uiTestAPI.getOpenedEditorScreen(PetEdit.class);
    final Pet pet = openedPetEditor.get(editedEntity());
    assertThat(pet).isEqualTo(pikachu);
}
Also used : PetEdit(io.jmix.petclinic.screen.pet.pet.PetEdit) InputDialogTestAPI(de.diedavids.sneferu.screen.InputDialogTestAPI) OperationResult(io.jmix.ui.util.OperationResult) Pet(io.jmix.petclinic.entity.pet.Pet) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Pet (io.jmix.petclinic.entity.pet.Pet)9 SneferuUiTest (de.diedavids.sneferu.SneferuUiTest)4 Test (org.junit.jupiter.api.Test)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 OperationResult (io.jmix.ui.util.OperationResult)3 InputDialogTestAPI (de.diedavids.sneferu.screen.InputDialogTestAPI)2 PetType (io.jmix.petclinic.entity.pet.PetType)2 PetEdit (io.jmix.petclinic.screen.pet.pet.PetEdit)2 DataManager (io.jmix.core.DataManager)1 Id (io.jmix.core.Id)1 Owner (io.jmix.petclinic.entity.owner.Owner)1 Visit (io.jmix.petclinic.entity.visit.Visit)1 VisitBrowse (io.jmix.petclinic.screen.visit.VisitBrowse)1 VisitEdit (io.jmix.petclinic.screen.visit.VisitEdit)1 Dialogs (io.jmix.ui.Dialogs)1 Notifications (io.jmix.ui.Notifications)1 ScreenBuilders (io.jmix.ui.ScreenBuilders)1 Action (io.jmix.ui.action.Action)1 DialogOutcome (io.jmix.ui.app.inputdialog.DialogOutcome)1 InputDialog (io.jmix.ui.app.inputdialog.InputDialog)1