Learning Jmix through real-world app video series: Rent-your-Stuff

Issue #20 - Register product stock items - Part 1

We will enhance our domain model and allow users to register stock items for products.

  • create stock item entity
  • create a product - stock item association
  • add stock item UI to the product detail screen
  • reorganize product edit screen with the help of Tabs

Issue #21 - Register product stock items - Part 2 - Tests

Ensure Stock Items can be created during Product creation.

  • refactor ProductEditTest to JUnit 5 nested classes
  • create stock item creation test case during product creation
  • encounter problem with failing *BrowseTest

Issue #22 - Remove flakiness from UI integration tests

After finding out about the problem with the UI integration tests in video #21, lets dig deeper into the problem and resolve the root cause of the flaky tests

  • see tests running in isolation, but not in the whole suite
  • debug tests to find problem of incorrect entity comparison
  • find out that multiple screens are still open from other tests
  • reason about shared state of “opened screens”
  • fix by clearing up all screens at the beginning of each test case

Issue #23 - Introduce Multi Tenancy - Part 1

In order to offer the application to multiple clients, let’s enhance the rent-your-stuff application with multi tenancy in order to create a real SaaS solution

  • add multi tenancy add on
  • enhance entities with @TenantId
  • adjust user management UI to support multi tenancy

Issue #24 - Introduce Multi Tenancy - Part 2 - Make Tests run as tenant

Let’s make our tests run as a particular tenant to mirror the actual user scenario.

  • create tenant & user on the fly before each test
  • creating a JUnit 5 extension to automatically setup tenant creating before each test

Issue #25 - Create Rental Order - Part 1 - Domain Model

Let’s enhance our domain model and add a central piece to the table: the rental order

  • create order & order line entity
  • use association, composition for modeling out the connection
  • configure instance names for entities
  • use @SystemLevel to declare the “tenant” attribute as something that should not be used in UI code generation and UI components (like filter)

Issue #26 - Create Rental Order - Part 2 - Domain Model Validation Tests

This video is about adding validation tests for the new domain model of rental orders

  • create validation test for Order and OrderLine
  • check on @PresentOrFuture
  • talk about flakyness with LocalDateTime.now() in test cases
1 Like

Issue #27 - Create rental order - Part 3 - Custom Bean Validation

Let’s create a custom validation for a rental order: a valid rental period

  • create a custom validation annotation & ConstraintValidator class
  • refactor validation tests to create custom assertion methods

Issue #28 - Create rental order - Part 4 - Verify @InstanceName

The @InstanceName annotated method for the Order entity is going to be tested this time

  • create a test case for the Order::getInstanceName method
  • verify the injection mechanism of the @InstanceName methods works as expected

Issue #29 - Create rental order - Part 5 - Test data creation

In order to create a storage test for the order, let’s improve our test data creation approach a little bit. This video will guide you through this process:

  • add two depenencies: Lombok & MapStruct to your Jmix application
  • use Lombok’s @Builder annotation for a data class that only contains the business attributes
  • use MapStruct for mapping the data class to the JPA entity using the Jmix DataManager
  • create pre-build product data with the Products test bean
  • refactor the product storage test to use the new approach

Issue #30 - Create rental order - Part 5 - Order storage test

After the new test data creation approach, let’s use this for creating the order storage test

  • create test case for storing an order with order lines
  • generate custom assertions through assertj code generation

Issue #31 - Create rental order - Part 6 - Create CRUD order UI

After having the domain model in place, let’s start with a very simple UI for the order

  • generate UI for order management
  • talk about limitations of CRUD based UIs
  • explore possible improvements for the UI to make it more usable

order-screen-wireframe

Issue #32 - Search customer in order creation - Part 1 - Entity suggestion field

To improve user experience during order creation, let them search for customers directly in the screen

  • use Jmix’s entity suggestion field for faster search
  • define custom JQPL query for filtering customers
  • use action properties in XML to open the customer detail screen in DIALOG mode

Dear Mario,

I hope this message finds you well. I wanted to express my gratitude for your informative video series. I’ve learned a lot from it.
Regarding UI testing, I’ve been researching the most suitable approach for Jmix 2.0.1 and came across the “Masquerade” library for UI testing. I’d appreciate your guidance on whether I should use it. If you recommend it, could you provide some instructions or tips to ensure consistency with the content in your videos?

Thank you for your time and expertise.

Best regards,

Hi,

From my experience browser based e2e testing is comparably expensive and slow compared to other alternatives. Therefore I normally apply the pattern: if a specific functionality can be tested on a different level, I tend to do it there. In Jmix/Vaadin land this is UI integration tests. With those you are not able to test every situation (like client based in interactions, for example the date picker), but almost all logic based situations that you create through code.

But if you really need browser based testing and can live with the downsides it brings, then Masquerade seems to be a valid choice, as it knows all the Jmix specifics.

But I think it is not compatible with Vaadin 24 / Jmix 2.x yet.

Cheers
Mario

1 Like

Issue #33 - Search Customer in Order Creation - Part 2 - Test search functionality

After some small break (of almost two years :smiley:), here the second part of the search customer in order creation functionality.

Let’s verify the search behavior to ensure the query definition is working as expected

  • use SearchExecutor to perform the search programmatically
  • verify the results during the test
  • assure when selecting a search result, the customer has been assigned to the order
2 Likes

Issue #34 - Show customer details after selection - Part 1 - UI Logic

Let’s give our users a little more context when creating an order. Show Customer details after selection

  • conditionally show / hide components based on search selection
  • explain the way to align components on the help with the help of vbox / hbox

Let’s verify the search behavior to ensure the query definition is working as expected

Issue #35 - Show customer details after selection - Part 2 - Test UI behavior

The conditional UI logic from #34 should be tested. This is what we are doing in this video.

  • ensure customer details are displayed after selecting customer
  • ensure customer details are displayed when opening existing order with customer association
  • ensure customer search is active after removing customer
  • talk about Component::isVisible vs. Component::isVisibleRecursive

Issue #36 - Migrate Rental Period to Order - Part 1 - Database Migration

When business requirements change, so does the data model. Let’s move the rental period from the Order Line entity to the Order entity to simplify usage. For that we in this video:

  • create entity attributes in the Order entity
  • create a custom SQL Liquibase migration to migrate the data
1 Like

Issue #37 - Migrate Rental Period to Order - Part 2 - Test Liquibase migration

When business requirements change, so does the data model. Let’s move the rental period from the Order Line entity to the Order entity to simplify usage. For that we will, in this video:

  • create an Spring integration test that triggers the liquibase migration process
  • see how to programmatically trigger the migration process
  • learn how to override Spring beans for test scenarios
  • verify that the custom SQL based migration is doing the intended thing
1 Like