Search in sources :

Example 1 with Veterinarian

use of io.jmix.petclinic.entity.veterinarian.Veterinarian in project jmix-sneferu by mariodavid.

the class SelectInListInteractionTest method storeVet.

private Veterinarian storeVet(String name) {
    Veterinarian entity = dataManager.create(Veterinarian.class);
    entity.setFirstName("Professor");
    entity.setLastName(name);
    return dataManager.save(entity);
}
Also used : Veterinarian(io.jmix.petclinic.entity.veterinarian.Veterinarian)

Example 2 with Veterinarian

use of io.jmix.petclinic.entity.veterinarian.Veterinarian in project jmix-sneferu by mariodavid.

the class CloseEditorInteractionTest method given_invalidForm_when_interactionIsPerformedWith_then_screenIsClosedAndFailIsReturned.

@Test
void given_invalidForm_when_interactionIsPerformedWith_then_screenIsClosedAndFailIsReturned(UiTestAPI uiTestAPI) {
    // given:
    StandardEditorTestAPI<Veterinarian, VeterinarianEdit> visitEdit = uiTestAPI.openStandardEditor(Veterinarian.class, VeterinarianEdit.class);
    // and:
    visitEdit.interact(enter(textInputField("firstNameField"), null));
    // when:
    final OperationResult operationResult = visitEdit.andThenGet(closeEditor());
    // then:
    assertThat(operationResult).isEqualTo(OperationResult.fail());
}
Also used : VeterinarianEdit(io.jmix.petclinic.screen.veterinarian.veterinarian.VeterinarianEdit) Veterinarian(io.jmix.petclinic.entity.veterinarian.Veterinarian) OperationResult(io.jmix.ui.util.OperationResult) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest)

Example 3 with Veterinarian

use of io.jmix.petclinic.entity.veterinarian.Veterinarian in project jmix-sneferu by mariodavid.

the class SelectInListInteractionTest method when_multipleSelectionIsTriedWithSingleSelectionTable_then_exceptionIsThrown.

@Test
void when_multipleSelectionIsTriedWithSingleSelectionTable_then_exceptionIsThrown(UiTestAPI uiTestAPI) {
    // given:
    storeVet("Elm");
    storeVet("Rowan");
    storeVet("Sycamore");
    // and:
    final Veterinarian oak = storeVet("Oak");
    final Veterinarian juniper = storeVet("Juniper");
    final Veterinarian birch = storeVet("Birch");
    // and:
    final StandardLookupTestAPI<Veterinarian, VeterinarianBrowse> openedScreen = uiTestAPI.openStandardLookup(Veterinarian.class, VeterinarianBrowse.class);
    final DataGridComponentDescriptor dataGrid = dataGrid("veterinariansTable");
    assertThat(openedScreen.rawComponent(dataGrid).isMultiSelect()).isFalse();
    // when:
    final IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> openedScreen.interact(selectInList(dataGrid, Lists.list(birch, oak, juniper))));
    // then:
    assertThat(exception.getMessage()).isEqualTo("Cannot select multiple values for component with multiselect='false'");
}
Also used : DataGridComponentDescriptor(de.diedavids.sneferu.components.descriptor.DataGridComponentDescriptor) VeterinarianBrowse(io.jmix.petclinic.screen.veterinarian.veterinarian.VeterinarianBrowse) Veterinarian(io.jmix.petclinic.entity.veterinarian.Veterinarian) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with Veterinarian

use of io.jmix.petclinic.entity.veterinarian.Veterinarian in project jmix-sneferu by mariodavid.

the class SelectInListInteractionTest method when_interactionIsPerformedWithSingleSelection_then_valueIsSet.

@Test
void when_interactionIsPerformedWithSingleSelection_then_valueIsSet(UiTestAPI uiTestAPI) {
    // given:
    storeVet("Oak");
    storeVet("Elm");
    storeVet("Juniper");
    storeVet("Rowan");
    storeVet("Sycamore");
    // and:
    final Veterinarian birch = storeVet("Birch");
    // and:
    final StandardLookupTestAPI<Veterinarian, VeterinarianBrowse> openedScreen = uiTestAPI.openStandardLookup(Veterinarian.class, VeterinarianBrowse.class);
    final DataGridComponentDescriptor dataGrid = dataGrid("veterinariansTable");
    assertThat(openedScreen.rawComponent(dataGrid).isMultiSelect()).isFalse();
    // when:
    openedScreen.interact(selectInList(dataGrid, birch));
    // then:
    final Veterinarian selectedVetInTable = (Veterinarian) openedScreen.rawComponent(dataGrid).getSingleSelected();
    // and:
    assertThat(selectedVetInTable).isEqualTo(birch);
}
Also used : DataGridComponentDescriptor(de.diedavids.sneferu.components.descriptor.DataGridComponentDescriptor) VeterinarianBrowse(io.jmix.petclinic.screen.veterinarian.veterinarian.VeterinarianBrowse) Veterinarian(io.jmix.petclinic.entity.veterinarian.Veterinarian) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with Veterinarian

use of io.jmix.petclinic.entity.veterinarian.Veterinarian in project jmix-sneferu by mariodavid.

the class CancelEditorInteractionTest method when_interactionIsPerformed_then_screenIsCanceledAndNothingIsCommitted.

@Test
void when_interactionIsPerformed_then_screenIsCanceledAndNothingIsCommitted(UiTestAPI uiTestAPI) {
    // given:
    StandardEditorTestAPI<Veterinarian, VeterinarianEdit> visitEdit = uiTestAPI.openStandardEditor(Veterinarian.class, VeterinarianEdit.class);
    // and:
    visitEdit.interact(enter(textInputField("firstNameField"), "Oak"));
    // when:
    final OperationResult operationResult = visitEdit.andThenGet(cancelEditor());
    // then:
    assertThat(operationResult).isEqualTo(OperationResult.success());
    // and:
    assertThat(dataManager.load(Veterinarian.class).all().list()).isEmpty();
}
Also used : VeterinarianEdit(io.jmix.petclinic.screen.veterinarian.veterinarian.VeterinarianEdit) Veterinarian(io.jmix.petclinic.entity.veterinarian.Veterinarian) OperationResult(io.jmix.ui.util.OperationResult) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Veterinarian (io.jmix.petclinic.entity.veterinarian.Veterinarian)6 SneferuUiTest (de.diedavids.sneferu.SneferuUiTest)5 Test (org.junit.jupiter.api.Test)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 VeterinarianEdit (io.jmix.petclinic.screen.veterinarian.veterinarian.VeterinarianEdit)3 OperationResult (io.jmix.ui.util.OperationResult)3 DataGridComponentDescriptor (de.diedavids.sneferu.components.descriptor.DataGridComponentDescriptor)2 VeterinarianBrowse (io.jmix.petclinic.screen.veterinarian.veterinarian.VeterinarianBrowse)2