From 4fe3541d947cd030e23d4414589b8f13fb54383a Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 20 Dec 2024 08:42:18 +0200 Subject: [PATCH] Update test to use Flow crud classes --- .../views/GridUseDataProviderHookView.tsx | 10 +-- .../views/ReadOnlyGridCustomFilter.tsx | 64 +++++++++---------- .../frontend/views/ReadOnlyGridOrFilter.tsx | 6 +- .../ReadOnlyGridSinglePropertyFilter.tsx | 6 +- .../test/reactgrid/AppointmentService.java | 8 ++- .../hilla/test/reactgrid/CompanyService.java | 8 ++- .../test/reactgrid/PersonListOnlyService.java | 9 ++- .../hilla/test/reactgrid/PersonService.java | 8 ++- .../entityreferences/EmployeeService.java | 9 ++- .../reactgrid/GridUseDataProviderHookIT.java | 6 +- .../ReadOnlyGridWithHeaderFilterIT.java | 4 +- 11 files changed, 75 insertions(+), 63 deletions(-) diff --git a/packages/java/tests/spring/react-grid-test/frontend/views/GridUseDataProviderHookView.tsx b/packages/java/tests/spring/react-grid-test/frontend/views/GridUseDataProviderHookView.tsx index edad44bbc2..3ed55e34ad 100644 --- a/packages/java/tests/spring/react-grid-test/frontend/views/GridUseDataProviderHookView.tsx +++ b/packages/java/tests/spring/react-grid-test/frontend/views/GridUseDataProviderHookView.tsx @@ -1,14 +1,14 @@ import { useDataProvider } from '@vaadin/hilla-react-crud'; -import type Person from 'Frontend/generated/com/vaadin/hilla/test/reactgrid/Person.js'; -import { PersonService } from 'Frontend/generated/endpoints.js'; +import { Button } from '@vaadin/react-components/Button.js'; import { Grid } from '@vaadin/react-components/Grid'; import { GridSortColumn } from '@vaadin/react-components/GridSortColumn'; -import { Button } from '@vaadin/react-components/Button.js'; import { TextField } from '@vaadin/react-components/TextField.js'; -import PropertyStringFilter from 'Frontend/generated/com/vaadin/hilla/crud/filter/PropertyStringFilter'; import { useState } from 'react'; -import Matcher from 'Frontend/generated/com/vaadin/hilla/crud/filter/PropertyStringFilter/Matcher'; +import type PropertyStringFilter from 'Frontend/generated/com/vaadin/flow/spring/data/filter/PropertyStringFilter'; +import Matcher from 'Frontend/generated/com/vaadin/flow/spring/data/filter/PropertyStringFilter/Matcher'; import Gender from 'Frontend/generated/com/vaadin/hilla/test/reactgrid/Person/Gender'; +import type Person from 'Frontend/generated/com/vaadin/hilla/test/reactgrid/Person.js'; +import { PersonService } from 'Frontend/generated/endpoints.js'; type GridBodyReactRendererProps = { item: TItem; diff --git a/packages/java/tests/spring/react-grid-test/frontend/views/ReadOnlyGridCustomFilter.tsx b/packages/java/tests/spring/react-grid-test/frontend/views/ReadOnlyGridCustomFilter.tsx index ff664f03cf..a14e83e18f 100644 --- a/packages/java/tests/spring/react-grid-test/frontend/views/ReadOnlyGridCustomFilter.tsx +++ b/packages/java/tests/spring/react-grid-test/frontend/views/ReadOnlyGridCustomFilter.tsx @@ -1,42 +1,40 @@ +import { AutoGrid, type HeaderFilterRendererProps } from '@vaadin/hilla-react-crud'; +import { GridColumn } from '@vaadin/react-components/GridColumn'; import { TextField } from '@vaadin/react-components/TextField.js'; -import { AutoGrid, HeaderFilterRendererProps } from '@vaadin/hilla-react-crud'; +import type FilterUnion from 'Frontend/generated/com/vaadin/flow/spring/data/filter/FilterUnion'; +import type OrFilter from 'Frontend/generated/com/vaadin/flow/spring/data/filter/OrFilter'; +import type Person from 'Frontend/generated/com/vaadin/hilla/test/reactgrid/Person'; import PersonModel from 'Frontend/generated/com/vaadin/hilla/test/reactgrid/PersonModel.js'; -import Person from 'Frontend/generated/com/vaadin/hilla/test/reactgrid/Person'; import { PersonService } from 'Frontend/generated/endpoints.js'; -import { GridColumn } from '@vaadin/react-components/GridColumn'; -import type FilterUnion from 'Frontend/generated/com/vaadin/hilla/crud/filter/FilterUnion.js'; -import type OrFilter from 'Frontend/generated/com/vaadin/hilla/crud/filter/OrFilter.js'; -const HeaderFilterRenderer = ({ setFilter }: HeaderFilterRendererProps) => { - return ( - { - const firstNameFilter = { - '@type': 'propertyString', - propertyId: 'firstName', - matcher: 'CONTAINS', - filterValue: value, - }; - const lastNameFilter = { - '@type': 'propertyString', - propertyId: 'lastName', - matcher: 'CONTAINS', - filterValue: value, - }; +const HeaderFilterRenderer = ({ setFilter }: HeaderFilterRendererProps) => ( + { + const firstNameFilter = { + '@type': 'propertyString', + propertyId: 'firstName', + matcher: 'CONTAINS', + filterValue: value, + }; + const lastNameFilter = { + '@type': 'propertyString', + propertyId: 'lastName', + matcher: 'CONTAINS', + filterValue: value, + }; - const filter: OrFilter = { - '@type': 'or', - children: [firstNameFilter, lastNameFilter], - }; + const filter: OrFilter = { + '@type': 'or', + children: [firstNameFilter, lastNameFilter], + }; - setFilter(filter as FilterUnion); - }} - > - ); -}; + setFilter(filter as FilterUnion); + }} + > +); const FullNameRenderer = ({ item }: { item: Person }): JSX.Element => ( diff --git a/packages/java/tests/spring/react-grid-test/frontend/views/ReadOnlyGridOrFilter.tsx b/packages/java/tests/spring/react-grid-test/frontend/views/ReadOnlyGridOrFilter.tsx index d9ed2e7a0c..014ed5e06b 100644 --- a/packages/java/tests/spring/react-grid-test/frontend/views/ReadOnlyGridOrFilter.tsx +++ b/packages/java/tests/spring/react-grid-test/frontend/views/ReadOnlyGridOrFilter.tsx @@ -1,7 +1,7 @@ -import { TextField } from '@vaadin/react-components/TextField.js'; import { AutoGrid } from '@vaadin/hilla-react-crud'; +import { TextField } from '@vaadin/react-components/TextField.js'; import { useState } from 'react'; -import type FilterUnion from 'Frontend/generated/com/vaadin/hilla/crud/filter/FilterUnion.js'; +import type FilterUnion from 'Frontend/generated/com/vaadin/flow/spring/data/filter/FilterUnion'; import PersonModel from 'Frontend/generated/com/vaadin/hilla/test/reactgrid/PersonModel.js'; import { PersonService } from 'Frontend/generated/endpoints.js'; @@ -27,7 +27,7 @@ export function ReadOnlyGridOrFilter(): JSX.Element { matcher: 'CONTAINS', filterValue: value, }; - setFilter({ '@type': 'or', children: [firstNameFilter, lasttNameFilter]}); + setFilter({ '@type': 'or', children: [firstNameFilter, lasttNameFilter] }); }} > diff --git a/packages/java/tests/spring/react-grid-test/frontend/views/ReadOnlyGridSinglePropertyFilter.tsx b/packages/java/tests/spring/react-grid-test/frontend/views/ReadOnlyGridSinglePropertyFilter.tsx index 30fb903765..cf8cb9fc8b 100644 --- a/packages/java/tests/spring/react-grid-test/frontend/views/ReadOnlyGridSinglePropertyFilter.tsx +++ b/packages/java/tests/spring/react-grid-test/frontend/views/ReadOnlyGridSinglePropertyFilter.tsx @@ -1,8 +1,8 @@ -import { TextField } from '@vaadin/react-components/TextField.js'; import { AutoGrid } from '@vaadin/hilla-react-crud'; +import { TextField } from '@vaadin/react-components/TextField.js'; import { useState } from 'react'; -import type FilterUnion from 'Frontend/generated/com/vaadin/hilla/crud/filter/FilterUnion.js'; -import Matcher from 'Frontend/generated/com/vaadin/hilla/crud/filter/PropertyStringFilter/Matcher.js'; +import type FilterUnion from 'Frontend/generated/com/vaadin/flow/spring/data/filter/FilterUnion'; +import Matcher from 'Frontend/generated/com/vaadin/flow/spring/data/filter/PropertyStringFilter/Matcher'; import PersonModel from 'Frontend/generated/com/vaadin/hilla/test/reactgrid/PersonModel.js'; import { PersonService } from 'Frontend/generated/endpoints.js'; diff --git a/packages/java/tests/spring/react-grid-test/src/main/java/com/vaadin/hilla/test/reactgrid/AppointmentService.java b/packages/java/tests/spring/react-grid-test/src/main/java/com/vaadin/hilla/test/reactgrid/AppointmentService.java index aba309f2fe..7af54e3b8d 100644 --- a/packages/java/tests/spring/react-grid-test/src/main/java/com/vaadin/hilla/test/reactgrid/AppointmentService.java +++ b/packages/java/tests/spring/react-grid-test/src/main/java/com/vaadin/hilla/test/reactgrid/AppointmentService.java @@ -1,14 +1,18 @@ package com.vaadin.hilla.test.reactgrid; -import com.vaadin.hilla.BrowserCallable; -import com.vaadin.hilla.crud.CrudRepositoryService; +import org.checkerframework.checker.units.qual.A; import org.springframework.stereotype.Service; import com.vaadin.flow.server.auth.AnonymousAllowed; +import com.vaadin.flow.spring.data.jpa.CrudRepositoryService; +import com.vaadin.hilla.BrowserCallable; @BrowserCallable @Service @AnonymousAllowed public class AppointmentService extends CrudRepositoryService { + AppointmentService(AppointmentRepository repository) { + super(repository); + } } diff --git a/packages/java/tests/spring/react-grid-test/src/main/java/com/vaadin/hilla/test/reactgrid/CompanyService.java b/packages/java/tests/spring/react-grid-test/src/main/java/com/vaadin/hilla/test/reactgrid/CompanyService.java index 4eea3330b7..d46bf67b3e 100644 --- a/packages/java/tests/spring/react-grid-test/src/main/java/com/vaadin/hilla/test/reactgrid/CompanyService.java +++ b/packages/java/tests/spring/react-grid-test/src/main/java/com/vaadin/hilla/test/reactgrid/CompanyService.java @@ -1,12 +1,14 @@ package com.vaadin.hilla.test.reactgrid; -import com.vaadin.hilla.BrowserCallable; -import com.vaadin.hilla.crud.CrudRepositoryService; - import com.vaadin.flow.server.auth.AnonymousAllowed; +import com.vaadin.flow.spring.data.jpa.CrudRepositoryService; +import com.vaadin.hilla.BrowserCallable; @BrowserCallable @AnonymousAllowed public class CompanyService extends CrudRepositoryService { + CompanyService(CompanyRepository repository) { + super(repository); + } } diff --git a/packages/java/tests/spring/react-grid-test/src/main/java/com/vaadin/hilla/test/reactgrid/PersonListOnlyService.java b/packages/java/tests/spring/react-grid-test/src/main/java/com/vaadin/hilla/test/reactgrid/PersonListOnlyService.java index 97781f6cc9..ac456b8881 100644 --- a/packages/java/tests/spring/react-grid-test/src/main/java/com/vaadin/hilla/test/reactgrid/PersonListOnlyService.java +++ b/packages/java/tests/spring/react-grid-test/src/main/java/com/vaadin/hilla/test/reactgrid/PersonListOnlyService.java @@ -1,13 +1,16 @@ package com.vaadin.hilla.test.reactgrid; -import com.vaadin.hilla.BrowserCallable; -import com.vaadin.hilla.crud.ListRepositoryService; - import com.vaadin.flow.server.auth.AnonymousAllowed; +import com.vaadin.flow.spring.data.jpa.ListRepositoryService; +import com.vaadin.hilla.BrowserCallable; @BrowserCallable @AnonymousAllowed public class PersonListOnlyService extends ListRepositoryService { + PersonListOnlyService(PersonRepository repository) { + super(repository); + } + } diff --git a/packages/java/tests/spring/react-grid-test/src/main/java/com/vaadin/hilla/test/reactgrid/PersonService.java b/packages/java/tests/spring/react-grid-test/src/main/java/com/vaadin/hilla/test/reactgrid/PersonService.java index 82cbb74dde..719bc03f1a 100644 --- a/packages/java/tests/spring/react-grid-test/src/main/java/com/vaadin/hilla/test/reactgrid/PersonService.java +++ b/packages/java/tests/spring/react-grid-test/src/main/java/com/vaadin/hilla/test/reactgrid/PersonService.java @@ -1,13 +1,15 @@ package com.vaadin.hilla.test.reactgrid; -import com.vaadin.hilla.BrowserCallable; -import com.vaadin.hilla.crud.CrudRepositoryService; - import com.vaadin.flow.server.auth.AnonymousAllowed; +import com.vaadin.flow.spring.data.jpa.CrudRepositoryService; +import com.vaadin.hilla.BrowserCallable; @BrowserCallable @AnonymousAllowed public class PersonService extends CrudRepositoryService { + PersonService(PersonRepository repository) { + super(repository); + } } diff --git a/packages/java/tests/spring/react-grid-test/src/main/java/com/vaadin/hilla/test/reactgrid/entityreferences/EmployeeService.java b/packages/java/tests/spring/react-grid-test/src/main/java/com/vaadin/hilla/test/reactgrid/entityreferences/EmployeeService.java index 870c36521b..13ab9d47c8 100644 --- a/packages/java/tests/spring/react-grid-test/src/main/java/com/vaadin/hilla/test/reactgrid/entityreferences/EmployeeService.java +++ b/packages/java/tests/spring/react-grid-test/src/main/java/com/vaadin/hilla/test/reactgrid/entityreferences/EmployeeService.java @@ -1,13 +1,16 @@ package com.vaadin.hilla.test.reactgrid.entityreferences; -import com.vaadin.hilla.BrowserCallable; -import com.vaadin.hilla.crud.ListRepositoryService; - import com.vaadin.flow.server.auth.AnonymousAllowed; +import com.vaadin.flow.spring.data.jpa.ListRepositoryService; +import com.vaadin.hilla.BrowserCallable; @BrowserCallable @AnonymousAllowed public class EmployeeService extends ListRepositoryService { + public EmployeeService(EmployeeRepository repository) { + super(repository); + } + } diff --git a/packages/java/tests/spring/react-grid-test/src/test/java/com/vaadin/hilla/test/reactgrid/GridUseDataProviderHookIT.java b/packages/java/tests/spring/react-grid-test/src/test/java/com/vaadin/hilla/test/reactgrid/GridUseDataProviderHookIT.java index 519c4e43d7..3883995df8 100644 --- a/packages/java/tests/spring/react-grid-test/src/test/java/com/vaadin/hilla/test/reactgrid/GridUseDataProviderHookIT.java +++ b/packages/java/tests/spring/react-grid-test/src/test/java/com/vaadin/hilla/test/reactgrid/GridUseDataProviderHookIT.java @@ -1,11 +1,11 @@ package com.vaadin.hilla.test.reactgrid; -import com.vaadin.flow.component.button.testbench.ButtonElement; -import com.vaadin.flow.component.textfield.testbench.TextFieldElement; -import com.vaadin.testbench.TestBenchElement; import org.junit.Assert; import org.junit.Test; +import com.vaadin.flow.component.button.testbench.ButtonElement; +import com.vaadin.flow.component.textfield.testbench.TextFieldElement; + public class GridUseDataProviderHookIT extends AbstractGridTest { protected String getTestPath() { diff --git a/packages/java/tests/spring/react-grid-test/src/test/java/com/vaadin/hilla/test/reactgrid/ReadOnlyGridWithHeaderFilterIT.java b/packages/java/tests/spring/react-grid-test/src/test/java/com/vaadin/hilla/test/reactgrid/ReadOnlyGridWithHeaderFilterIT.java index edd03b30b4..2a5d1ee5b2 100644 --- a/packages/java/tests/spring/react-grid-test/src/test/java/com/vaadin/hilla/test/reactgrid/ReadOnlyGridWithHeaderFilterIT.java +++ b/packages/java/tests/spring/react-grid-test/src/test/java/com/vaadin/hilla/test/reactgrid/ReadOnlyGridWithHeaderFilterIT.java @@ -4,14 +4,14 @@ import java.util.Locale; import java.util.function.Consumer; -import com.vaadin.hilla.crud.filter.PropertyStringFilter.Matcher; import org.junit.Test; import com.vaadin.flow.component.datepicker.testbench.DatePickerElement; -import com.vaadin.flow.component.timepicker.testbench.TimePickerElement; import com.vaadin.flow.component.select.testbench.SelectElement; import com.vaadin.flow.component.textfield.testbench.NumberFieldElement; import com.vaadin.flow.component.textfield.testbench.TextFieldElement; +import com.vaadin.flow.component.timepicker.testbench.TimePickerElement; +import com.vaadin.flow.spring.data.filter.PropertyStringFilter.Matcher; import com.vaadin.testbench.TestBench; import com.vaadin.testbench.TestBenchElement; import com.vaadin.testbench.elementsbase.Element;