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