Search in sources :

Example 26 with Visit

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

the class InteractionsTest method when_interactIsPerformedMultipleTimes_then_allInteractionsArePerformed.

@Test
void when_interactIsPerformedMultipleTimes_then_allInteractionsArePerformed(UiTestAPI uiTestAPI) {
    // given:
    final StandardEditorTestAPI<Visit, VisitEdit> openedScreen = uiTestAPI.openStandardEditor(Visit.class, VisitEdit.class);
    // and:
    assertThat(openedScreen.component(dateField("visitStartField"))).isNotNull();
    assertThat(openedScreen.component(comboBox("typeField"))).isNotNull();
    // and:
    final LocalDateTime startDate = LocalDateTime.of(2022, 1, 15, 6, 0);
    final VisitType recharge = VisitType.RECHARGE;
    // when:
    openedScreen.interact(enter(dateField("visitStartField"), startDate)).andThen(select(comboBox("typeField"), recharge));
    // then:
    assertThat(openedScreen.verify(entityValue("visitStart", LocalDateTime.class))).isEqualTo(startDate);
    // and:
    assertThat(openedScreen.verify(entityValue("type", VisitType.class))).isEqualTo(recharge);
}
Also used : VisitEdit(io.jmix.petclinic.screen.visit.VisitEdit) LocalDateTime(java.time.LocalDateTime) Visit(io.jmix.petclinic.entity.visit.Visit) VisitType(io.jmix.petclinic.entity.visit.VisitType) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 27 with Visit

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

the class EntityValueInteractionTest method when_interactionIsPerformed_then_valueIsReturnedFromTheEntity.

@Test
void when_interactionIsPerformed_then_valueIsReturnedFromTheEntity(UiTestAPI uiTestAPI) {
    // given:
    StandardEditorTestAPI<Visit, VisitEdit> visitEdit = uiTestAPI.openStandardEditor(Visit.class, VisitEdit.class);
    // and:
    final LocalDateTime visitStart = LocalDateTime.now();
    visitEdit.interact(enter(dateField("visitStartField"), visitStart));
    // when:
    final LocalDateTime actualVisitStart = (LocalDateTime) visitEdit.andThenGet(entityValue("visitStart", LocalDateTime.class));
    // then:
    assertThat(actualVisitStart).isEqualTo(visitStart);
}
Also used : VisitEdit(io.jmix.petclinic.screen.visit.VisitEdit) LocalDateTime(java.time.LocalDateTime) Visit(io.jmix.petclinic.entity.visit.Visit) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest)

Example 28 with Visit

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

the class CreateVisitTest method aVisitCanBeCreated_whenAllFieldsAreFilled.

@Test
void aVisitCanBeCreated_whenAllFieldsAreFilled(UiTestAPI uiTestAPI) {
    // given:
    final Pet pikachu = dataManager.create(Pet.class);
    pikachu.setName("Pikachu");
    pikachu.setIdentificationNumber("025");
    final Pet savedPikachu = dataManager.save(pikachu);
    // and:
    final StandardLookupTestAPI<Visit, VisitBrowse> visitBrowse = uiTestAPI.openStandardLookup(Visit.class, VisitBrowse.class);
    visitBrowse.interact(click(button("createBtn")));
    // when:
    final StandardEditorTestAPI<Visit, VisitEdit> visitEdit = uiTestAPI.getOpenedEditorScreen(VisitEdit.class);
    OperationResult outcome = (OperationResult) visitEdit.interact(enter(dateField("visitStartField"), LocalDateTime.now())).interact(enter(textField("descriptionField"), "Regular Visit")).interact(select(comboBox("typeField"), VisitType.REGULAR_CHECKUP)).interact(select(entityComboBox("petField"), savedPikachu)).andThenGet(closeEditor());
    // then:
    assertThat(outcome).isEqualTo(OperationResult.success());
    // and:
    assertThat(uiTestAPI.isActive(visitEdit)).isFalse();
}
Also used : VisitEdit(io.jmix.petclinic.screen.visit.VisitEdit) Visit(io.jmix.petclinic.entity.visit.Visit) OperationResult(io.jmix.ui.util.OperationResult) Pet(io.jmix.petclinic.entity.pet.Pet) VisitBrowse(io.jmix.petclinic.screen.visit.VisitBrowse) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 29 with Visit

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

the class GetOpenedLookupScreenTest method given_lookupScreenIsOpen_when_getOpenedScreen_then_screenIsReturned.

@Test
void given_lookupScreenIsOpen_when_getOpenedScreen_then_screenIsReturned(Screens screens, UiTestAPI uiTestAPI) {
    // given:
    final VisitBrowse screen = screens.create(VisitBrowse.class);
    // and:
    screen.show();
    // when:
    final StandardLookupTestAPI<Visit, VisitBrowse> openedScreen = uiTestAPI.getOpenedLookupScreen(VisitBrowse.class);
    // then:
    assertThat(openedScreen.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 30 with Visit

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

the class GetLazyOpenedLookupScreenTest method given_lazyTestApiIsReturned_when_accessingScreen_then_ScreenNotFoundExceptionIsThrown.

@Test
void given_lazyTestApiIsReturned_when_accessingScreen_then_ScreenNotFoundExceptionIsThrown(Screens screens, UiTestAPI uiTestAPI) {
    // given:
    screens.removeAll();
    // when:
    final StandardLookupTestAPI<Visit, VisitBrowse> lazyOpenedScreen = uiTestAPI.getLazyOpenedLookupScreen(VisitBrowse.class);
    // then:
    final ScreenNotOpenException exception = Assertions.assertThrows(ScreenNotOpenException.class, lazyOpenedScreen::screen);
    // then:
    assertThat(exception.getMessage()).isEqualTo("No Screen of class VisitBrowse found");
}
Also used : ScreenNotOpenException(de.diedavids.sneferu.ScreenNotOpenException) 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)

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