This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) | |
@ExtendWith(VertxExtension.class) | |
public class ComponentTests extends AbstractContainerBaseTest { | |
@BeforeAll | |
static void setup(Vertx vertx, | |
VertxTestContext testContext) { | |
vertx.deployVerticle(new MigrationVerticle(), testContext.succeeding(migrationVerticleId -> | |
vertx.deployVerticle(new ApiVerticle(), testContext.succeeding(apiVerticleId -> | |
testContext.completeNow())))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MetricsRouter { | |
/** | |
* Set metrics routes | |
* | |
* @param router Router | |
*/ | |
public static void setRouter(Router router) { | |
router.route("/metrics").handler(PrometheusScrapingHandler.create()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HealthCheckRouter { | |
/** | |
* Set health check routes | |
* | |
* @param vertx Vertx context | |
* @param router Router | |
* @param dbClient PostgreSQL pool | |
*/ | |
public void setRouter(Vertx vertx, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainVerticle extends AbstractVerticle { | |
private static final Logger LOGGER = LoggerFactory.getLogger(MainVerticle.class); | |
@Override | |
public void start() { | |
final long start = System.currentTimeMillis(); | |
deployMigrationVerticle(vertx) | |
.flatMap(migrationVerticleId -> deployApiVerticle(vertx)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MigrationVerticle extends AbstractVerticle { | |
@Override | |
public void start(Promise<Void> promise) { | |
final Configuration config = DbUtils.buildMigrationsConfiguration(); | |
final Flyway flyway = new Flyway(config); | |
flyway.migrate(); | |
promise.complete(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ApiVerticle extends AbstractVerticle { | |
private static final Logger LOGGER = LoggerFactory.getLogger(ApiVerticle.class); | |
@Override | |
public void start(Promise<Void> promise) { | |
final PgPool dbClient = DbUtils.buildDbClient(vertx); | |
final BookRepository bookRepository = new BookRepository(); | |
final BookService bookService = new BookService(dbClient, bookRepository); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BookRepository { | |
private static final Logger LOGGER = LoggerFactory.getLogger(BookRepository.class); | |
private static final String SQL_SELECT_ALL = "SELECT * FROM books LIMIT #{limit} OFFSET #{offset}"; | |
private static final String SQL_SELECT_BY_ID = "SELECT * FROM books WHERE id = #{id}"; | |
private static final String SQL_INSERT = "INSERT INTO books (author, country, image_link, language, link, pages, title, year) " + | |
"VALUES (#{author}, #{country}, #{image_link}, #{language}, #{link}, #{pages}, #{title}, #{year}) RETURNING id"; | |
private static final String SQL_UPDATE = "UPDATE books SET author = #{author}, country = #{country}, image_link = #{image_link}, " + | |
"language = #{language}, link = #{link}, pages = #{pages}, title = #{title}, year = #{year} WHERE id = #{id}"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BookService { | |
private static final Logger LOGGER = LoggerFactory.getLogger(BookService.class); | |
private final PgPool dbClient; | |
private final BookRepository bookRepository; | |
public BookService(PgPool dbClient, | |
BookRepository bookRepository) { | |
this.dbClient = dbClient; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BookRouter { | |
private final Vertx vertx; | |
private final BookHandler bookHandler; | |
private final BookValidationHandler bookValidationHandler; | |
public BookRouter(Vertx vertx, | |
BookHandler bookHandler, | |
BookValidationHandler bookValidationHandler) { | |
this.vertx = vertx; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BookHandler { | |
private static final String ID_PARAMETER = "id"; | |
private static final String PAGE_PARAMETER = "page"; | |
private static final String LIMIT_PARAMETER = "limit"; | |
private final BookService bookService; | |
public BookHandler(BookService bookService) { | |
this.bookService = bookService; |
NewerOlder