All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Springdoc library, to enrich the project with two new features:
- Generation of an OpenAPI 3.0 spec file, akin to the Trebol API's
- Generation of a Swagger UI page and endpoint.
- Follow new specification for error messages
- Introduce new model class
AppError
- Make the
ExceptionsControllerAdvice
use this new class on all its methods
- Introduce new model class
- Rename all references of the word
Sell
andSales
toOrder
andOrders
respectively- REST API endpoints
/data/sales
->/data/orders
/data/sell_statuses
->/data/order_statuses
- Hardcoded Spring Security authorities
sales:(create|read|update|delete)
->orders:(...)
sell_statuses:(create|read|update|delete)
->order_statuses:(...)
- SQL schema tables, columns, constraints, indexes and initial values
- Entity table mappings included as well
- Custom properties
trebol.api.able-to-edit-sales-after-being-processed
- to
trebol.api.able-to-edit-orders-after-being-processed
- to
- Class names, by package
org.trebol.api.
models.
SellPojo
->OrderPojo
SellDetailPojo
->OrderDetailPojo
SellStatusPojo
->OrderStatusPojo
services.
(for both interfaces and implementations)SalesProcessService
->OrdersProcessService
org.trebol.jpa.
entities.
(and their QueryDSL counterparts)Sell
->Order
SellDetail
->OrderDetail
SellStatus
->OrderStatus
repositories.
SalesRepository
->OrdersRepository
SellDetailsRepository
->OrderDetailsRepository
SellStatusesRepository
->OrderStatusesRepository
sortspecs.
SalesSortSpec
->OrdersSortSpec
SellStatusesSortSpec
->OrderStatusesSortSpec
services.
(for both interfaces and implementations)crud.
SalesCrudService
->OrdersCrudService
SellStatusesCrudService
->OrderStatusesCrudService
patch.
SalesPatchService
->OrdersPatchService
SellStatusesPatchService
->OrderStatusesPatchService
conversion.
SalesConverterService
->OrdersConverterService
SellStatusesConverterService
->OrderStatusesConverterService
predicates.
SalesPredicateService
->OrdersPredicateService
SellStatusesPredicateService
->OrderStatusesPredicateService
- And all other constant and variable names that reference them
- REST API endpoints
- remove
CustomerPojo
andSalespersonPojo
classes- the
OrderPojo
class now relates to two instances ofPersonPojo
instead
- the
- Change status codes for most
/data
endpoints- All POST requests return 201, except for three specific paths
/data/orders/confirmation
/data/orders/rejection
/data/orders/completion
- All PUT,PATCH,DELETE,OPTIONS requests return 204
- All POST requests return 201, except for three specific paths
- Remove duplicated functionality endpoint
/public/checkout/result/{token}
- Served the same purpose as
/public/receipt/{token}
- Served the same purpose as
- Remove support for paths with leading slash
- For example,
/public/checkout/
is no longer accepted, only/public/checkout
- For example,
- BREAKING CHANGE: Updated supported Java version to 17 LTS
(although the folks at whichjdk.com recommend migrating to 21, this is the best choice
compatibility-wise, also supported by SonarQube static analysis)
- Artifact Id was given suffix
-java17
to reflect this change in base Java version
- Artifact Id was given suffix
- Updated project dependencies
- spring boot starter parent pom
2.7.18
->3.2.9
- lombok
1.18.26
->1.18.34
(version inherited fromspring-boot-dependencies
) - h2 database
2.1.214
->2.1.220
- spring boot starter parent pom
- Many minor changes required to keep things running under these new dependencies
- Most
javax
-prefixed libraries now use thejakarta
-prefix instead (with the exception ofjavax.crypto
)querydsl
also needed to be aware of this as a "classifier"
- Migrate
SecurityConfig
following the official guides by Spring Security (1) (2) (3)- Drop
WebSecurityConfigurerAdapter
interface- Instead of implement
configure
method; declare a bean of typeSecurityFilterChain
- Instead of implement
- Include
AuthenticationManager
andDaoAuthenticationProvider
beans - Configure
HttpSecurity
with newer arrow function-based syntax
- Drop
- Most
- Update GitHub issue templates, contribution guidelines and reformat
*.md
files - Removed properties in
pom.xml
that were only used once - Updated project dependencies
- lombok
1.18.24
->1.18.26
- h2 database
2.1.212
->2.1.214
- lombok
- Missing validation for request bodies of
PUT
methods in/data/*
controllers
- Project-wide clean up (re-indentation & import optimization)
- New indentation rules set in
.editorconfig
- New indentation rules set in
- Raise an exception when no payment type is specified
- Unintended errors during checkout
- Description of each sell detail would not be included
- New sales would not have an initial status or registered payment type
- Billing address was required for non-enterprise customers>
- Support for partial updates using
PATCH
request in these endpoints/data/products
/data/sales
/data/users
/data/images
/data/product_categories
/data/shippers
/data/product_lists
- Update
CrudService
signature methodsupdate
- now meant as a method to fully update a data registry or itempartialUpdate
- new method; meant to update part(s) of a data registry or item (former behavior of theupdate
method)
- Update
PatchService
signature methodspatchExistingEntity
method relies on aMap<String, Object>
as first parameter, instead of a<P>
object- The previous method signature has been deprecated in favor of this one
- All
@Entity
classes implement a newDBEntity
interface- This interface declares a getter & setter pair for an
id
field. Most entities already had one anyway. - This is made to easily integrate the
partialUpdate
method with database numeric primary keys, represented by thefindById
repositories
- This interface declares a getter & setter pair for an
- Update base
CrudGenericService
implementationpartialUpdate
method is implemented, being fully-aware of theDBEntity
interface to pass theid
to an existing target entitycreate
andupdate
methods now share extremely similar logic- Their only difference is that the
update
method syncs the entityid
before being saved and flushed
- Their only difference is that the
prepareEntityWithUpdatesFromPojo
renamed toflushPartialChanges
- Remove method
prepareNewEntityFromInputPojo
- Instead of overriding this method, implementations may directly override its containing
create
method
- Instead of overriding this method, implementations may directly override its containing
- Remove method
persist
- This two-line method started making things a bit confusing... (!?)
- (note to self: never excuse a two-line method to duplicate code refactoring)
- Scope and flows of data have changed
- Entity classes' copy constructors are very often used, so now these never care for entity relationships
- EXCEPT when it is explicitly stated otherwise! These exceptions were made (from-to):
Customer
->Person
Salesperson
->Person
Sell
->SellStatus
Sell
->PaymentType
Sell
->BillingType
User
->UserRole
- EXCEPT when it is explicitly stated otherwise! These exceptions were made (from-to):
ConverterService
s now take care of one-to-one entity relationships at mostCrudService
s now take care of all entity relationships not covered by other cases- Pojo classes with
id
fields have been stripped of them; only entities holdid
fields now
- Entity classes' copy constructors are very often used, so now these never care for entity relationships
- Calls to
/checkout
using an invalid sell will output a400
error (bad input from user) instead of500
(bad state of the server) - Add a check in two
GenericCrudService
methods,partialUpdate
andupdate
, both overloaded with a QueryDSLPredicate
as a second method argument- Validate that said
Predicate
only ever matches one record - This behavior could change in the future, but for now it is a deliberate choice to avoid them affecting more than one registry at a time
- Validate that said
- Stock JUnit run configuration for IntelliJ
- Raised coverage percentage from
51.4%
to73.4%
- Now excluding API models and JPA entities
- Added tests for all remaining security components as well as the Webpay Plus integration service
This is the first tagged version that is filed under the new project artifact,
trebol-backend-monolith
.
- Issue and Pull Request templates
- .editorconfig file
- Enforces Unix-style line endings (LF)
PhoneNumber
annotation for validating phone numbers - Thank you@mepox
- Use custom
PhoneNumberValidator
, subclass ofjavax.validation.ValidationConstraint
, which validates using regular expression - Configure the regular expression through
trebol.validation.phonenumber-regexp
inapplication.properties
- Use custom
- Account protection mechanism by
user_id
- Thank you@mepox
- Any attempt to delete one certain user account will be cancelled
- The protected user account must have the same
id
indicated bytrebol.security.protected-account-id
inapplication.properties
- Spring Security Test dependency for integration tests that deal with Spring Security mechanisms
- [WIP] BREAKING CHANGE Split logic in services that implement
ICrudJpaService
(nowCrudService
) and extendGenericCrudJpaService
(nowCrudGenericService
)- Introduce
PatchService<P, E>
to keep specific domain-dependant boilerplate code for updating entities before they are submitted to database- This new, separate interface inherits the
applyChangesToExistingEntity
method fromITwoWayConverterJpaService
(nowConverterService
) - The original method in
ITwoWayConverterJpaService
(nowConverterService
) has been deprecated
- This new, separate interface inherits the
- Break down the steps taken on each method in the public API of
GenericCrudJpaService
(nowCrudGenericService
) and its sub-implementations, by introducing these overridableprotected
methodsprepareEntityWithUpdatesFromPojo
validateInputPojoBeforeCreation
prepareNewEntityFromInputPojo
- Introduce sub-interfaces from
ICrudJpaService
(nowCrudService
),PatchService
andITwoWayConverterJpaService
(nowConverterService
)- This increases the accuracy of type-safe dependency injection. Specially important for mocks and unit testing.
- Introduce
- UsersConverterJpaServiceImpl - refactor
convertToNewEntity
since it tag as cyclomatic issue - SalesConverterJpaServiceImpl, SalesProcessServiceImpl - add string constants
- BREAKING CHANGE: Rename table names to follow the naming convention - Thank you
@mepox
products_categories
->product_categories
products_images
->product_images
sales_statuses
->sell_statuses
app_users_roles
->app_user_roles
app_users_roles_permissions
->app_user_role_permissions
- Update GitHub Actions workflow
actions/checkout
|v2 ->
v3`actions/setup-java
|v1 ->
v3`- Following Switching to V2 guide
- Chose
temurin
distro, maintained by the Eclipse foundation
actions/cache
|v1 ->
v3`
- Update to the latest Spring Boot patch (as of Oct 12th, 2022)
spring-boot-starter-parent
-2.6.4
to2.6.12
- Take advantage of Project Lombok annotations for entity and model classes
- Use entrySet in place of keySet for better iteration in CorsConfigurationSourceBuilder
- Enforce a better naming scheme for classes and methods
- No interface names with capital initial
I
- Class and method names should explain roles and purposes from the get-go
- It is preferable to avoid class names over 50 characters long
- Test classes must always be suffixed with
Test
- Test methods should be named using
underscores_and_lowercase
- Spring component class names should be suffixed with their respective base type
name (
Service
,Controller
,Config
,Repository
)
- No interface names with capital initial
- REST Assured dependency, as the Spring Framework provides an easy and working
MockMvc
- ProductListJpaCrudServiceImpl - add unit tests
- ReceiptServiceImpl - add unit tests
- SalesProcessServiceImpl - add unit tests
- ProfileServiceImpl - add unit tests
- RegistrationServiceImpl - add unit tests
- Refactor PhoneNumberValidatorTest - resolve code smell tag by sonarqube and @ParameterizedTest is the solution
- Additional entry in TestConstants
int 1
- CheckoutServiceImpl - add more coverage for method "confirmTransaction, generatePageUrl"
- CompanyServiceImpl - validate the proper mapping behaviour of method "readDetails"
- Add
mockito-inline
dependency to create inline mocks - Thank you@NyorJa
- Useful to mock final classes and methods, also for having constant regex
- Add TestConstants to hold some static final values for use with mocks - Thank you
@NyorJa
- Introduce unit tests for 15 converter services - Thank you
@NyorJa
BillingCompaniesConverterJpaServiceImpl
BillingTypesConverterJpaServiceImpl
CustomersConverterJpaServiceImpl
ImagesConverterJpaServiceImpl
PeopleConverterJpaServiceImpl
ProductCategoriesConverterJpaServiceImpl
ProductListsConverterJpaServiceImpl
ProductsConverterJpaServiceImplTest
SalesStatusesConverterJpaServiceImplTest
SellStatusesConverterJpaServiceImplTest
ShippersConverterJpaServiceImplTest
UserRolesConverterJpaServiceImplTest
UsersConverterJpaServiceImplTest
- Refactor out test boilerplate using
@InjectMocks
- Introduce Spring Security integration tests for custom Filters
JwtGuestAuthenticationFilter
JwtLoginAuthenticationFilter
- Using a better fitted java11 method of String to check for emptiness - Thank you
@NyorJa
From here and below, the project used to have another artifact name and version.
It was reset because the author didn't feel that the software was very polished,
so in turn, tagging versions as v3.0
and onwards felt misleading.
- Support sorting product lists by item count (the amount of products held on each)
- Properties to configure the guest user (a public account only enabled for checking out)
trebol.security.guestUserEnabled
- Can be true or falsetrebol.security.guestUserName
- Any non-blank string; also acts as its password
- Property to configure max allowed nested depth while fetching categories
- BREAKING CHANGE:
SellDetail
entity now has adescription
field, which is meant to describe and summarize the detail in a human-readable format - When fetching data, filters by category may include descendant of lower level categories
- For example, assumming that category A includes subcategories AB and AC, filtering 'by category A' may include children from subcategories AB and AC as well
- This applies for filtering categories and products
- Behavior before was to fetch only direct descendants of a given category
- Implement three API resources to interact with sales after a checkout process from the customer
/data/sales/confirmation
- To confirm the sell (when logistics is good to go)/data/sales/rejection
- To reject the sell (for cases such as, when no stock is available)/data/sales/completion
- To complete the sell, or otherwise mark it as delivered
- Introduce a service interface for sending notification mails to customers and owners alike during checkout steps
- Include Mailgun HTTP API implementation
- To use it, the
mailgun
spring profile should be active - An empty configuration file is provided
- To use it, the
- Include Mailgun HTTP API implementation
-
Use Project Lombok
-
The transaction token for the (frontend) checkout result page is passed through query param instead of path param
-
Default
GET /data/sales
sort order is by descendingbuyOrder
-
(Temporary) Disable regex pattern validation for phone numbers
-
Further divide logic for sorting/pagination/filtering into different services
-
Bump dependencies
spring-boot-starter-parent
from2.6.2
to2.6.4
h2database
frominherited
to2.1.212
jjwt-*
from0.11.2
to0.11.5
unirest-java
from3.13.6
to3.13.8
-
Bump plugins
jacoco-maven-plugin
from0.8.5
to0.8.8
- Incorrect amount value given to Webpay (net value instead of total value)
- Two very important equations when calculating sell totals
- Incorrect protocol for MariaDB JDBC URL
- Webpay Plus was unable to redirect users to the callback URL; added
null
in list of allowed CORS origins - Incongruent binding of query parameters to data search filters for products
- Guest can call the
/access
API and be returned a200 OK
response - Support for fetching an individual sell data (details included) when requested with
buyOrder
query param - Change integration type for payments with Webpay Plus when production mode is not enabled
- Now uses
TEST
as recommended by@TransbankDevelopers
- Was using
MOCK
which is not very well documented
- Now uses
- Reformat
pom.xml
file- Add comments
- Update properties
- Add keys for code coverage ratio
- Add keys to version of all dependencies and plugins (except those inferred from parent)
- Rename some properties
- Remove unused
jcenter
repository - Bump plugins
maven-compiler-plugin
- from3.1
to3.9.0
maven-war-plugin
- from3.3.1
to3.3.2
- Remove old
Oracle Java EE endorsed API
artifacts- In reality, these have been replaced by Jakarta EE endorsed API
- Bump Spring Boot Starter POM to v2.6.2 [BREAKING CHANGE]
- Deprecated/unsupported properties; update configuration described in
application.properties
- Deprecated/unsupported properties; update configuration described in
- Update license file; add headers to all source files
- Creating products through a
POST /data/products
call does not cascade creation of other entities
- Clean up deprecated API resources
/public/categories
/public/products
/public/products/{barcode}
- Remove any reference to the depreacted
amount
property in the Receipt entity
- CRUD operations support for
Product List
- Also for managing contents of individual lists, as described by resource
/data/product_list_contents
in the API
- Also for managing contents of individual lists, as described by resource
- Schema SQL script for MariaDB
- Maximum page size limit, parametrizable through
properties
files
- Updated security rule for
GET /data/products
to: do not require any authority - Simplified method signature for
readMany
method inIDataController
- Updated BD schema diagram
schema.png
- Clean up deprecated resources
/data/customers/{idNumber}
/data/images/{code}
/data/product_categories/{parentCode}
/data/products/{barcode}
/data/sales/{buyOrder}
/data/salespeople/{idNumber}
/data/users/{name}
/public/categories/{parentId}
- Paths to be superseded
/public/products
/public/products/{barcode}
- Support for sorting data through query parameters
- Unable to update products due to possible null pointer in description
- CORS mappings for
/access
API
- Added unit tests for predicate services (responsible for parsing query params to filtering conditions)
- Improved quality of some unit tests
- Issues during checkout:
- Incorrect validation API endpoints for integrating Webpay Plus SDK
- JPA transactions failing between service calls
- Data missing in receipt after checkout is complete
- Using SonarCloud to automate project building and code analyzing
- Include maintainability and reliability badges, generated by SonarCloud, in
README.md
- Support for query parameters in PUT requests to
/data
resources - Unit tests providing an approximate of 20% codebase coverage
- Database schema file
/schema.png
- Removed request authentication for remapped paths in
/data/product_categories/*
to make them publicly available to anonymous users - Updated
Person
schema by splittingname
property into two propertiesfirstName
andlastName
- Updated
Sell
schema by adding propertiestaxValue
,transportValue
,totalValue
andtotalItems
- Updated
Receipt
schema by adding propertiestoken
,taxValue
,transportValue
,totalValue
andtotalItems
- Updated
SellDetail
andReceiptDetail
schemas by adding propertyunitValue
in both - Updated
ProductCategory
schema by changing data type ofcode
frominteger
tostring
- Delegate API authorized access requirements to each REST controller method, instead of using HttpSecurity-centric configuration
- Improvements on JPA entities
BillingCompany
- added unique constraint onname
BillingType
- added unique constraint onname
Image
- added unique constraint oncode
,filename
andurl
Param
- added unique constraint that uses bothcategory
andname
PaymentType
- added unique constraint onname
Permission
- added unique constraint oncode
Person
- added index tofirstName
andlastName
Product
- added index toname
Sell
- added index todate
andtransactionToken
SellStatus
- added unique constraint oncode
andname
- Refactored services in
org.trebol.jpa
package for better separation of concerns
- Path
/public/categories
and/public/categories/{parentId}
, mapped underPublicCategoriesController
- Thanks @ParundeepSingh - Property
amount
ofSell
and their getters; must usetotalValue
instead - Parameterized paths
/data/customers/{idNumber}
replaced by/data/customers?idNumber={}
/data/images/{code}
replaced by/data/images?code={}
/data/products/{code}
replaced by/data/products?barcode={}
/data/sales/{buyOrder}
replaced by/data/sales?buyOrder={}
/data/salespeople/{idNumber}
replaced by/data/salespeople?idNumber={}
/data/users/{name}
replaced by/data/users?name={}
- Entity class
Session
, not used in the codebase
- Clean up entities and remove redundant annotation values - Thanks to @trangntt-016
- Fix resolving paging parameters where it would always get the default value.
- Restrict users from deleting their own account - Thanks to @trangntt-016
/public/receipt/{id}
updated withid
parameter now calledtoken
and referencing sell payment token
- Fix default application parameters related to the checkout/payment service
- Self-callback URL after clients navigates checkout
- Success/Failure page URL to send customers to, after checkout
- Add missing sales filters required to fetch data during the checkout flow
- Add missing mock data into
data.sql
that is needed to invoke/public/about
ReceiptPojo
now usesInstant
to represent dates, just likeSell
andSellPojo
First public version.