diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e37fcc9b..2ffb3551 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: distribution: temurin cache: maven - name: Build with Maven - run: mvn verify -Dquarkus.native.container-build=true -P native,ui,${{ matrix.flavor }} + run: mvn verify -Dquarkus.native.container-build=true -P native,${{ matrix.flavor }} ui-tests: name: UI Tests diff --git a/README.md b/README.md index 35f67170..56da3402 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Microservicio que expone los datos provenientes del `padrón reducido` de la SUN Puedes ejecutar la aplicación en modo desarrollo con: ```shell script -./mvnw compile quarkus:dev -Pstandalone-dev +./mvnw compile quarkus:dev ``` ### Iniciar UI diff --git a/pom.xml b/pom.xml index c55e8a48..a70dade7 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ quarkus-bom io.quarkus.platform - 2.7.5.Final + 2.8.0.Final true 3.0.0-M6 @@ -110,11 +110,11 @@ io.quarkus - quarkus-resteasy + quarkus-resteasy-reactive io.quarkus - quarkus-resteasy-jsonb + quarkus-resteasy-reactive-jsonb io.quarkus @@ -186,7 +186,13 @@ io.quarkus - quarkus-resteasy-qute + quarkus-resteasy-reactive-qute + + + + commons-io + commons-io + 2.11.0 @@ -325,6 +331,7 @@ + org.apache.maven.plugins maven-failsafe-plugin ${surefire-plugin.version} @@ -445,31 +452,6 @@ - - standalone - - standalone - - - - - maven-failsafe-plugin - ${surefire-plugin.version} - - - **/*StandaloneIT.java - - - - - - - - standalone-dev - - standalone - - standalone-distribution @@ -535,81 +517,6 @@ - - enterprise - - enterprise - - - - - maven-failsafe-plugin - ${surefire-plugin.version} - - - **/*EnterpriseIT.java - - - - - - - - enterprise-dev - - enterprise,dev - - - - - io.fabric8 - docker-maven-plugin - 0.39.1 - - ${skipTests} - - - docker.elastic.co/elasticsearch/elasticsearch:7.10.2 - elasticsearch - - - single-node - - - 9200:9200 - - - false - Elasticsearch: - default - cyan - - - - http://localhost:9200 - GET - 200 - - - - - - - - - - docker-start - compile - - stop - start - - - - - - - enterprise-distribution diff --git a/src/main/java/io/github/project/openubl/searchpe/bootstrap/SearchpeBootstrap.java b/src/main/java/io/github/project/openubl/searchpe/bootstrap/SearchpeBootstrap.java index 2fe3cfa2..8c3ab888 100644 --- a/src/main/java/io/github/project/openubl/searchpe/bootstrap/SearchpeBootstrap.java +++ b/src/main/java/io/github/project/openubl/searchpe/bootstrap/SearchpeBootstrap.java @@ -16,37 +16,22 @@ */ package io.github.project.openubl.searchpe.bootstrap; -import io.github.project.openubl.searchpe.models.jpa.entity.VersionEntity; -import io.github.project.openubl.searchpe.models.jpa.search.SearchpeNoneIndexer; +import io.github.project.openubl.searchpe.resources.BasicUserResource; import io.quarkus.runtime.StartupEvent; -import org.eclipse.microprofile.config.inject.ConfigProperty; -import org.hibernate.search.mapper.orm.session.SearchSession; +import org.jboss.logging.Logger; import javax.enterprise.event.Observes; -import javax.inject.Inject; import javax.inject.Singleton; import javax.transaction.Transactional; @Singleton public class SearchpeBootstrap { - @ConfigProperty(name = "quarkus.hibernate-search-orm.automatic-indexing.synchronization.strategy") - String searchOrmIndexSyncStrategy; + private static final Logger LOGGER = Logger.getLogger(BasicUserResource.class); - @Inject - SearchSession searchSession; - - /** - * If there is an upgrade of Version, the indexes in Elasticsearch should be deleted. - * This will work under the assumption that on upgrades the DB will delete all data before. - */ @Transactional void reindexSearchIndexes(@Observes StartupEvent ev) throws InterruptedException { - if (!searchOrmIndexSyncStrategy.equals(SearchpeNoneIndexer.BEAN_FULL_NAME)) { - if (VersionEntity.count() == 0) { - searchSession.massIndexer().startAndWait(); - } - } + LOGGER.info("SearchPE started"); } } diff --git a/src/main/java/io/github/project/openubl/searchpe/models/jpa/search/SearchpeNoneIndexer.java b/src/main/java/io/github/project/openubl/searchpe/models/jpa/search/SearchpeNoneIndexer.java deleted file mode 100644 index 25d22cd3..00000000 --- a/src/main/java/io/github/project/openubl/searchpe/models/jpa/search/SearchpeNoneIndexer.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2019 Project OpenUBL, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.github.project.openubl.searchpe.models.jpa.search; - -import org.hibernate.search.mapper.orm.automaticindexing.session.AutomaticIndexingSynchronizationConfigurationContext; -import org.hibernate.search.mapper.orm.automaticindexing.session.AutomaticIndexingSynchronizationStrategy; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Named; - -@ApplicationScoped -@Named(SearchpeNoneIndexer.BEAN_NAME) -public class SearchpeNoneIndexer implements AutomaticIndexingSynchronizationStrategy { - - public static final String BEAN_NAME = "searchpeNoneIndexer"; - public static final String BEAN_FULL_NAME = "bean:" + BEAN_NAME; - - @Override - public void apply(AutomaticIndexingSynchronizationConfigurationContext context) { - // Nothing to do since we don't want to index in Elasticsearch - } - -} diff --git a/src/main/java/io/github/project/openubl/searchpe/resources/ContribuyenteResource.java b/src/main/java/io/github/project/openubl/searchpe/resources/ContribuyenteResource.java index d7962c6d..30d68137 100644 --- a/src/main/java/io/github/project/openubl/searchpe/resources/ContribuyenteResource.java +++ b/src/main/java/io/github/project/openubl/searchpe/resources/ContribuyenteResource.java @@ -25,7 +25,6 @@ import io.github.project.openubl.searchpe.models.jpa.entity.ContribuyenteEntity; import io.github.project.openubl.searchpe.models.jpa.entity.ContribuyenteId; import io.github.project.openubl.searchpe.models.jpa.entity.VersionEntity; -import io.github.project.openubl.searchpe.models.jpa.search.SearchpeNoneIndexer; import io.github.project.openubl.searchpe.security.Permission; import io.github.project.openubl.searchpe.utils.ResourceUtils; import org.eclipse.microprofile.config.inject.ConfigProperty; @@ -44,6 +43,7 @@ import javax.annotation.security.RolesAllowed; import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Instance; import javax.inject.Inject; import javax.transaction.Transactional; import javax.validation.constraints.Max; @@ -57,8 +57,8 @@ @Path("/contribuyentes") public class ContribuyenteResource { - @ConfigProperty(name = "quarkus.hibernate-search-orm.automatic-indexing.synchronization.strategy") - String searchOrmIndexSyncStrategy; + @ConfigProperty(name = "quarkus.hibernate-search-orm.enabled") + Optional isESEnabled; @Inject VersionRepository versionRepository; @@ -67,7 +67,14 @@ public class ContribuyenteResource { ContribuyenteRepository contribuyenteRepository; @Inject - SearchSession searchSession; + Instance searchSession; + + private Optional getSearchSession() { + for (SearchSession session : searchSession) { + return Optional.of(session); + } + return Optional.empty(); + } @RolesAllowed({Permission.admin, Permission.search}) @Operation(summary = "Search contribuyentes", description = "Get contribuyentes in a page") @@ -83,10 +90,12 @@ public PageRepresentation getContribuyentes( @QueryParam("limit") @DefaultValue("10") @Max(1_000) Integer limit, @QueryParam("sort_by") @DefaultValue("name") List sortBy ) { - if (searchOrmIndexSyncStrategy.equals(SearchpeNoneIndexer.BEAN_FULL_NAME)) { + if (isESEnabled.isEmpty() || !isESEnabled.get()) { throw new NotFoundException(); } + SearchSession searchSession = getSearchSession().orElseThrow(() -> new IllegalStateException("Could not find a SearchSession available")); + Optional versionOptional = versionRepository.findActive(); if (versionOptional.isEmpty()) { PageRepresentation result = new PageRepresentation<>(); diff --git a/src/main/java/io/github/project/openubl/searchpe/resources/FrontendResource.java b/src/main/java/io/github/project/openubl/searchpe/resources/FrontendResource.java index f1711ad0..5a87f255 100644 --- a/src/main/java/io/github/project/openubl/searchpe/resources/FrontendResource.java +++ b/src/main/java/io/github/project/openubl/searchpe/resources/FrontendResource.java @@ -16,7 +16,6 @@ */ package io.github.project.openubl.searchpe.resources; -import io.github.project.openubl.searchpe.models.jpa.search.SearchpeNoneIndexer; import io.quarkus.qute.Location; import io.quarkus.qute.Template; import io.quarkus.qute.TemplateInstance; @@ -40,15 +39,15 @@ public class FrontendResource { @ConfigProperty(name = "quarkus.oidc.enabled") Optional isOidcEnabled; + @ConfigProperty(name = "quarkus.hibernate-search-orm.enabled") + Optional isESEnabled; + @ConfigProperty(name = "quarkus.http.auth.form.cookie-name") Optional formCookieName; @ConfigProperty(name = "quarkus.oidc.logout.path") Optional oidcLogoutPath; - @ConfigProperty(name = "quarkus.hibernate-search-orm.automatic-indexing.synchronization.strategy") - Optional esSyncStrategy; - @Authenticated @GET @Path("/settings.js") @@ -58,7 +57,7 @@ public TemplateInstance getSettingsJS() { .data("defaultAuthMethod", isOidcEnabled.isPresent() && isOidcEnabled.get() ? "oidc" : "basic") .data("formCookieName", formCookieName.orElse("")) .data("oidcLogoutPath", oidcLogoutPath.orElse("")) - .data("isElasticsearchEnabled", !Objects.equals(esSyncStrategy.orElse(""), SearchpeNoneIndexer.BEAN_FULL_NAME)); + .data("isElasticsearchEnabled", isESEnabled.isPresent() && isESEnabled.get()); } } diff --git a/src/main/java/io/github/project/openubl/searchpe/resources/VersionResource.java b/src/main/java/io/github/project/openubl/searchpe/resources/VersionResource.java index 6fba63ac..b298a236 100644 --- a/src/main/java/io/github/project/openubl/searchpe/resources/VersionResource.java +++ b/src/main/java/io/github/project/openubl/searchpe/resources/VersionResource.java @@ -85,7 +85,6 @@ public List getVersions(@QueryParam("active") Boolean active) { @Transactional(Transactional.TxType.NEVER) @POST @Path("/") - @Consumes() public VersionEntity createVersion() { try { tx.begin(); diff --git a/src/main/resources/application-enterprise.properties b/src/main/resources/application-enterprise.properties index b04655db..1f52354e 100644 --- a/src/main/resources/application-enterprise.properties +++ b/src/main/resources/application-enterprise.properties @@ -1,13 +1,15 @@ # Elasticsearch -quarkus.hibernate-search-orm.elasticsearch.version-check.enabled=true +quarkus.hibernate-search-orm.enabled=true -quarkus.hibernate-search-orm.elasticsearch.username=es_username -quarkus.hibernate-search-orm.elasticsearch.password=es_password -quarkus.hibernate-search-orm.elasticsearch.hosts=localhost:9200 +quarkus.hibernate-search-orm.elasticsearch.analysis.configurer=bean:searchpeAnalysisConfigurer +quarkus.hibernate-search-orm.elasticsearch.version-check.enabled=true quarkus.hibernate-search-orm.elasticsearch.protocol=HTTP quarkus.hibernate-search-orm.elasticsearch.version=7 quarkus.hibernate-search-orm.schema-management.strategy=CREATE_OR_VALIDATE quarkus.hibernate-search-orm.automatic-indexing.synchronization.strategy=write-sync +%test.quarkus.hibernate-search-orm.automatic-indexing.synchronization.strategy=sync + +quarkus.elasticsearch.devservices.enabled=true # Basic HTTP Authentication quarkus.http.auth.basic=false @@ -37,5 +39,5 @@ quarkus.oidc.roles.source=accesstoken quarkus.oidc.logout.path=/oidc/logout quarkus.oidc.logout.post-logout-path=/ +quarkus.keycloak.devservices.enabled=true quarkus.keycloak.devservices.realm-path=openubl-realm.json -%dev.quarkus.keycloak.devservices.enabled=true diff --git a/src/main/resources/application-standalone.properties b/src/main/resources/application-standalone.properties deleted file mode 100644 index a706d07e..00000000 --- a/src/main/resources/application-standalone.properties +++ /dev/null @@ -1,27 +0,0 @@ -# Elasticsearch -quarkus.hibernate-search-orm.elasticsearch.version=7.10 -quarkus.hibernate-search-orm.elasticsearch.version-check.enabled=false -quarkus.hibernate-search-orm.schema-management.strategy=NONE -quarkus.hibernate-search-orm.automatic-indexing.synchronization.strategy=bean:searchpeNoneIndexer - -# Basic HTTP Authentication -quarkus.http.auth.basic=true - -# Form HTTP Authentication -quarkus.http.auth.form.enabled=true -quarkus.http.auth.form.login-page=/auth-switch -quarkus.http.auth.form.error-page=/login-error.html - -quarkus.http.auth.permission.login-assets.paths=/assets/* -quarkus.http.auth.permission.login-assets.policy=permit - -quarkus.http.auth.permission.basic-auth-flow.paths=/auth-switch,/login.html,/login-error.html,/signup.html,/signup-error.html,/j_security_signup -quarkus.http.auth.permission.basic-auth-flow.policy=permit - -quarkus.http.auth.permission.everything-else.paths=/* -quarkus.http.auth.permission.everything-else.policy=authenticated - -# OpenId Authentication -quarkus.oidc.enabled=false -quarkus.oidc.auth-server-url=http://localhost:8180/auth/realms/openubl - diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 233b2655..88acd0a5 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,13 +1,11 @@ # Resteasy -quarkus.resteasy.path=/api +quarkus.resteasy-reactive.path=/api # Qute quarkus.qute.content-types.js=text/javascript # Datasource quarkus.datasource.db-kind=postgresql -quarkus.datasource.username=searchpe_username -quarkus.datasource.password=searchpe_password quarkus.datasource.jdbc.additional-jdbc-properties.reWriteBatchedInserts=true # Hibernate @@ -31,7 +29,14 @@ quarkus.jaeger.sampler-type=const quarkus.jaeger.sampler-param=1 # Elasticsearch -quarkus.hibernate-search-orm.elasticsearch.analysis.configurer=bean:searchpeAnalysisConfigurer +quarkus.hibernate-search-orm.enabled=false + +quarkus.hibernate-search-orm.elasticsearch.version-check.enabled=false +quarkus.hibernate-search-orm.elasticsearch.version=7.17 +quarkus.hibernate-search-orm.schema-management.strategy=NONE +quarkus.hibernate-search-orm.automatic-indexing.synchronization.strategy=write-sync + +quarkus.elasticsearch.devservices.enabled=false # HTTP quarkus.http.cors=true @@ -41,10 +46,23 @@ quarkus.http.auth.basic=true # Form HTTP Authentication quarkus.http.auth.form.enabled=true + quarkus.http.auth.form.cookie-name=searchpe-credential quarkus.http.auth.form.location-cookie=searchpe-redirect-location quarkus.http.auth.session.encryption-key=N50xtHmAqRfL0CO7Yej5RvRsvQKeyRcesVDJc8a0Wq0= +quarkus.http.auth.form.login-page=/auth-switch +quarkus.http.auth.form.error-page=/login-error.html + +quarkus.http.auth.permission.login-assets.paths=/assets/* +quarkus.http.auth.permission.login-assets.policy=permit + +quarkus.http.auth.permission.basic-auth-flow.paths=/auth-switch,/login.html,/login-error.html,/signup.html,/signup-error.html,/j_security_signup +quarkus.http.auth.permission.basic-auth-flow.policy=permit + +quarkus.http.auth.permission.everything-else.paths=/* +quarkus.http.auth.permission.everything-else.policy=authenticated + # Global Auth config quarkus.http.auth.permission.health-check.paths=/q/* quarkus.http.auth.permission.health-check.policy=permit diff --git a/src/test/java/io/github/project/openubl/searchpe/ProfileManager.java b/src/test/java/io/github/project/openubl/searchpe/ProfileManager.java index f8efeccd..9c44ea41 100644 --- a/src/test/java/io/github/project/openubl/searchpe/ProfileManager.java +++ b/src/test/java/io/github/project/openubl/searchpe/ProfileManager.java @@ -16,75 +16,41 @@ */ package io.github.project.openubl.searchpe; -import io.github.project.openubl.searchpe.models.jpa.search.SearchpeNoneIndexer; -import io.github.project.openubl.searchpe.resources.config.ElasticsearchServer; -import io.github.project.openubl.searchpe.resources.config.KeycloakServer; -import io.github.project.openubl.searchpe.resources.config.PostgresSQLServer; import io.github.project.openubl.searchpe.resources.config.SunatServer; import io.quarkus.test.junit.QuarkusTestProfile; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; -public class ProfileManager implements QuarkusTestProfile { - - static final String testModeKey = "searchpe.test.mode"; +public abstract class ProfileManager implements QuarkusTestProfile { enum DistributionFlavor { standalone, enterprise } - String configProfile; - List testResources = new ArrayList<>(); - Map configOverrides = new HashMap<>(); - - public ProfileManager() { - String testModeFlavor = System.getProperty(testModeKey, DistributionFlavor.standalone.toString()); - DistributionFlavor distributionFlavor = DistributionFlavor.valueOf(testModeFlavor); - - init(distributionFlavor); - } + protected String configProfile; + protected List testResources = new ArrayList<>(); public ProfileManager(DistributionFlavor distributionFlavor) { init(distributionFlavor); } private void init(DistributionFlavor distributionFlavor) { - configOverrides.put("quarkus.datasource.devservices.enabled", "false"); - configOverrides.put("quarkus.keycloak.devservices.enabled", "false"); - switch (distributionFlavor) { case standalone: // Profile configProfile = DistributionFlavor.standalone.toString(); // Test resources - testResources.add(new TestResourceEntry(PostgresSQLServer.class)); testResources.add(new TestResourceEntry(SunatServer.class)); - // Config - configOverrides.put("quarkus.hibernate-search-orm.automatic-indexing.synchronization.strategy", SearchpeNoneIndexer.BEAN_FULL_NAME); - - configOverrides.put("quarkus.oidc.auth-server-url", "http://localhost:8180/auth"); // Required to have this prop for running tests - configOverrides.put("quarkus.oidc.client-id", "searchpe"); // Required to have this prop for running tests - configOverrides.put("quarkus.oidc.credentials.secret", "secret"); // Required to have this prop for running tests - break; case enterprise: // Profile configProfile = DistributionFlavor.enterprise.toString(); // Test resources - testResources.add(new TestResourceEntry(PostgresSQLServer.class)); testResources.add(new TestResourceEntry(SunatServer.class)); - testResources.add(new TestResourceEntry(ElasticsearchServer.class)); - testResources.add(new TestResourceEntry(KeycloakServer.class)); - - // Config - configOverrides.put("quarkus.hibernate-search-orm.automatic-indexing.synchronization.strategy", "sync"); - configOverrides.put("quarkus.oidc.enabled", "true"); // Without this ti doesn't take effect and tests fail break; } @@ -92,16 +58,11 @@ private void init(DistributionFlavor distributionFlavor) { @Override public String getConfigProfile() { - return configProfile; + return "test," + configProfile; } @Override public List testResources() { return testResources; } - - @Override - public Map getConfigOverrides() { - return configOverrides; - } } diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/ContribuyenteResourceTest.java b/src/test/java/io/github/project/openubl/searchpe/resources/AbstractContribuyenteResourceTest.java similarity index 92% rename from src/test/java/io/github/project/openubl/searchpe/resources/ContribuyenteResourceTest.java rename to src/test/java/io/github/project/openubl/searchpe/resources/AbstractContribuyenteResourceTest.java index 7d42bdff..acf4033d 100644 --- a/src/test/java/io/github/project/openubl/searchpe/resources/ContribuyenteResourceTest.java +++ b/src/test/java/io/github/project/openubl/searchpe/resources/AbstractContribuyenteResourceTest.java @@ -23,11 +23,11 @@ import static org.hamcrest.CoreMatchers.is; @TestHTTPEndpoint(ContribuyenteResource.class) -public abstract class ContribuyenteResourceTest extends AbstractBaseTest { +public abstract class AbstractContribuyenteResourceTest extends AbstractBaseTest { @Override public Class getTestClass() { - return ContribuyenteResourceTest.class; + return AbstractContribuyenteResourceTest.class; } @Test diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/CurrentUserResourceTest.java b/src/test/java/io/github/project/openubl/searchpe/resources/AbstractCurrentUserResourceTest.java similarity index 93% rename from src/test/java/io/github/project/openubl/searchpe/resources/CurrentUserResourceTest.java rename to src/test/java/io/github/project/openubl/searchpe/resources/AbstractCurrentUserResourceTest.java index ea883c5f..b8a23c85 100644 --- a/src/test/java/io/github/project/openubl/searchpe/resources/CurrentUserResourceTest.java +++ b/src/test/java/io/github/project/openubl/searchpe/resources/AbstractCurrentUserResourceTest.java @@ -29,11 +29,11 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; @TestHTTPEndpoint(CurrentUserResource.class) -public abstract class CurrentUserResourceTest extends AbstractBaseTest { +public abstract class AbstractCurrentUserResourceTest extends AbstractBaseTest { @Override public Class getTestClass() { - return CurrentUserResourceTest.class; + return AbstractCurrentUserResourceTest.class; } @Test diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/VersionResourceTest.java b/src/test/java/io/github/project/openubl/searchpe/resources/AbstractVersionResourceTest.java similarity index 98% rename from src/test/java/io/github/project/openubl/searchpe/resources/VersionResourceTest.java rename to src/test/java/io/github/project/openubl/searchpe/resources/AbstractVersionResourceTest.java index 7c63151e..d735ed11 100644 --- a/src/test/java/io/github/project/openubl/searchpe/resources/VersionResourceTest.java +++ b/src/test/java/io/github/project/openubl/searchpe/resources/AbstractVersionResourceTest.java @@ -31,11 +31,11 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; @TestHTTPEndpoint(VersionResource.class) -public abstract class VersionResourceTest extends AbstractBaseTest { +public abstract class AbstractVersionResourceTest extends AbstractBaseTest { @Override public Class getTestClass() { - return VersionResourceTest.class; + return AbstractVersionResourceTest.class; } @Test diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/ContribuyenteResource_EnterpriseTest.java b/src/test/java/io/github/project/openubl/searchpe/resources/EnterpriseContribuyenteResourceTest.java similarity index 91% rename from src/test/java/io/github/project/openubl/searchpe/resources/ContribuyenteResource_EnterpriseTest.java rename to src/test/java/io/github/project/openubl/searchpe/resources/EnterpriseContribuyenteResourceTest.java index 5f278d19..c2373cd6 100644 --- a/src/test/java/io/github/project/openubl/searchpe/resources/ContribuyenteResource_EnterpriseTest.java +++ b/src/test/java/io/github/project/openubl/searchpe/resources/EnterpriseContribuyenteResourceTest.java @@ -22,6 +22,6 @@ @QuarkusTest @TestProfile(EnterpriseProfileManager.class) -public class ContribuyenteResource_EnterpriseTest extends ContribuyenteResourceTest { +public class EnterpriseContribuyenteResourceTest extends AbstractContribuyenteResourceTest { } diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/CurrentUserResource_EnterpriseTest.java b/src/test/java/io/github/project/openubl/searchpe/resources/EnterpriseCurrentUserResourceTest.java similarity index 91% rename from src/test/java/io/github/project/openubl/searchpe/resources/CurrentUserResource_EnterpriseTest.java rename to src/test/java/io/github/project/openubl/searchpe/resources/EnterpriseCurrentUserResourceTest.java index b098fd42..43a96af1 100644 --- a/src/test/java/io/github/project/openubl/searchpe/resources/CurrentUserResource_EnterpriseTest.java +++ b/src/test/java/io/github/project/openubl/searchpe/resources/EnterpriseCurrentUserResourceTest.java @@ -22,6 +22,6 @@ @QuarkusTest @TestProfile(EnterpriseProfileManager.class) -public class CurrentUserResource_EnterpriseTest extends CurrentUserResourceTest { +public class EnterpriseCurrentUserResourceTest extends AbstractCurrentUserResourceTest { } diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/SearchContribuyenteResource_EnterpriseTest.java b/src/test/java/io/github/project/openubl/searchpe/resources/EnterpriseSearchContribuyenteResourceTest.java similarity index 98% rename from src/test/java/io/github/project/openubl/searchpe/resources/SearchContribuyenteResource_EnterpriseTest.java rename to src/test/java/io/github/project/openubl/searchpe/resources/EnterpriseSearchContribuyenteResourceTest.java index b8b86ac0..60d91909 100644 --- a/src/test/java/io/github/project/openubl/searchpe/resources/SearchContribuyenteResource_EnterpriseTest.java +++ b/src/test/java/io/github/project/openubl/searchpe/resources/EnterpriseSearchContribuyenteResourceTest.java @@ -32,11 +32,11 @@ @QuarkusTest @TestProfile(EnterpriseProfileManager.class) -public class SearchContribuyenteResource_EnterpriseTest extends AbstractBaseTest { +public class EnterpriseSearchContribuyenteResourceTest extends AbstractBaseTest { @Override public Class getTestClass() { - return SearchContribuyenteResource_EnterpriseTest.class; + return EnterpriseSearchContribuyenteResourceTest.class; } @Test diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/UserResource_EnterpriseTest.java b/src/test/java/io/github/project/openubl/searchpe/resources/EnterpriseUserResourceTest.java similarity index 86% rename from src/test/java/io/github/project/openubl/searchpe/resources/UserResource_EnterpriseTest.java rename to src/test/java/io/github/project/openubl/searchpe/resources/EnterpriseUserResourceTest.java index 5f4f945e..07309d1f 100644 --- a/src/test/java/io/github/project/openubl/searchpe/resources/UserResource_EnterpriseTest.java +++ b/src/test/java/io/github/project/openubl/searchpe/resources/EnterpriseUserResourceTest.java @@ -18,6 +18,7 @@ import io.github.project.openubl.searchpe.AbstractBaseTest; import io.github.project.openubl.searchpe.EnterpriseProfileManager; +import io.github.project.openubl.searchpe.idm.BasicUserRepresentation; import io.github.project.openubl.searchpe.models.jpa.entity.BasicUserEntity; import io.github.project.openubl.searchpe.security.Permission; import io.quarkus.test.common.http.TestHTTPEndpoint; @@ -25,14 +26,17 @@ import io.quarkus.test.junit.TestProfile; import org.junit.jupiter.api.Test; +import java.util.HashSet; +import java.util.List; + @QuarkusTest @TestProfile(EnterpriseProfileManager.class) @TestHTTPEndpoint(BasicUserResource.class) -public class UserResource_EnterpriseTest extends AbstractBaseTest { +public class EnterpriseUserResourceTest extends AbstractBaseTest { @Override public Class getTestClass() { - return UserResource_EnterpriseTest.class; + return EnterpriseUserResourceTest.class; } @Test @@ -85,10 +89,10 @@ public void deleteUser() { @Test public void createUser() { // Given - BasicUserEntity user = new BasicUserEntity(); - user.username = "myUsername"; - user.password = "myPassword"; - user.permissions = Permission.search; + BasicUserRepresentation user = new BasicUserRepresentation(); + user.setUsername("myUsername"); + user.setPassword("myPassword"); + user.setPermissions(new HashSet<>(List.of(Permission.search))); // When givenAuth("admin") diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/VersionResource_EnterpriseTest.java b/src/test/java/io/github/project/openubl/searchpe/resources/EnterpriseVersionResourceTest.java similarity index 92% rename from src/test/java/io/github/project/openubl/searchpe/resources/VersionResource_EnterpriseTest.java rename to src/test/java/io/github/project/openubl/searchpe/resources/EnterpriseVersionResourceTest.java index 16a8e41c..19eea57b 100644 --- a/src/test/java/io/github/project/openubl/searchpe/resources/VersionResource_EnterpriseTest.java +++ b/src/test/java/io/github/project/openubl/searchpe/resources/EnterpriseVersionResourceTest.java @@ -22,6 +22,6 @@ @QuarkusTest @TestProfile(EnterpriseProfileManager.class) -public class VersionResource_EnterpriseTest extends VersionResourceTest { +public class EnterpriseVersionResourceTest extends AbstractVersionResourceTest { } diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/NativeEnterpriseContribuyenteResourceIT.java b/src/test/java/io/github/project/openubl/searchpe/resources/NativeEnterpriseContribuyenteResourceIT.java new file mode 100644 index 00000000..2831f9de --- /dev/null +++ b/src/test/java/io/github/project/openubl/searchpe/resources/NativeEnterpriseContribuyenteResourceIT.java @@ -0,0 +1,25 @@ +/* + * Copyright 2019 Project OpenUBL, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.github.project.openubl.searchpe.resources; + +import io.quarkus.test.junit.QuarkusIntegrationTest; +import org.junit.jupiter.api.Disabled; + +@Disabled +@QuarkusIntegrationTest +public class NativeEnterpriseContribuyenteResourceIT extends EnterpriseContribuyenteResourceTest { +} diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/NativeContribuyenteResource_StandaloneIT.java b/src/test/java/io/github/project/openubl/searchpe/resources/NativeEnterpriseCurrentUserResourceIT.java similarity index 77% rename from src/test/java/io/github/project/openubl/searchpe/resources/NativeContribuyenteResource_StandaloneIT.java rename to src/test/java/io/github/project/openubl/searchpe/resources/NativeEnterpriseCurrentUserResourceIT.java index a40540a3..a02f27c3 100644 --- a/src/test/java/io/github/project/openubl/searchpe/resources/NativeContribuyenteResource_StandaloneIT.java +++ b/src/test/java/io/github/project/openubl/searchpe/resources/NativeEnterpriseCurrentUserResourceIT.java @@ -16,8 +16,10 @@ */ package io.github.project.openubl.searchpe.resources; -import io.quarkus.test.junit.NativeImageTest; +import io.quarkus.test.junit.QuarkusIntegrationTest; +import org.junit.jupiter.api.Disabled; -@NativeImageTest -public class NativeContribuyenteResource_StandaloneIT extends ContribuyenteResource_StandaloneTest { +@Disabled +@QuarkusIntegrationTest +public class NativeEnterpriseCurrentUserResourceIT extends EnterpriseCurrentUserResourceTest { } diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/NativeCurrentUserResource_StandaloneIT.java b/src/test/java/io/github/project/openubl/searchpe/resources/NativeEnterpriseVersionResourceIT.java similarity index 77% rename from src/test/java/io/github/project/openubl/searchpe/resources/NativeCurrentUserResource_StandaloneIT.java rename to src/test/java/io/github/project/openubl/searchpe/resources/NativeEnterpriseVersionResourceIT.java index 14beaf30..d91e0726 100644 --- a/src/test/java/io/github/project/openubl/searchpe/resources/NativeCurrentUserResource_StandaloneIT.java +++ b/src/test/java/io/github/project/openubl/searchpe/resources/NativeEnterpriseVersionResourceIT.java @@ -16,8 +16,10 @@ */ package io.github.project.openubl.searchpe.resources; -import io.quarkus.test.junit.NativeImageTest; +import io.quarkus.test.junit.QuarkusIntegrationTest; +import org.junit.jupiter.api.Disabled; -@NativeImageTest -public class NativeCurrentUserResource_StandaloneIT extends CurrentUserResource_StandaloneTest { +@Disabled +@QuarkusIntegrationTest +public class NativeEnterpriseVersionResourceIT extends EnterpriseVersionResourceTest { } diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/NativeStandaloneContribuyenteResourceIT.java b/src/test/java/io/github/project/openubl/searchpe/resources/NativeStandaloneContribuyenteResourceIT.java new file mode 100644 index 00000000..3b37b18b --- /dev/null +++ b/src/test/java/io/github/project/openubl/searchpe/resources/NativeStandaloneContribuyenteResourceIT.java @@ -0,0 +1,25 @@ +/* + * Copyright 2019 Project OpenUBL, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.github.project.openubl.searchpe.resources; + +import io.quarkus.test.junit.QuarkusIntegrationTest; +import org.junit.jupiter.api.Disabled; + +@Disabled +@QuarkusIntegrationTest +public class NativeStandaloneContribuyenteResourceIT extends StandaloneContribuyenteResourceTest { +} diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/NativeCurrentUserResource_EnterpriseIT.java b/src/test/java/io/github/project/openubl/searchpe/resources/NativeStandaloneCurrentUserResourceIT.java similarity index 77% rename from src/test/java/io/github/project/openubl/searchpe/resources/NativeCurrentUserResource_EnterpriseIT.java rename to src/test/java/io/github/project/openubl/searchpe/resources/NativeStandaloneCurrentUserResourceIT.java index c4672aea..d13b88d6 100644 --- a/src/test/java/io/github/project/openubl/searchpe/resources/NativeCurrentUserResource_EnterpriseIT.java +++ b/src/test/java/io/github/project/openubl/searchpe/resources/NativeStandaloneCurrentUserResourceIT.java @@ -16,8 +16,10 @@ */ package io.github.project.openubl.searchpe.resources; -import io.quarkus.test.junit.NativeImageTest; +import io.quarkus.test.junit.QuarkusIntegrationTest; +import org.junit.jupiter.api.Disabled; -@NativeImageTest -public class NativeCurrentUserResource_EnterpriseIT extends CurrentUserResource_EnterpriseTest { +@Disabled +@QuarkusIntegrationTest +public class NativeStandaloneCurrentUserResourceIT extends StandaloneCurrentUserResourceTest { } diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/NativeContribuyenteResource_EnterpriseIT.java b/src/test/java/io/github/project/openubl/searchpe/resources/NativeStandaloneVersionResourceIT.java similarity index 77% rename from src/test/java/io/github/project/openubl/searchpe/resources/NativeContribuyenteResource_EnterpriseIT.java rename to src/test/java/io/github/project/openubl/searchpe/resources/NativeStandaloneVersionResourceIT.java index 578c5536..b4c52b39 100644 --- a/src/test/java/io/github/project/openubl/searchpe/resources/NativeContribuyenteResource_EnterpriseIT.java +++ b/src/test/java/io/github/project/openubl/searchpe/resources/NativeStandaloneVersionResourceIT.java @@ -16,8 +16,10 @@ */ package io.github.project.openubl.searchpe.resources; -import io.quarkus.test.junit.NativeImageTest; +import io.quarkus.test.junit.QuarkusIntegrationTest; +import org.junit.jupiter.api.Disabled; -@NativeImageTest -public class NativeContribuyenteResource_EnterpriseIT extends ContribuyenteResource_EnterpriseTest { +@Disabled +@QuarkusIntegrationTest +public class NativeStandaloneVersionResourceIT extends StandaloneVersionResourceTest { } diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/NativeVersionResource_EnterpriseIT.java b/src/test/java/io/github/project/openubl/searchpe/resources/NativeVersionResource_EnterpriseIT.java deleted file mode 100644 index 643073ae..00000000 --- a/src/test/java/io/github/project/openubl/searchpe/resources/NativeVersionResource_EnterpriseIT.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2019 Project OpenUBL, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.github.project.openubl.searchpe.resources; - -import io.quarkus.test.junit.NativeImageTest; - -@NativeImageTest -public class NativeVersionResource_EnterpriseIT extends VersionResource_EnterpriseTest { -} diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/NativeVersionResource_StandaloneIT.java b/src/test/java/io/github/project/openubl/searchpe/resources/NativeVersionResource_StandaloneIT.java deleted file mode 100644 index fe00cc38..00000000 --- a/src/test/java/io/github/project/openubl/searchpe/resources/NativeVersionResource_StandaloneIT.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2019 Project OpenUBL, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.github.project.openubl.searchpe.resources; - -import io.quarkus.test.junit.NativeImageTest; - -@NativeImageTest -public class NativeVersionResource_StandaloneIT extends VersionResource_StandaloneTest { -} diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/ContribuyenteResource_StandaloneTest.java b/src/test/java/io/github/project/openubl/searchpe/resources/StandaloneContribuyenteResourceTest.java similarity index 91% rename from src/test/java/io/github/project/openubl/searchpe/resources/ContribuyenteResource_StandaloneTest.java rename to src/test/java/io/github/project/openubl/searchpe/resources/StandaloneContribuyenteResourceTest.java index 24fd9956..cd96e2e2 100644 --- a/src/test/java/io/github/project/openubl/searchpe/resources/ContribuyenteResource_StandaloneTest.java +++ b/src/test/java/io/github/project/openubl/searchpe/resources/StandaloneContribuyenteResourceTest.java @@ -22,6 +22,6 @@ @QuarkusTest @TestProfile(StandaloneProfileManager.class) -public class ContribuyenteResource_StandaloneTest extends ContribuyenteResourceTest { +public class StandaloneContribuyenteResourceTest extends AbstractContribuyenteResourceTest { } diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/CurrentUserResource_StandaloneTest.java b/src/test/java/io/github/project/openubl/searchpe/resources/StandaloneCurrentUserResourceTest.java similarity index 91% rename from src/test/java/io/github/project/openubl/searchpe/resources/CurrentUserResource_StandaloneTest.java rename to src/test/java/io/github/project/openubl/searchpe/resources/StandaloneCurrentUserResourceTest.java index 10c28a25..359275df 100644 --- a/src/test/java/io/github/project/openubl/searchpe/resources/CurrentUserResource_StandaloneTest.java +++ b/src/test/java/io/github/project/openubl/searchpe/resources/StandaloneCurrentUserResourceTest.java @@ -22,6 +22,6 @@ @QuarkusTest @TestProfile(StandaloneProfileManager.class) -public class CurrentUserResource_StandaloneTest extends CurrentUserResourceTest { +public class StandaloneCurrentUserResourceTest extends AbstractCurrentUserResourceTest { } diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/SearchContribuyenteResource_StandaloneTest.java b/src/test/java/io/github/project/openubl/searchpe/resources/StandaloneSearchContribuyenteResourceTest.java similarity index 90% rename from src/test/java/io/github/project/openubl/searchpe/resources/SearchContribuyenteResource_StandaloneTest.java rename to src/test/java/io/github/project/openubl/searchpe/resources/StandaloneSearchContribuyenteResourceTest.java index 284e2c86..863db9d8 100644 --- a/src/test/java/io/github/project/openubl/searchpe/resources/SearchContribuyenteResource_StandaloneTest.java +++ b/src/test/java/io/github/project/openubl/searchpe/resources/StandaloneSearchContribuyenteResourceTest.java @@ -26,11 +26,11 @@ @QuarkusTest @TestProfile(StandaloneProfileManager.class) @TestHTTPEndpoint(ContribuyenteResource.class) -public class SearchContribuyenteResource_StandaloneTest extends AbstractBaseTest { +public class StandaloneSearchContribuyenteResourceTest extends AbstractBaseTest { @Override public Class getTestClass() { - return SearchContribuyenteResource_StandaloneTest.class; + return StandaloneSearchContribuyenteResourceTest.class; } @Test diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/UserResource_StandaloneTest.java b/src/test/java/io/github/project/openubl/searchpe/resources/StandaloneUserResourceTest.java similarity index 98% rename from src/test/java/io/github/project/openubl/searchpe/resources/UserResource_StandaloneTest.java rename to src/test/java/io/github/project/openubl/searchpe/resources/StandaloneUserResourceTest.java index 4a51663c..fec34103 100644 --- a/src/test/java/io/github/project/openubl/searchpe/resources/UserResource_StandaloneTest.java +++ b/src/test/java/io/github/project/openubl/searchpe/resources/StandaloneUserResourceTest.java @@ -35,11 +35,11 @@ @QuarkusTest @TestProfile(StandaloneProfileManager.class) @TestHTTPEndpoint(BasicUserResource.class) -public class UserResource_StandaloneTest extends AbstractBaseTest { +public class StandaloneUserResourceTest extends AbstractBaseTest { @Override public Class getTestClass() { - return UserResource_StandaloneTest.class; + return StandaloneUserResourceTest.class; } @Test diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/VersionResource_StandaloneTest.java b/src/test/java/io/github/project/openubl/searchpe/resources/StandaloneVersionResourceTest.java similarity index 92% rename from src/test/java/io/github/project/openubl/searchpe/resources/VersionResource_StandaloneTest.java rename to src/test/java/io/github/project/openubl/searchpe/resources/StandaloneVersionResourceTest.java index 38e32f00..6d0d677c 100644 --- a/src/test/java/io/github/project/openubl/searchpe/resources/VersionResource_StandaloneTest.java +++ b/src/test/java/io/github/project/openubl/searchpe/resources/StandaloneVersionResourceTest.java @@ -22,6 +22,6 @@ @QuarkusTest @TestProfile(StandaloneProfileManager.class) -public class VersionResource_StandaloneTest extends VersionResourceTest { +public class StandaloneVersionResourceTest extends AbstractVersionResourceTest { } diff --git a/src/test/java/io/github/project/openubl/searchpe/resources/config/PostgresSQLServer.java b/src/test/java/io/github/project/openubl/searchpe/resources/config/PostgresSQLServer.java index bec5c6cd..5bb886b8 100644 --- a/src/test/java/io/github/project/openubl/searchpe/resources/config/PostgresSQLServer.java +++ b/src/test/java/io/github/project/openubl/searchpe/resources/config/PostgresSQLServer.java @@ -42,7 +42,7 @@ public Map start() { .withEnv("POSTGRES_USER", DB_USERNAME) .withEnv("POSTGRES_PASSWORD", DB_PASSWORD) .waitingFor(Wait.forLogMessage(".* database system is ready to accept .*", 1)); - ; + postgreSQL.start(); String host = postgreSQL.getHost(); diff --git a/src/test/resources/db/io/github/project/openubl/searchpe/resources/ContribuyenteResourceTest/V9999.0.1__test.sql b/src/test/resources/db/io/github/project/openubl/searchpe/resources/AbstractContribuyenteResourceTest/V9999.0.1__test.sql similarity index 100% rename from src/test/resources/db/io/github/project/openubl/searchpe/resources/ContribuyenteResourceTest/V9999.0.1__test.sql rename to src/test/resources/db/io/github/project/openubl/searchpe/resources/AbstractContribuyenteResourceTest/V9999.0.1__test.sql diff --git a/src/test/resources/db/io/github/project/openubl/searchpe/resources/VersionResourceTest/V9999.0.1__test.sql b/src/test/resources/db/io/github/project/openubl/searchpe/resources/AbstractVersionResourceTest/V9999.0.1__test.sql similarity index 100% rename from src/test/resources/db/io/github/project/openubl/searchpe/resources/VersionResourceTest/V9999.0.1__test.sql rename to src/test/resources/db/io/github/project/openubl/searchpe/resources/AbstractVersionResourceTest/V9999.0.1__test.sql