Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove tkit dependencies #33

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ You can run your application in dev mode that enables live coding using:

You can run tests from your IDE or via Maven. Simply run `./mvnw test ` or `./mvnw package`

## Tkit quarkus

Adding tkit libs to our project gives us several new features. Check the logs for example, all our business methods are now logged and timed.
The REST API now handles exceptions gracefully(as JSON response), and we get server side pagination with very little effort.
Our tests are now real integration tests with real postgres DB, and are stuitable for CI envs.

maybeec marked this conversation as resolved.
Show resolved Hide resolved
## Access your REST endpoint

Go to http://localhost:8080/animals
Expand Down
60 changes: 23 additions & 37 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@
<scope>provided</scope>
<version>4.3.1</version>
</dependency>
<!-- Json logging / Enable this if you do not use tkit-json-log -->
<!-- <dependency>-->
<!-- <groupId>io.quarkus</groupId>-->
<!-- <artifactId>quarkus-logging-json</artifactId>-->
<!-- </dependency>-->

<!-- JSON logging -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-logging-json</artifactId>
</dependency>

<!-- Lombok, which does what java should do out of the box -->
<dependency>
Expand Down Expand Up @@ -137,51 +138,36 @@
<scope>provided</scope>
</dependency>

<!-- 1000kit extensions-->
<dependency>
<groupId>org.tkit.quarkus</groupId>
<artifactId>tkit-quarkus-rest</artifactId>
<version>2.4.0</version>
</dependency>
<!-- Business method logger... -->
<dependency>
<groupId>org.tkit.quarkus</groupId>
<artifactId>tkit-quarkus-log-cdi</artifactId>
<version>1.4.5</version>
</dependency>
<!-- REST communication logger.. -->
<!--Testing -->
<dependency>
<groupId>org.tkit.quarkus</groupId>
<artifactId>tkit-quarkus-log-rs</artifactId>
<version>1.4.5</version>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<!-- Extended structured JSON logger -->
<dependency>
<groupId>org.tkit.quarkus</groupId>
<artifactId>tkit-quarkus-log-json</artifactId>
<version>1.4.5</version>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>

<!-- Component level integration tests -->
<dependency>
<groupId>org.tkit.quarkus</groupId>
<artifactId>tkit-quarkus-test</artifactId>
<version>1.12.0</version>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.15.2</version>
<scope>test</scope>
</dependency>

<!--Testing -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>1.15.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>1.15.2</version>
<scope>test</scope>
</dependency>

</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ public abstract class ApplicationPersistenceEntity {
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Version
private Integer modificationCounter;

/**
Expand All @@ -42,7 +43,6 @@ public void setId(Long id) {
this.id = id;
}

@Version
public Integer getModificationCounter() {

return this.modificationCounter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponses;
import org.springframework.data.domain.Page;
import org.tkit.quarkus.rs.models.PageResultDTO;

import com.devonfw.quarkus.productmanagement.logic.UcFindProduct;
import com.devonfw.quarkus.productmanagement.logic.UcManageProduct;
Expand All @@ -47,14 +46,9 @@ public class ProductRestService {
@Inject
UcManageProduct ucManageProduct;

@APIResponses({
@APIResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = PagedProductResponse.class))),
@APIResponse(responseCode = "500") })
@APIResponses({ @APIResponse(responseCode = "200", description = "OK"), @APIResponse(responseCode = "500") })
@Operation(operationId = "Get Products", description = "Returns list of Products matching given criteria, uses pagination")
@GET
// REST service methods should not declare exceptions, any thrown error will be transformed by exceptionMapper in
// tkit-rest
// We did not define custom @Path - so it will use class level path
public Page<ProductDto> getAll(@BeanParam ProductSearchCriteriaDto dto) {

return this.ucFindProduct.findProducts(dto);
Expand Down Expand Up @@ -136,8 +130,4 @@ public ProductDto deleteProductById(@Parameter(description = "Product unique id"

return this.ucManageProduct.deleteProduct(id);
}

private static class PagedProductResponse extends PageResultDTO<ProductDto> {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import java.util.List;

import org.mapstruct.Mapper;
import org.tkit.quarkus.rs.mappers.OffsetDateTimeMapper;

import com.devonfw.quarkus.productmanagement.domain.model.ProductEntity;
import com.devonfw.quarkus.productmanagement.service.v1.model.NewProductDto;
import com.devonfw.quarkus.productmanagement.service.v1.model.ProductDto;

//mapstruct will generate an impl class(CDI bean, see pom.xml) from this interface at compile time
@Mapper(uses = OffsetDateTimeMapper.class)
@Mapper
public interface ProductMapper {

ProductDto map(ProductEntity model);
Expand Down
20 changes: 6 additions & 14 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ quarkus.flyway.migrate-at-start=true
quarkus.flyway.baseline-on-migrate=true
quarkus.flyway.baseline-version=0

# logging configuration
# which packages should be automatically logged by tkit cdi logger
quarkus.tkit.log.packages=org.tkit,com.devonfw
# you can supress logs from classes by annotations or regex
quarkus.tkit.log.ignore.pattern=.*MapperImpl

# Metrics
# all of these are default values, metrics would work just fine if you remove it
quarkus.micrometer.binder-enabled-default=true
Expand All @@ -35,18 +29,16 @@ quarkus.micrometer.binder.http-server.enabled=true
# during dev, print sql produced by hibernate, disable in prod(default)
%dev.quarkus.hibernate-orm.log.sql=true
# disable json logs for better readability
%dev.quarkus.tkit.log.console.json=false
#if you dont use tkit-json=log but standard quarkus-json-log, use this instead
#%dev.quarkus.log.console.json=false
%dev.quarkus.log.console.json=false
# if you want to see opentracing values in
%dev.quarkus.log.console.format=%d{HH:mm:ss} %-5p traceId=%X{traceId}, parentId=%X{parentId}, spanId=%X{spanId}, sampled=%X{sampled} [%c{2.}] (%t) %s%e%n


# TEST
%test.quarkus.tkit.log.console.json=false
# Test DB is provided by tkit test containers, URL will be set dynamically
%test.quarkus.datasource.password=demo
%test.quarkus.datasource.jdbc.driver=org.testcontainers.jdbc.ContainerDatabaseDriver
%test.quarkus.datasource.jdbc.url=jdbc:tc:postgresql:11.5:///demo_db
%test.quarkus.datasource.username=demo
%test.quarkus.hibernate-orm.database.generation=drop-and-create
%test.quarkus.hibernate-orm.log.sql=true
%test.quarkus.datasource.password=demo
%test.quarkus.flyway.clean-at-start=true

ryuk.container.image=testcontainersofficial/ryuk
Loading