diff --git a/docs/modules/onecx-parameter-svc/pages/onecx-parameter-svc-docs.adoc b/docs/modules/onecx-parameter-svc/pages/onecx-parameter-svc-docs.adoc index 159c02e..e7c7f39 100644 --- a/docs/modules/onecx-parameter-svc/pages/onecx-parameter-svc-docs.adoc +++ b/docs/modules/onecx-parameter-svc/pages/onecx-parameter-svc-docs.adoc @@ -17,7 +17,6 @@ quarkus.http.auth.permission.health.paths=/q/* quarkus.http.auth.permission.health.policy=permit quarkus.http.auth.permission.default.paths=/* quarkus.http.auth.permission.default.policy=authenticated -quarkus.banner.enabled=false quarkus.hibernate-orm.database.generation=validate quarkus.hibernate-orm.multitenant=DISCRIMINATOR quarkus.liquibase.migrate-at-start=true @@ -65,3 +64,7 @@ app: ---- +pes: [ ocx-tn:read ] + +---- + diff --git a/docs/modules/onecx-parameter-svc/pages/onecx-parameter-svc-extensions.adoc b/docs/modules/onecx-parameter-svc/pages/onecx-parameter-svc-extensions.adoc index ace52cf..cf43cbc 100644 --- a/docs/modules/onecx-parameter-svc/pages/onecx-parameter-svc-extensions.adoc +++ b/docs/modules/onecx-parameter-svc/pages/onecx-parameter-svc-extensions.adoc @@ -8,12 +8,6 @@ h| Documentation h| Configuration h| Version -| tkit-quarkus-data-import - -| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-data-import.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.36.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-data-import.adoc[Link] -| 2.36.0 - | tkit-quarkus-jpa | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-jpa.html[Link] @@ -166,4 +160,22 @@ h| Version | 3.15.1 +|===ps://quarkus.io/guides/container-image[Link] +| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-container-image-docker.adoc[Link] +| 3.15.1 + + +| onecx-security + +| +| +| 0.34.0 + +| quarkus-scheduler + +| +| +| 3.15.1 + + |=== \ No newline at end of file diff --git a/pom.xml b/pom.xml index f1239c9..176189f 100644 --- a/pom.xml +++ b/pom.xml @@ -16,10 +16,6 @@ - - org.tkit.quarkus.lib - tkit-quarkus-data-import - org.tkit.quarkus.lib tkit-quarkus-jpa @@ -187,19 +183,6 @@ org.openapitools openapi-generator-maven-plugin - - di-v1 - - generate - - - src/main/openapi/di-v1.yaml - gen.org.tkit.onecx.parameters.di.v1 - gen.org.tkit.onecx.parameters.di.v1.model - DTOV1 - true - - internal diff --git a/src/main/java/org/tkit/onecx/parameters/domain/timer/ParameterConfig.java b/src/main/java/org/tkit/onecx/parameters/domain/config/ParameterConfig.java similarity index 95% rename from src/main/java/org/tkit/onecx/parameters/domain/timer/ParameterConfig.java rename to src/main/java/org/tkit/onecx/parameters/domain/config/ParameterConfig.java index 4fc0c30..bbb6b68 100644 --- a/src/main/java/org/tkit/onecx/parameters/domain/timer/ParameterConfig.java +++ b/src/main/java/org/tkit/onecx/parameters/domain/config/ParameterConfig.java @@ -1,4 +1,4 @@ -package org.tkit.onecx.parameters.domain.timer; +package org.tkit.onecx.parameters.domain.config; import io.quarkus.runtime.annotations.ConfigDocFilename; import io.quarkus.runtime.annotations.ConfigPhase; diff --git a/src/main/java/org/tkit/onecx/parameters/domain/criteria/ApplicationParameterHistorySearchCriteria.java b/src/main/java/org/tkit/onecx/parameters/domain/criteria/ParameterHistorySearchCriteria.java similarity index 90% rename from src/main/java/org/tkit/onecx/parameters/domain/criteria/ApplicationParameterHistorySearchCriteria.java rename to src/main/java/org/tkit/onecx/parameters/domain/criteria/ParameterHistorySearchCriteria.java index acddea5..84720e1 100644 --- a/src/main/java/org/tkit/onecx/parameters/domain/criteria/ApplicationParameterHistorySearchCriteria.java +++ b/src/main/java/org/tkit/onecx/parameters/domain/criteria/ParameterHistorySearchCriteria.java @@ -10,7 +10,7 @@ */ @Getter @Setter -public class ApplicationParameterHistorySearchCriteria { +public class ParameterHistorySearchCriteria { /** * The application ID. diff --git a/src/main/java/org/tkit/onecx/parameters/domain/criteria/ApplicationParameterSearchCriteria.java b/src/main/java/org/tkit/onecx/parameters/domain/criteria/ParameterSearchCriteria.java similarity index 90% rename from src/main/java/org/tkit/onecx/parameters/domain/criteria/ApplicationParameterSearchCriteria.java rename to src/main/java/org/tkit/onecx/parameters/domain/criteria/ParameterSearchCriteria.java index a3e3a33..9924d6f 100644 --- a/src/main/java/org/tkit/onecx/parameters/domain/criteria/ApplicationParameterSearchCriteria.java +++ b/src/main/java/org/tkit/onecx/parameters/domain/criteria/ParameterSearchCriteria.java @@ -8,7 +8,7 @@ */ @Getter @Setter -public class ApplicationParameterSearchCriteria { +public class ParameterSearchCriteria { /** * The application ID. diff --git a/src/main/java/org/tkit/onecx/parameters/domain/daos/ApplicationParameterDAO.java b/src/main/java/org/tkit/onecx/parameters/domain/daos/ApplicationParameterDAO.java deleted file mode 100644 index efcbaf7..0000000 --- a/src/main/java/org/tkit/onecx/parameters/domain/daos/ApplicationParameterDAO.java +++ /dev/null @@ -1,160 +0,0 @@ -package org.tkit.onecx.parameters.domain.daos; - -import java.util.*; -import java.util.stream.Collectors; - -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.persistence.criteria.*; -import jakarta.transaction.Transactional; - -import org.tkit.onecx.parameters.domain.criteria.ApplicationParameterSearchCriteria; -import org.tkit.onecx.parameters.domain.criteria.KeysSearchCriteria; -import org.tkit.onecx.parameters.domain.models.*; -import org.tkit.quarkus.jpa.daos.AbstractDAO; -import org.tkit.quarkus.jpa.daos.Page; -import org.tkit.quarkus.jpa.daos.PageResult; -import org.tkit.quarkus.jpa.exceptions.DAOException; - -@ApplicationScoped -@Transactional(value = Transactional.TxType.NOT_SUPPORTED, rollbackOn = DAOException.class) -public class ApplicationParameterDAO extends AbstractDAO { - - // keys in format - public Map findApplicationParametersByKeys(Set keys, String separator) { - try { - CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); - CriteriaQuery cq = cb.createQuery(ApplicationParameter.class); - Root root = cq.from(ApplicationParameter.class); - - // 'app__key' in ( ... ) - cq.where(cb.concat( - cb.concat(root.get(ApplicationParameter_.APPLICATION_ID), separator), root.get(ApplicationParameter_.KEY)) - .in(keys)); - - List params = getEntityManager().createQuery(cq).getResultList(); - return params.stream().collect(Collectors.toMap(x -> x.getApplicationId() + separator + x.getKey(), x -> x)); - } catch (Exception e) { - throw new DAOException(ErrorKeys.FIND_PARAMETER_BY_APPLICATION_ID_AND_PARAMETER_KEY_FAILED, e); - } - } - - public List findByApplicationIdAndParameterKeys(String applicationId, List parametersKeys) { - - try { - CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); - CriteriaQuery cq = cb.createQuery(ApplicationParameter.class); - Root root = cq.from(ApplicationParameter.class); - cq.where(cb.and( - cb.equal(root.get(ApplicationParameter_.APPLICATION_ID), applicationId), - root.get(ApplicationParameter_.KEY).in(parametersKeys))); - return getEntityManager().createQuery(cq).getResultList(); - } catch (Exception e) { - throw new DAOException(ErrorKeys.FIND_PARAMETERS_BY_APPLICATION_AND_PARAMETER_KEYS_FAILED, e); - } - } - - public Map findAllByProductNameAndApplicationId(String productName, String applicationId) { - try { - CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); - CriteriaQuery cq = cb.createQuery(ApplicationParameter.class); - Root root = cq.from(ApplicationParameter.class); - cq.where(cb.and( - cb.equal(root.get(ApplicationParameter_.PRODUCT_NAME), productName), - cb.equal(root.get(ApplicationParameter_.APPLICATION_ID), applicationId), - cb.or( - cb.isNotNull(root.get(ApplicationParameter_.SET_VALUE)), - cb.isNotNull(root.get(ApplicationParameter_.IMPORT_VALUE))))); - - return getEntityManager() - .createQuery(cq) - .getResultStream() - .collect(Collectors.toMap(ApplicationParameter::getKey, - p -> p.getSetValue() != null ? p.getSetValue() : p.getImportValue())); - - } catch (Exception e) { - throw new DAOException(ErrorKeys.FIND_ALL_PARAMETERS_BY_APPLICATION_ID_FAILED, e); - } - } - - public PageResult searchByCriteria(ApplicationParameterSearchCriteria criteria) { - try { - CriteriaQuery cq = criteriaQuery(); - Root root = cq.from(ApplicationParameter.class); - List predicates = new ArrayList<>(); - CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); - if (criteria.getProductName() != null && !criteria.getProductName().isEmpty()) { - predicates.add(cb.like(cb.lower(root.get(ApplicationParameter_.PRODUCT_NAME)), - stringPattern(criteria.getProductName()))); - } - if (criteria.getApplicationId() != null && !criteria.getApplicationId().isEmpty()) { - predicates.add(cb.like(cb.lower(root.get(ApplicationParameter_.APPLICATION_ID)), - stringPattern(criteria.getApplicationId()))); - } - if (criteria.getKey() != null && !criteria.getKey().isEmpty()) { - predicates.add(cb.like(cb.lower(root.get(ApplicationParameter_.KEY)), stringPattern(criteria.getKey()))); - } - if (criteria.getName() != null && !criteria.getName().isEmpty()) { - predicates.add(cb.like(cb.lower(root.get(ApplicationParameter_.NAME)), stringPattern(criteria.getName()))); - } - if (!predicates.isEmpty()) { - cq.where(cb.and(predicates.toArray(new Predicate[0]))); - } - return createPageQuery(cq, Page.of(criteria.getPageNumber(), criteria.getPageSize())).getPageResult(); - } catch (Exception exception) { - throw new DAOException(ErrorKeys.FIND_ALL_PARAMETERS_FAILED, exception); - } - } - - public PageResult searchAllKeys(KeysSearchCriteria criteria) { - try { - var cb = getEntityManager().getCriteriaBuilder(); - CriteriaQuery cq = cb.createQuery(String.class); - Root root = cq.from(ApplicationParameter.class); - cq.select(root.get(ApplicationParameter_.KEY)).distinct(true); - - if (criteria.getProductName() != null && !criteria.getProductName().isEmpty()) { - cq.where(cb.equal(root.get(ApplicationParameter_.PRODUCT_NAME), criteria.getProductName())); - } - - if (criteria.getApplicationId() != null && !criteria.getApplicationId().isEmpty()) { - cq.where(cb.equal(root.get(ApplicationParameter_.APPLICATION_ID), criteria.getApplicationId())); - } - - var results = getEntityManager().createQuery(cq).getResultList(); - return new PageResult<>(results.size(), results.stream(), Page.of(0, 1)); - } catch (Exception exception) { - throw new DAOException(ErrorKeys.FIND_ALL_KEYS_FAILED, exception); - } - } - - public List searchAllProductNamesAndApplicationIds() { - try { - var cb = getEntityManager().getCriteriaBuilder(); - CriteriaQuery cq = cb.createQuery(ApplicationTuple.class); - Root root = cq.from(ApplicationParameter.class); - cq.select( - cb.construct(ApplicationTuple.class, root.get(ApplicationParameter_.PRODUCT_NAME), - root.get(ApplicationParameter_.APPLICATION_ID))) - .distinct(true); - return getEntityManager().createQuery(cq).getResultList(); - } catch (Exception exception) { - throw new DAOException(ErrorKeys.FIND_ALL_APPLICATIONS_FAILED, exception); - } - } - - private static String stringPattern(String value) { - return (value.toLowerCase() + "%"); - } - - public enum ErrorKeys { - - FIND_ALL_PARAMETERS_BY_APPLICATION_ID_FAILED, - FIND_PARAMETER_BY_APPLICATION_ID_AND_PARAMETER_KEY_FAILED, - FIND_PARAMETERS_BY_APPLICATION_AND_PARAMETER_KEYS_FAILED, - FIND_PARAMETERS_BY_APPLICATION_AND_PARAMETER_KEY_TYPE_FAILED, - FIND_ALL_APPLICATIONS_FAILED, - - FIND_ALL_KEYS_FAILED, - FIND_ALL_PARAMETERS_FAILED; - } -} diff --git a/src/main/java/org/tkit/onecx/parameters/domain/daos/JobDAO.java b/src/main/java/org/tkit/onecx/parameters/domain/daos/JobDAO.java index bb34b62..e60aa1b 100644 --- a/src/main/java/org/tkit/onecx/parameters/domain/daos/JobDAO.java +++ b/src/main/java/org/tkit/onecx/parameters/domain/daos/JobDAO.java @@ -28,7 +28,7 @@ public Job getJob(String id) throws DAOException { .createQuery(cq) .setMaxResults(1) .setLockMode(LockModeType.PESSIMISTIC_WRITE) - .setHint("javax.persistence.lock.timeout", -2) + .setHint("jakarta.persistence.lock.timeout", -2) .getSingleResult(); } catch (NoResultException ex) { diff --git a/src/main/java/org/tkit/onecx/parameters/domain/daos/ParameterDAO.java b/src/main/java/org/tkit/onecx/parameters/domain/daos/ParameterDAO.java new file mode 100644 index 0000000..8d3fb1c --- /dev/null +++ b/src/main/java/org/tkit/onecx/parameters/domain/daos/ParameterDAO.java @@ -0,0 +1,123 @@ +package org.tkit.onecx.parameters.domain.daos; + +import java.util.*; +import java.util.stream.Collectors; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.persistence.criteria.*; +import jakarta.transaction.Transactional; + +import org.tkit.onecx.parameters.domain.criteria.KeysSearchCriteria; +import org.tkit.onecx.parameters.domain.criteria.ParameterSearchCriteria; +import org.tkit.onecx.parameters.domain.models.*; +import org.tkit.quarkus.jpa.daos.AbstractDAO; +import org.tkit.quarkus.jpa.daos.Page; +import org.tkit.quarkus.jpa.daos.PageResult; +import org.tkit.quarkus.jpa.exceptions.DAOException; + +@ApplicationScoped +@Transactional(value = Transactional.TxType.NOT_SUPPORTED, rollbackOn = DAOException.class) +public class ParameterDAO extends AbstractDAO { + + public Map findAllByProductNameAndApplicationId(String productName, String applicationId) { + try { + CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); + CriteriaQuery cq = cb.createQuery(Parameter.class); + Root root = cq.from(Parameter.class); + cq.where(cb.and( + cb.equal(root.get(Parameter_.PRODUCT_NAME), productName), + cb.equal(root.get(Parameter_.APPLICATION_ID), applicationId), + cb.or( + cb.isNotNull(root.get(Parameter_.VALUE)), + cb.isNotNull(root.get(Parameter_.IMPORT_VALUE))))); + + return getEntityManager() + .createQuery(cq) + .getResultStream() + .collect(Collectors.toMap(Parameter::getKey, + p -> p.getValue() != null ? p.getValue() : p.getImportValue())); + + } catch (Exception e) { + throw new DAOException(ErrorKeys.FIND_ALL_PARAMETERS_BY_APPLICATION_ID_FAILED, e); + } + } + + public PageResult searchByCriteria(ParameterSearchCriteria criteria) { + try { + CriteriaQuery cq = criteriaQuery(); + Root root = cq.from(Parameter.class); + List predicates = new ArrayList<>(); + CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); + if (criteria.getProductName() != null && !criteria.getProductName().isEmpty()) { + predicates.add(cb.like(cb.lower(root.get(Parameter_.PRODUCT_NAME)), + stringPattern(criteria.getProductName()))); + } + if (criteria.getApplicationId() != null && !criteria.getApplicationId().isEmpty()) { + predicates.add(cb.like(cb.lower(root.get(Parameter_.APPLICATION_ID)), + stringPattern(criteria.getApplicationId()))); + } + if (criteria.getKey() != null && !criteria.getKey().isEmpty()) { + predicates.add(cb.like(cb.lower(root.get(Parameter_.KEY)), stringPattern(criteria.getKey()))); + } + if (criteria.getName() != null && !criteria.getName().isEmpty()) { + predicates.add(cb.like(cb.lower(root.get(Parameter_.NAME)), stringPattern(criteria.getName()))); + } + if (!predicates.isEmpty()) { + cq.where(cb.and(predicates.toArray(new Predicate[0]))); + } + return createPageQuery(cq, Page.of(criteria.getPageNumber(), criteria.getPageSize())).getPageResult(); + } catch (Exception exception) { + throw new DAOException(ErrorKeys.FIND_ALL_PARAMETERS_FAILED, exception); + } + } + + public PageResult searchAllKeys(KeysSearchCriteria criteria) { + try { + var cb = getEntityManager().getCriteriaBuilder(); + CriteriaQuery cq = cb.createQuery(String.class); + Root root = cq.from(Parameter.class); + cq.select(root.get(Parameter_.KEY)).distinct(true); + + if (criteria.getProductName() != null && !criteria.getProductName().isEmpty()) { + cq.where(cb.equal(root.get(Parameter_.PRODUCT_NAME), criteria.getProductName())); + } + + if (criteria.getApplicationId() != null && !criteria.getApplicationId().isEmpty()) { + cq.where(cb.equal(root.get(Parameter_.APPLICATION_ID), criteria.getApplicationId())); + } + + var results = getEntityManager().createQuery(cq).getResultList(); + return new PageResult<>(results.size(), results.stream(), Page.of(0, 1)); + } catch (Exception exception) { + throw new DAOException(ErrorKeys.FIND_ALL_KEYS_FAILED, exception); + } + } + + public List searchAllProductNamesAndApplicationIds() { + try { + var cb = getEntityManager().getCriteriaBuilder(); + CriteriaQuery cq = cb.createQuery(ApplicationTuple.class); + Root root = cq.from(Parameter.class); + cq.select( + cb.construct(ApplicationTuple.class, root.get(Parameter_.PRODUCT_NAME), + root.get(Parameter_.APPLICATION_ID))) + .distinct(true); + return getEntityManager().createQuery(cq).getResultList(); + } catch (Exception exception) { + throw new DAOException(ErrorKeys.FIND_ALL_APPLICATIONS_FAILED, exception); + } + } + + private static String stringPattern(String value) { + return (value.toLowerCase() + "%"); + } + + public enum ErrorKeys { + + FIND_ALL_PARAMETERS_BY_APPLICATION_ID_FAILED, + FIND_ALL_APPLICATIONS_FAILED, + + FIND_ALL_KEYS_FAILED, + FIND_ALL_PARAMETERS_FAILED; + } +} diff --git a/src/main/java/org/tkit/onecx/parameters/domain/daos/ApplicationParameterHistoryDAO.java b/src/main/java/org/tkit/onecx/parameters/domain/daos/ParameterHistoryDAO.java similarity index 64% rename from src/main/java/org/tkit/onecx/parameters/domain/daos/ApplicationParameterHistoryDAO.java rename to src/main/java/org/tkit/onecx/parameters/domain/daos/ParameterHistoryDAO.java index 1295178..efa6fac 100644 --- a/src/main/java/org/tkit/onecx/parameters/domain/daos/ApplicationParameterHistoryDAO.java +++ b/src/main/java/org/tkit/onecx/parameters/domain/daos/ParameterHistoryDAO.java @@ -8,11 +8,11 @@ import jakarta.persistence.criteria.*; import jakarta.transaction.Transactional; -import org.tkit.onecx.parameters.domain.criteria.ApplicationParameterHistorySearchCriteria; -import org.tkit.onecx.parameters.domain.models.ApplicationParameterHistory; -import org.tkit.onecx.parameters.domain.models.ApplicationParameterHistory_; -import org.tkit.onecx.parameters.domain.models.ApplicationParameter_; +import org.tkit.onecx.parameters.domain.criteria.ParameterHistorySearchCriteria; +import org.tkit.onecx.parameters.domain.models.ParameterHistory; import org.tkit.onecx.parameters.domain.models.ParameterHistoryCountTuple; +import org.tkit.onecx.parameters.domain.models.ParameterHistory_; +import org.tkit.onecx.parameters.domain.models.Parameter_; import org.tkit.quarkus.jpa.daos.AbstractDAO; import org.tkit.quarkus.jpa.daos.Page; import org.tkit.quarkus.jpa.daos.PageResult; @@ -22,14 +22,14 @@ @ApplicationScoped @Transactional(value = Transactional.TxType.NOT_SUPPORTED, rollbackOn = DAOException.class) -public class ApplicationParameterHistoryDAO extends AbstractDAO { +public class ParameterHistoryDAO extends AbstractDAO { @Transactional(value = Transactional.TxType.REQUIRED, rollbackOn = DAOException.class) public void deleteApplicationHistoryOlderThan(LocalDateTime date) { try { CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); - CriteriaDelete cd = deleteQuery(); - Root root = cd.from(ApplicationParameterHistory.class); + CriteriaDelete cd = deleteQuery(); + Root root = cd.from(ParameterHistory.class); cd.where(cb.lessThanOrEqualTo(root.get(AbstractTraceableEntity_.CREATION_DATE), date)); getEntityManager().createQuery(cd).executeUpdate(); } catch (Exception e) { @@ -37,27 +37,27 @@ public void deleteApplicationHistoryOlderThan(LocalDateTime date) { } } - public PageResult searchByCriteria(ApplicationParameterHistorySearchCriteria criteria) { + public PageResult searchByCriteria(ParameterHistorySearchCriteria criteria) { try { - CriteriaQuery cq = criteriaQuery(); - Root root = cq.from(ApplicationParameterHistory.class); + CriteriaQuery cq = criteriaQuery(); + Root root = cq.from(ParameterHistory.class); List predicates = new ArrayList<>(); CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); if (criteria.getProductName() != null && !criteria.getProductName().isEmpty()) { - predicates.add(cb.like(cb.lower(root.get(ApplicationParameter_.PRODUCT_NAME)), + predicates.add(cb.like(cb.lower(root.get(Parameter_.PRODUCT_NAME)), stringPattern(criteria.getProductName()))); } if (criteria.getApplicationId() != null && !criteria.getApplicationId().isEmpty()) { - predicates.add(cb.like(cb.lower(root.get(ApplicationParameter_.APPLICATION_ID)), + predicates.add(cb.like(cb.lower(root.get(Parameter_.APPLICATION_ID)), stringPattern(criteria.getApplicationId()))); } if (criteria.getKey() != null && !criteria.getKey().isEmpty()) { - predicates.add(cb.like(cb.lower(root.get(ApplicationParameterHistory_.KEY)), stringPattern(criteria.getKey()))); + predicates.add(cb.like(cb.lower(root.get(ParameterHistory_.KEY)), stringPattern(criteria.getKey()))); } if (!criteria.getType().isEmpty()) { - predicates.add(cb.lower(root.get(ApplicationParameterHistory_.TYPE)).in(toLowerCase(criteria.getType()))); + predicates.add(cb.lower(root.get(ParameterHistory_.TYPE)).in(toLowerCase(criteria.getType()))); } if (!predicates.isEmpty()) { cq.where(cb.and(predicates.toArray(new Predicate[0]))); @@ -69,36 +69,36 @@ public PageResult searchByCriteria(ApplicationParam } } - public PageResult searchOnlyLatestByCriteria( - ApplicationParameterHistorySearchCriteria criteria) { + public PageResult searchOnlyLatestByCriteria( + ParameterHistorySearchCriteria criteria) { try { CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); - CriteriaQuery cq = cb.createQuery(ApplicationParameterHistory.class); - Root root = cq.from(ApplicationParameterHistory.class); + CriteriaQuery cq = cb.createQuery(ParameterHistory.class); + Root root = cq.from(ParameterHistory.class); Subquery maxDateSubquery = cq.subquery(Number.class); - Root maxDateSubqueryRoot = maxDateSubquery.from(ApplicationParameterHistory.class); + Root maxDateSubqueryRoot = maxDateSubquery.from(ParameterHistory.class); maxDateSubquery.select(cb.max(maxDateSubqueryRoot.get(AbstractTraceableEntity_.CREATION_DATE))) - .groupBy(maxDateSubqueryRoot.get(ApplicationParameterHistory_.INSTANCE_ID)); + .groupBy(maxDateSubqueryRoot.get(ParameterHistory_.INSTANCE_ID)); List predicates = new ArrayList<>(); predicates.add(root.get(AbstractTraceableEntity_.CREATION_DATE).in(maxDateSubquery)); if (criteria.getProductName() != null && !criteria.getProductName().isEmpty()) { - predicates.add(cb.equal(cb.lower(root.get(ApplicationParameter_.PRODUCT_NAME)), + predicates.add(cb.equal(cb.lower(root.get(Parameter_.PRODUCT_NAME)), criteria.getProductName().toLowerCase())); } if (criteria.getApplicationId() != null && !criteria.getApplicationId().isEmpty()) { - predicates.add(cb.equal(cb.lower(root.get(ApplicationParameter_.APPLICATION_ID)), + predicates.add(cb.equal(cb.lower(root.get(Parameter_.APPLICATION_ID)), criteria.getApplicationId().toLowerCase())); } if (criteria.getKey() != null && !criteria.getKey().isEmpty()) { - predicates.add(cb.equal(cb.lower(root.get(ApplicationParameterHistory_.KEY)), criteria.getKey().toLowerCase())); + predicates.add(cb.equal(cb.lower(root.get(ParameterHistory_.KEY)), criteria.getKey().toLowerCase())); } cq.select(root) .where(cb.and(predicates.toArray(new Predicate[0]))) - .groupBy(root.get(ApplicationParameterHistory_.INSTANCE_ID), root.get(TraceableEntity_.ID)); + .groupBy(root.get(ParameterHistory_.INSTANCE_ID), root.get(TraceableEntity_.ID)); return createPageQuery(cq, Page.of(criteria.getPageNumber(), criteria.getPageSize())).getPageResult(); } catch (Exception exception) { @@ -106,27 +106,27 @@ public PageResult searchOnlyLatestByCriteria( } } - public List searchCountsByCriteria(ApplicationParameterHistorySearchCriteria criteria) { + public List searchCountsByCriteria(ParameterHistorySearchCriteria criteria) { try { var cb = getEntityManager().getCriteriaBuilder(); CriteriaQuery cq = cb.createQuery(ParameterHistoryCountTuple.class); - Root root = cq.from(ApplicationParameterHistory.class); + Root root = cq.from(ParameterHistory.class); cq.select( cb.construct(ParameterHistoryCountTuple.class, root.get(AbstractTraceableEntity_.CREATION_DATE), - root.get(ApplicationParameterHistory_.COUNT))); + root.get(ParameterHistory_.COUNT))); List predicates = new ArrayList<>(); if (criteria.getProductName() != null && !criteria.getProductName().isEmpty()) { - predicates.add(cb.like(cb.lower(root.get(ApplicationParameter_.PRODUCT_NAME)), + predicates.add(cb.like(cb.lower(root.get(Parameter_.PRODUCT_NAME)), stringPattern(criteria.getProductName()))); } if (criteria.getApplicationId() != null && !criteria.getApplicationId().isEmpty()) { - predicates.add(cb.like(cb.lower(root.get(ApplicationParameter_.APPLICATION_ID)), + predicates.add(cb.like(cb.lower(root.get(Parameter_.APPLICATION_ID)), stringPattern(criteria.getApplicationId()))); } if (criteria.getKey() != null && !criteria.getKey().isEmpty()) { - predicates.add(cb.like(cb.lower(root.get(ApplicationParameterHistory_.KEY)), stringPattern(criteria.getKey()))); + predicates.add(cb.like(cb.lower(root.get(ParameterHistory_.KEY)), stringPattern(criteria.getKey()))); } if (!predicates.isEmpty()) { cq.where(cb.and(predicates.toArray(new Predicate[0]))); diff --git a/src/main/java/org/tkit/onecx/parameters/domain/di/v1/ParameterDataImportService.java b/src/main/java/org/tkit/onecx/parameters/domain/di/v1/ParameterDataImportService.java deleted file mode 100644 index 994aa45..0000000 --- a/src/main/java/org/tkit/onecx/parameters/domain/di/v1/ParameterDataImportService.java +++ /dev/null @@ -1,185 +0,0 @@ -package org.tkit.onecx.parameters.domain.di.v1; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; - -import jakarta.inject.Inject; -import jakarta.transaction.Transactional; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.tkit.onecx.parameters.domain.daos.ApplicationParameterDAO; -import org.tkit.onecx.parameters.domain.models.ApplicationParameter; -import org.tkit.quarkus.dataimport.DataImport; -import org.tkit.quarkus.dataimport.DataImportConfig; -import org.tkit.quarkus.dataimport.DataImportService; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import gen.org.tkit.onecx.parameters.di.v1.model.DataImportDTOV1; -import gen.org.tkit.onecx.parameters.di.v1.model.DataImportParamDTOV1; - -/** - * Import JSON format. Openapi: ./src/main/openapi/di-v1.yaml - * - *
- * {
- *   "appId" : {
- *     "key1": {
- *       "description": "description_1",
- *       "name": "name_1",
- *       "value": "value_1"
- *     },
- *     "key2": {
- *       "description": "description_2",
- *       "name": "name_2",
- *       "value": "value_2"
- *     }
- *   }
- * }
- * 
- * - *
- * operation:
- * - CLEAN_INSERT - delete all data and import new set
- * - UPDATE - update existing data from file or create new parameters
- * 
- */ -@DataImport("parameters") -public class ParameterDataImportService implements DataImportService { - - private static final Logger log = LoggerFactory.getLogger(ParameterDataImportService.class); - - public static final String KEY_SEPARATOR = "__"; - - @Inject - ApplicationParameterDAO dao; - - @Inject - ObjectMapper mapper; - - @Override - @Transactional(Transactional.TxType.REQUIRES_NEW) - public void importData(DataImportConfig config) { - log.info("Import parameters from configuration {}", config); - try { - String operation = config.getMetadata().getOrDefault("operation", "NONE"); - - Consumer action = switch (operation) { - case "CLEAN_INSERT" -> this::cleanInsert; - case "UPDATE" -> this::update; - default -> null; - }; - - if (action == null) { - log.warn("Not supported operation '{}' for the import configuration key '{}'", operation, config.getKey()); - return; - } - - if (config.getData() == null || config.getData().length == 0) { - log.warn("Import configuration key {} does not contains any data to import", config.getKey()); - return; - } - - DataImportDTOV1 data = mapper.readValue(config.getData(), DataImportDTOV1.class); - if (data.isEmpty()) { - log.warn("Import configuration key {} does not contains any JSON data to import", config.getKey()); - return; - } - action.accept(data); - } catch (Exception ex) { - throw new ErrorImportException(ex); - } - } - - public static class ErrorImportException extends RuntimeException { - public ErrorImportException(Exception ex) { - super(ex.getMessage(), ex); - } - } - - private void cleanInsert(DataImportDTOV1 data) { - - // convert import model to list of parameters - List params = new ArrayList<>(); - data.forEach((app, keys) -> { - if (keys != null && !keys.isEmpty()) { - keys.forEach((key, value) -> params.add(create(app, key, value))); - } - }); - - // delete all parameters - dao.deleteQueryAll(); - - // create new parameters - dao.create(params); - } - - private void update(DataImportDTOV1 data) { - Map values = new HashMap<>(); - data.forEach((appId, app) -> { - if (app != null) { - app.forEach((paramId, param) -> values.put(id(appId, paramId), param)); - } - }); - - // update existing parameter - Map params = dao.findApplicationParametersByKeys(values.keySet(), KEY_SEPARATOR); - if (!params.isEmpty()) { - List updated = new ArrayList<>(); - params.forEach((k, v) -> { - updated.add(update(v, values.get(k))); - values.remove(k); - - }); - dao.update(updated); - } - - // no new application parameter to create - if (values.isEmpty()) { - return; - } - - // create new parameter - List created = new ArrayList<>(); - values.forEach((k, value) -> { - String[] tmp = k.split(KEY_SEPARATOR); - created.add(create(tmp[0], tmp[1], value)); - }); - dao.create(created); - } - - private ApplicationParameter update(ApplicationParameter param, DataImportParamDTOV1 value) { - if (isValue(value.getName())) { - param.setName(value.getName()); - } - if (isValue(value.getDescription())) { - param.setDescription(value.getDescription()); - } - if (isValue(value.getValue())) { - param.setImportValue(value.getValue()); - } - return param; - } - - private ApplicationParameter create(String app, String key, DataImportParamDTOV1 value) { - ApplicationParameter param = new ApplicationParameter(); - param.setApplicationId(app); - param.setKey(key); - param.setName(value.getName()); - param.setDescription(value.getDescription()); - param.setImportValue(value.getValue()); - return param; - } - - private boolean isValue(String value) { - return value != null && !value.isBlank(); - } - - private String id(String app, String key) { - return app + KEY_SEPARATOR + key; - } -} diff --git a/src/main/java/org/tkit/onecx/parameters/domain/models/Job.java b/src/main/java/org/tkit/onecx/parameters/domain/models/Job.java index dbe588f..e8e7b7f 100644 --- a/src/main/java/org/tkit/onecx/parameters/domain/models/Job.java +++ b/src/main/java/org/tkit/onecx/parameters/domain/models/Job.java @@ -11,7 +11,7 @@ @Getter @Setter @Entity -@Table(name = "APM_JOB") +@Table(name = "JOB") public class Job extends TraceableEntity { } diff --git a/src/main/java/org/tkit/onecx/parameters/domain/models/ApplicationParameter.java b/src/main/java/org/tkit/onecx/parameters/domain/models/Parameter.java similarity index 67% rename from src/main/java/org/tkit/onecx/parameters/domain/models/ApplicationParameter.java rename to src/main/java/org/tkit/onecx/parameters/domain/models/Parameter.java index 446d9bf..b9209fc 100644 --- a/src/main/java/org/tkit/onecx/parameters/domain/models/ApplicationParameter.java +++ b/src/main/java/org/tkit/onecx/parameters/domain/models/Parameter.java @@ -12,19 +12,15 @@ @Setter @Entity @Table(name = "PARAMETER", uniqueConstraints = { - @UniqueConstraint(columnNames = { "KEY", "APPLICATION_ID", "PRODUCT_NAME", "TENANT_ID" }) }) + @UniqueConstraint(name = "PARAMETER_CONSTRAINT", columnNames = { "KEY", "APPLICATION_ID", "PRODUCT_NAME", + "TENANT_ID" }) }) @SuppressWarnings("java:S2160") -public class ApplicationParameter extends TraceableEntity { +public class Parameter extends TraceableEntity { @TenantId @Column(name = "TENANT_ID") private String tenantId; - /** - * The UID for this class. - */ - private static final long serialVersionUID = 9009055375282015896L; - /** * The application parameter key. */ @@ -57,14 +53,14 @@ public class ApplicationParameter extends TraceableEntity { private String productName; /** - * The application parameter set value. + * The parameter value. */ - @Column(name = "SET_VALUE", columnDefinition = "varchar(1000)") - private String setValue; + @Column(name = "VALUE", columnDefinition = "varchar(5000)") + private String value; /** - * The application parameter set value. + * The parameter import value. */ - @Column(name = "IMPORT_VALUE", columnDefinition = "varchar(1000)") + @Column(name = "IMPORT_VALUE", columnDefinition = "varchar(5000)") private String importValue; } diff --git a/src/main/java/org/tkit/onecx/parameters/domain/models/ApplicationParameterHistory.java b/src/main/java/org/tkit/onecx/parameters/domain/models/ParameterHistory.java similarity index 90% rename from src/main/java/org/tkit/onecx/parameters/domain/models/ApplicationParameterHistory.java rename to src/main/java/org/tkit/onecx/parameters/domain/models/ParameterHistory.java index c14644d..fa3a0de 100644 --- a/src/main/java/org/tkit/onecx/parameters/domain/models/ApplicationParameterHistory.java +++ b/src/main/java/org/tkit/onecx/parameters/domain/models/ParameterHistory.java @@ -17,17 +17,12 @@ @Entity @Table(name = "PARAMETER_HISTORY") @SuppressWarnings("java:S2160") -public class ApplicationParameterHistory extends TraceableEntity { +public class ParameterHistory extends TraceableEntity { @TenantId @Column(name = "TENANT_ID") private String tenantId; - /** - * The UID for this class. - */ - private static final long serialVersionUID = 9009055375282015896L; - /** * The application parameter key. */ diff --git a/src/main/java/org/tkit/onecx/parameters/domain/timer/MaintenanceHistoryService.java b/src/main/java/org/tkit/onecx/parameters/domain/timer/MaintenanceHistoryService.java index ea82ea9..a3f3afc 100644 --- a/src/main/java/org/tkit/onecx/parameters/domain/timer/MaintenanceHistoryService.java +++ b/src/main/java/org/tkit/onecx/parameters/domain/timer/MaintenanceHistoryService.java @@ -6,8 +6,9 @@ import jakarta.inject.Singleton; import jakarta.transaction.Transactional; -import org.tkit.onecx.parameters.domain.daos.ApplicationParameterHistoryDAO; +import org.tkit.onecx.parameters.domain.config.ParameterConfig; import org.tkit.onecx.parameters.domain.daos.JobDAO; +import org.tkit.onecx.parameters.domain.daos.ParameterHistoryDAO; import org.tkit.onecx.parameters.domain.models.Job; import org.tkit.quarkus.jpa.exceptions.DAOException; @@ -23,7 +24,7 @@ public class MaintenanceHistoryService { ParameterConfig parameterConfig; @Inject - ApplicationParameterHistoryDAO dao; + ParameterHistoryDAO dao; @Inject JobDAO jobDAO; diff --git a/src/main/java/org/tkit/onecx/parameters/rs/external/v1/controllers/ParameterRestControllerV1.java b/src/main/java/org/tkit/onecx/parameters/rs/external/v1/controllers/ParameterRestControllerV1.java index 4b48dce..8a1838d 100644 --- a/src/main/java/org/tkit/onecx/parameters/rs/external/v1/controllers/ParameterRestControllerV1.java +++ b/src/main/java/org/tkit/onecx/parameters/rs/external/v1/controllers/ParameterRestControllerV1.java @@ -12,11 +12,11 @@ import org.jboss.resteasy.reactive.RestResponse; import org.jboss.resteasy.reactive.server.ServerExceptionMapper; -import org.tkit.onecx.parameters.domain.daos.ApplicationParameterDAO; -import org.tkit.onecx.parameters.domain.daos.ApplicationParameterHistoryDAO; -import org.tkit.onecx.parameters.domain.models.ApplicationParameterHistory; -import org.tkit.onecx.parameters.rs.external.v1.mappers.ApplicationParameterHistoryMapper; -import org.tkit.onecx.parameters.rs.external.v1.mappers.ExceptionMapper; +import org.tkit.onecx.parameters.domain.daos.ParameterDAO; +import org.tkit.onecx.parameters.domain.daos.ParameterHistoryDAO; +import org.tkit.onecx.parameters.domain.models.ParameterHistory; +import org.tkit.onecx.parameters.rs.external.v1.mappers.ExceptionMapperV1; +import org.tkit.onecx.parameters.rs.external.v1.mappers.ParameterMapperV1; import org.tkit.quarkus.log.cdi.LogService; import gen.org.tkit.onecx.parameters.rs.v1.ParameterApi; @@ -29,22 +29,25 @@ public class ParameterRestControllerV1 implements ParameterApi { @Inject - ApplicationParameterDAO applicationParameterDAO; + ParameterDAO applicationParameterDAO; @Inject - ApplicationParameterHistoryDAO historyDAO; + ParameterHistoryDAO historyDAO; @Inject - ApplicationParameterHistoryMapper mapper; + ParameterMapperV1 mapper; @Inject - ExceptionMapper exceptionMapper; + ExceptionMapperV1 exceptionMapper; @Override - public Response getApplicationParameters(String productName, String appId) { + public Response getParameters(String productName, String appId) { Map applicationParameters = applicationParameterDAO.findAllByProductNameAndApplicationId(productName, appId); - return Response.ok(applicationParameters).build(); + if (applicationParameters.isEmpty()) { + return Response.status(Response.Status.NOT_FOUND).build(); + } + return Response.ok(mapper.mapParameters(applicationParameters)).build(); } @Override @@ -52,7 +55,7 @@ public Response bucketRequest(String productName, String appId, ParametersBucket if (dto.getParameters() == null || dto.getParameters().isEmpty()) { return Response.status(Response.Status.NO_CONTENT).build(); } - List items = new ArrayList<>(); + List items = new ArrayList<>(); dto.getParameters().forEach((key, value) -> items .add(mapper.mapItem(value, key, dto, productName, appId, value.getCurrentValue()))); diff --git a/src/main/java/org/tkit/onecx/parameters/rs/external/v1/log/ExternalV1LogParam.java b/src/main/java/org/tkit/onecx/parameters/rs/external/v1/log/ParameterLogParamV1.java similarity index 90% rename from src/main/java/org/tkit/onecx/parameters/rs/external/v1/log/ExternalV1LogParam.java rename to src/main/java/org/tkit/onecx/parameters/rs/external/v1/log/ParameterLogParamV1.java index df1927b..cd211f0 100644 --- a/src/main/java/org/tkit/onecx/parameters/rs/external/v1/log/ExternalV1LogParam.java +++ b/src/main/java/org/tkit/onecx/parameters/rs/external/v1/log/ParameterLogParamV1.java @@ -9,7 +9,7 @@ import gen.org.tkit.onecx.parameters.rs.v1.model.ParametersBucketDTOV1; @ApplicationScoped -public class ExternalV1LogParam implements LogParam { +public class ParameterLogParamV1 implements LogParam { @Override public List getClasses() { diff --git a/src/main/java/org/tkit/onecx/parameters/rs/external/v1/mappers/ApplicationParameterHistoryMapper.java b/src/main/java/org/tkit/onecx/parameters/rs/external/v1/mappers/ApplicationParameterHistoryMapper.java deleted file mode 100644 index 62d115e..0000000 --- a/src/main/java/org/tkit/onecx/parameters/rs/external/v1/mappers/ApplicationParameterHistoryMapper.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.tkit.onecx.parameters.rs.external.v1.mappers; - -import org.mapstruct.Mapper; -import org.mapstruct.MapperConfig; -import org.mapstruct.Mapping; -import org.mapstruct.ReportingPolicy; -import org.tkit.onecx.parameters.domain.models.ApplicationParameterHistory; -import org.tkit.quarkus.rs.mappers.OffsetDateTimeMapper; - -import gen.org.tkit.onecx.parameters.rs.v1.model.ParameterInfoDTOV1; -import gen.org.tkit.onecx.parameters.rs.v1.model.ParametersBucketDTOV1; - -@Mapper(uses = OffsetDateTimeMapper.class) -@MapperConfig(unmappedTargetPolicy = ReportingPolicy.ERROR) -public interface ApplicationParameterHistoryMapper { - - @Mapping(target = "tenantId", ignore = true) - @Mapping(target = "creationDate", ignore = true) - @Mapping(target = "creationUser", ignore = true) - @Mapping(target = "modificationDate", ignore = true) - @Mapping(target = "modificationUser", ignore = true) - @Mapping(target = "controlTraceabilityManual", ignore = true) - @Mapping(target = "modificationCount", ignore = true) - @Mapping(target = "persisted", ignore = true) - @Mapping(target = "id", ignore = true) - ApplicationParameterHistory mapItem(ParameterInfoDTOV1 dto, String key, ParametersBucketDTOV1 bucketDTO, String productName, - String applicationId, String usedValue); - -} diff --git a/src/main/java/org/tkit/onecx/parameters/rs/external/v1/mappers/ExceptionMapper.java b/src/main/java/org/tkit/onecx/parameters/rs/external/v1/mappers/ExceptionMapperV1.java similarity index 98% rename from src/main/java/org/tkit/onecx/parameters/rs/external/v1/mappers/ExceptionMapper.java rename to src/main/java/org/tkit/onecx/parameters/rs/external/v1/mappers/ExceptionMapperV1.java index 267cf78..cd07673 100644 --- a/src/main/java/org/tkit/onecx/parameters/rs/external/v1/mappers/ExceptionMapper.java +++ b/src/main/java/org/tkit/onecx/parameters/rs/external/v1/mappers/ExceptionMapperV1.java @@ -21,7 +21,7 @@ @Slf4j @Mapper(uses = { OffsetDateTimeMapper.class }) -public abstract class ExceptionMapper { +public abstract class ExceptionMapperV1 { public RestResponse constraint(ConstraintViolationException ex) { var dto = exception(ErrorKeys.CONSTRAINT_VIOLATIONS.name(), ex.getMessage()); diff --git a/src/main/java/org/tkit/onecx/parameters/rs/external/v1/mappers/ParameterMapperV1.java b/src/main/java/org/tkit/onecx/parameters/rs/external/v1/mappers/ParameterMapperV1.java new file mode 100644 index 0000000..de5d47b --- /dev/null +++ b/src/main/java/org/tkit/onecx/parameters/rs/external/v1/mappers/ParameterMapperV1.java @@ -0,0 +1,61 @@ +package org.tkit.onecx.parameters.rs.external.v1.mappers; + +import java.util.HashMap; +import java.util.Map; + +import jakarta.inject.Inject; + +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.tkit.onecx.parameters.domain.models.ParameterHistory; +import org.tkit.quarkus.rs.mappers.OffsetDateTimeMapper; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import gen.org.tkit.onecx.parameters.rs.v1.model.ParameterInfoDTOV1; +import gen.org.tkit.onecx.parameters.rs.v1.model.ParametersBucketDTOV1; + +@Mapper(uses = OffsetDateTimeMapper.class) +public abstract class ParameterMapperV1 { + + @Inject + ObjectMapper objectMapper; + + public Map mapParameters(Map parameters) { + Map data = new HashMap<>(); + try { + for (Map.Entry e : parameters.entrySet()) { + if (e.getValue() == null || e.getValue().isBlank()) { + data.put(e.getKey(), null); + } else { + data.put(e.getKey(), objectMapper.readValue(e.getValue(), Object.class)); + } + } + } catch (Exception e) { + throw new MapperException("Error reading parameter", e); + } + return data; + } + + @Mapping(target = "tenantId", ignore = true) + @Mapping(target = "creationDate", ignore = true) + @Mapping(target = "creationUser", ignore = true) + @Mapping(target = "modificationDate", ignore = true) + @Mapping(target = "modificationUser", ignore = true) + @Mapping(target = "controlTraceabilityManual", ignore = true) + @Mapping(target = "modificationCount", ignore = true) + @Mapping(target = "persisted", ignore = true) + @Mapping(target = "id", ignore = true) + public abstract ParameterHistory mapItem(ParameterInfoDTOV1 dto, String key, ParametersBucketDTOV1 bucketDTO, + String productName, + String applicationId, String usedValue); + + public static class MapperException extends RuntimeException { + + public MapperException(String msg, Throwable t) { + super(msg, t); + } + + } + +} diff --git a/src/main/java/org/tkit/onecx/parameters/rs/internal/controllers/ApplicationParameterHistoryRestController.java b/src/main/java/org/tkit/onecx/parameters/rs/internal/controllers/HistoryRestController.java similarity index 65% rename from src/main/java/org/tkit/onecx/parameters/rs/internal/controllers/ApplicationParameterHistoryRestController.java rename to src/main/java/org/tkit/onecx/parameters/rs/internal/controllers/HistoryRestController.java index a5d93b8..4cfaaa4 100644 --- a/src/main/java/org/tkit/onecx/parameters/rs/internal/controllers/ApplicationParameterHistoryRestController.java +++ b/src/main/java/org/tkit/onecx/parameters/rs/internal/controllers/HistoryRestController.java @@ -5,43 +5,43 @@ import jakarta.transaction.Transactional; import jakarta.ws.rs.core.Response; -import org.tkit.onecx.parameters.domain.daos.ApplicationParameterHistoryDAO; -import org.tkit.onecx.parameters.domain.models.ApplicationParameterHistory; -import org.tkit.onecx.parameters.rs.internal.mappers.ApplicationParameterInternalMapper; +import org.tkit.onecx.parameters.domain.daos.ParameterHistoryDAO; +import org.tkit.onecx.parameters.domain.models.ParameterHistory; +import org.tkit.onecx.parameters.rs.internal.mappers.ParameterMapper; import org.tkit.quarkus.log.cdi.LogService; import gen.org.tkit.onecx.parameters.rs.internal.HistoriesApi; -import gen.org.tkit.onecx.parameters.rs.internal.model.ApplicationParameterHistoryCriteriaDTO; import gen.org.tkit.onecx.parameters.rs.internal.model.ParameterHistoryCountCriteriaDTO; +import gen.org.tkit.onecx.parameters.rs.internal.model.ParameterHistoryCriteriaDTO; @LogService @ApplicationScoped @Transactional(value = Transactional.TxType.NOT_SUPPORTED) -public class ApplicationParameterHistoryRestController implements HistoriesApi { +public class HistoryRestController implements HistoriesApi { @Inject - ApplicationParameterInternalMapper applicationParameterInternalMapper; + ParameterMapper applicationParameterInternalMapper; @Inject - ApplicationParameterHistoryDAO historyDAO; + ParameterHistoryDAO historyDAO; @Override - public Response getAllApplicationParametersHistoryLatest(ApplicationParameterHistoryCriteriaDTO criteriaDTO) { + public Response getAllParametersHistoryLatest(ParameterHistoryCriteriaDTO criteriaDTO) { var criteria = applicationParameterInternalMapper.map(criteriaDTO); var parametersHistories = historyDAO.searchOnlyLatestByCriteria(criteria); return Response.ok(applicationParameterInternalMapper.mapHistory(parametersHistories)).build(); } @Override - public Response getAllApplicationParametersHistory(ApplicationParameterHistoryCriteriaDTO criteriaDTO) { + public Response getAllParametersHistory(ParameterHistoryCriteriaDTO criteriaDTO) { var criteria = applicationParameterInternalMapper.map(criteriaDTO); var parametersHistories = historyDAO.searchByCriteria(criteria); return Response.ok(applicationParameterInternalMapper.mapHistory(parametersHistories)).build(); } @Override - public Response getApplicationParametersHistoryById(String id) { - ApplicationParameterHistory parameter = historyDAO.findById(id); + public Response getParametersHistoryById(String id) { + ParameterHistory parameter = historyDAO.findById(id); if (parameter == null) { return Response.status(Response.Status.NOT_FOUND).build(); } diff --git a/src/main/java/org/tkit/onecx/parameters/rs/internal/controllers/ApplicationParameterRestController.java b/src/main/java/org/tkit/onecx/parameters/rs/internal/controllers/ParameterRestController.java similarity index 54% rename from src/main/java/org/tkit/onecx/parameters/rs/internal/controllers/ApplicationParameterRestController.java rename to src/main/java/org/tkit/onecx/parameters/rs/internal/controllers/ParameterRestController.java index 468385f..c45482a 100644 --- a/src/main/java/org/tkit/onecx/parameters/rs/internal/controllers/ApplicationParameterRestController.java +++ b/src/main/java/org/tkit/onecx/parameters/rs/internal/controllers/ParameterRestController.java @@ -10,10 +10,10 @@ import org.jboss.resteasy.reactive.RestResponse; import org.jboss.resteasy.reactive.server.ServerExceptionMapper; -import org.tkit.onecx.parameters.domain.daos.ApplicationParameterDAO; -import org.tkit.onecx.parameters.domain.models.ApplicationParameter; -import org.tkit.onecx.parameters.rs.internal.mappers.ApplicationParameterInternalMapper; +import org.tkit.onecx.parameters.domain.daos.ParameterDAO; +import org.tkit.onecx.parameters.domain.models.Parameter; import org.tkit.onecx.parameters.rs.internal.mappers.ExceptionMapper; +import org.tkit.onecx.parameters.rs.internal.mappers.ParameterMapper; import org.tkit.quarkus.jpa.exceptions.ConstraintException; import org.tkit.quarkus.log.cdi.LogService; @@ -23,13 +23,13 @@ @LogService @ApplicationScoped @Transactional(value = Transactional.TxType.NOT_SUPPORTED) -public class ApplicationParameterRestController implements ParametersApi { +public class ParameterRestController implements ParametersApi { @Inject - ApplicationParameterDAO applicationParameterDAO; + ParameterDAO parameterDAO; @Inject - ApplicationParameterInternalMapper applicationParameterInternalMapper; + ParameterMapper parameterMapper; @Context UriInfo uriInfo; @@ -39,73 +39,67 @@ public class ApplicationParameterRestController implements ParametersApi { @Override public Response getAllApplications() { - var apps = applicationParameterDAO.searchAllProductNamesAndApplicationIds(); - return Response.ok(applicationParameterInternalMapper.apps(apps)).build(); + var apps = parameterDAO.searchAllProductNamesAndApplicationIds(); + return Response.ok(parameterMapper.apps(apps)).build(); } @Override public Response getAllKeys(String applicationId, String productName) { - var criteria = applicationParameterInternalMapper.map(productName, applicationId); - var keys = applicationParameterDAO.searchAllKeys(criteria); - return Response.ok(applicationParameterInternalMapper.keys(keys)).build(); + var criteria = parameterMapper.map(productName, applicationId); + var keys = parameterDAO.searchAllKeys(criteria); + return Response.ok(parameterMapper.keys(keys)).build(); } @Override - public Response searchApplicationParametersByCriteria(ParameterSearchCriteriaDTO criteriaDTO) { + public Response searchParametersByCriteria(ParameterSearchCriteriaDTO criteriaDTO) { - var criteria = applicationParameterInternalMapper.map(criteriaDTO); - var parameters = applicationParameterDAO.searchByCriteria(criteria); - ApplicationParameterPageResultDTO results = applicationParameterInternalMapper.map(parameters); + var criteria = parameterMapper.map(criteriaDTO); + var parameters = parameterDAO.searchByCriteria(criteria); + ParameterPageResultDTO results = parameterMapper.map(parameters); return Response.ok(results).build(); } @Override public Response getParameterById(String id) { - ApplicationParameter param = applicationParameterDAO.findById(id); + Parameter param = parameterDAO.findById(id); if (param == null) { return Response.status(Response.Status.NOT_FOUND) .entity(exceptionMapper.exception(Response.Status.NOT_FOUND.name(), "Parameter with id" + id + " not found.")) .build(); } - ApplicationParameterDTO parameterDTO = applicationParameterInternalMapper.map(param); + ParameterDTO parameterDTO = parameterMapper.map(param); return Response.ok(parameterDTO).build(); } @Override - @Transactional public Response updateParameterValue(String id, - ApplicationParameterUpdateDTO applicationParameterUpdateDTO) { - ApplicationParameter applicationParameter = applicationParameterDAO.findById(id); - if (applicationParameter == null) { + ParameterUpdateDTO parameterUpdateDTO) { + Parameter parameter = parameterDAO.findById(id); + if (parameter == null) { return Response.status(Response.Status.NOT_FOUND) .entity(exceptionMapper.exception(Response.Status.NOT_FOUND.name(), "Parameter with id" + id + " not found.")) .build(); } - applicationParameterInternalMapper.update(applicationParameterUpdateDTO, applicationParameter); - applicationParameterDAO.update(applicationParameter); + parameterMapper.update(parameterUpdateDTO, parameter); + parameterDAO.update(parameter); return Response.status(Response.Status.NO_CONTENT.getStatusCode()).build(); } @Override - @Transactional - public Response createParameterValue(ApplicationParameterCreateDTO request) { + public Response createParameter(ParameterCreateDTO request) { - ApplicationParameter param = applicationParameterInternalMapper.create(request); - param = applicationParameterDAO.create(param); + Parameter param = parameterMapper.create(request); + param = parameterDAO.create(param); return Response .created(uriInfo.getAbsolutePathBuilder().path(param.getId()).build()) .build(); } @Override - @Transactional public Response deleteParameter(String id) { - ApplicationParameter parameter = applicationParameterDAO.findById(id); - if (parameter != null) { - applicationParameterDAO.delete(parameter); - } + parameterDAO.deleteQueryById(id); return Response.status(Response.Status.NO_CONTENT.getStatusCode()).build(); } diff --git a/src/main/java/org/tkit/onecx/parameters/rs/internal/log/InternalLogParam.java b/src/main/java/org/tkit/onecx/parameters/rs/internal/log/ParameterLogParam.java similarity index 65% rename from src/main/java/org/tkit/onecx/parameters/rs/internal/log/InternalLogParam.java rename to src/main/java/org/tkit/onecx/parameters/rs/internal/log/ParameterLogParam.java index e56e955..5e79041 100644 --- a/src/main/java/org/tkit/onecx/parameters/rs/internal/log/InternalLogParam.java +++ b/src/main/java/org/tkit/onecx/parameters/rs/internal/log/ParameterLogParam.java @@ -9,14 +9,14 @@ import gen.org.tkit.onecx.parameters.rs.internal.model.*; @ApplicationScoped -public class InternalLogParam implements LogParam { +public class ParameterLogParam implements LogParam { @Override public List getClasses() { return List.of( - item(10, ApplicationParameterHistoryCriteriaDTO.class, x -> { - ApplicationParameterHistoryCriteriaDTO d = (ApplicationParameterHistoryCriteriaDTO) x; - return ApplicationParameterHistoryCriteriaDTO.class.getSimpleName() + "[" + d.getPageNumber() + "," + item(10, ParameterHistoryCriteriaDTO.class, x -> { + ParameterHistoryCriteriaDTO d = (ParameterHistoryCriteriaDTO) x; + return ParameterHistoryCriteriaDTO.class.getSimpleName() + "[" + d.getPageNumber() + "," + d.getPageSize() + "]"; }), @@ -31,9 +31,9 @@ public List getClasses() { return ParameterSearchCriteriaDTO.class.getSimpleName() + "[" + d.getPageNumber() + "," + d.getPageSize() + "]"; }), - item(10, ApplicationParameterCreateDTO.class, - x -> x.getClass().getSimpleName() + ":" + ((ApplicationParameterCreateDTO) x).getKey()), - item(10, ApplicationParameterUpdateDTO.class, - x -> x.getClass().getSimpleName() + ":" + ((ApplicationParameterUpdateDTO) x).getUnit())); + item(10, ParameterCreateDTO.class, + x -> x.getClass().getSimpleName() + ":" + ((ParameterCreateDTO) x).getKey()), + item(10, ParameterUpdateDTO.class, + x -> x.getClass().getSimpleName())); } } diff --git a/src/main/java/org/tkit/onecx/parameters/rs/internal/mappers/ApplicationParameterInternalMapper.java b/src/main/java/org/tkit/onecx/parameters/rs/internal/mappers/ApplicationParameterInternalMapper.java deleted file mode 100644 index 179c822..0000000 --- a/src/main/java/org/tkit/onecx/parameters/rs/internal/mappers/ApplicationParameterInternalMapper.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.tkit.onecx.parameters.rs.internal.mappers; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.mapstruct.*; -import org.tkit.onecx.parameters.domain.criteria.ApplicationParameterHistorySearchCriteria; -import org.tkit.onecx.parameters.domain.criteria.ApplicationParameterSearchCriteria; -import org.tkit.onecx.parameters.domain.criteria.KeysSearchCriteria; -import org.tkit.onecx.parameters.domain.models.ApplicationParameter; -import org.tkit.onecx.parameters.domain.models.ApplicationParameterHistory; -import org.tkit.onecx.parameters.domain.models.ApplicationTuple; -import org.tkit.onecx.parameters.domain.models.ParameterHistoryCountTuple; -import org.tkit.quarkus.jpa.daos.PageResult; -import org.tkit.quarkus.rs.mappers.OffsetDateTimeMapper; - -import gen.org.tkit.onecx.parameters.rs.internal.model.*; - -@Mapper(uses = { OffsetDateTimeMapper.class }) -public interface ApplicationParameterInternalMapper { - - @BeanMapping(nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT) - KeysSearchCriteria map(String productName, String applicationId); - - @Mapping(target = "removeStreamItem", ignore = true) - KeysPageResultDTO keys(PageResult page); - - default List apps(List applicationTuple) { - Map> productMap = new HashMap<>(); - - for (ApplicationTuple singleApplicationTuple : applicationTuple) { - productMap - .computeIfAbsent(singleApplicationTuple.productName(), k -> new ArrayList<>()) - .add(singleApplicationTuple.appId()); - } - - List products = new ArrayList<>(); - for (Map.Entry> entry : productMap.entrySet()) { - products.add(new ProductDTO().productName(entry.getKey()).applications(entry.getValue())); - } - - return products; - } - - @BeanMapping(nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT) - ApplicationParameterHistorySearchCriteria map(ApplicationParameterHistoryCriteriaDTO criteriaDTO); - - @BeanMapping(nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT) - ApplicationParameterHistorySearchCriteria map(ParameterHistoryCountCriteriaDTO criteriaDTO); - - @BeanMapping(nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT) - ApplicationParameterSearchCriteria map(ParameterSearchCriteriaDTO criteriaDTO); - - @Mapping(target = "removeStreamItem", ignore = true) - ApplicationParameterHistoryPageResultDTO mapHistory(PageResult page); - - ApplicationParameterHistoryDTO mapHistory(ApplicationParameterHistory applicationParameterHistory); - - List mapCountList(List count); - - @Mapping(target = "removeStreamItem", ignore = true) - ApplicationParameterPageResultDTO map(PageResult page); - - @Mapping(target = "value", ignore = true) - @Mapping(target = "unit", ignore = true) - @Mapping(target = "rangeFrom", ignore = true) - @Mapping(target = "rangeTo", ignore = true) - ApplicationParameterDTO map(ApplicationParameter applicationParameter); - - @Named("setValue") - default String objectToSetValue(Object value) { - if (value != null) { - return value.toString(); - } - return null; - } - - default void update(ApplicationParameterUpdateDTO dto, ApplicationParameter applicationParameter) { - if (dto == null) { - return; - } - if (dto.getDescription() != null && !dto.getDescription().isEmpty()) { - applicationParameter.setDescription(dto.getDescription()); - } - if (dto.getValue() != null) { - applicationParameter.setSetValue(objectToSetValue(dto.getValue())); - } - } - - @Mapping(target = "tenantId", ignore = true) - @Mapping(target = "setValue", source = "value") - @Mapping(target = "persisted", ignore = true) - @Mapping(target = "name", ignore = true) - @Mapping(target = "modificationUser", ignore = true) - @Mapping(target = "modificationDate", ignore = true) - @Mapping(target = "modificationCount", ignore = true) - @Mapping(target = "importValue", ignore = true) - @Mapping(target = "id", ignore = true) - @Mapping(target = "creationUser", ignore = true) - @Mapping(target = "creationDate", ignore = true) - @Mapping(target = "controlTraceabilityManual", ignore = true) - ApplicationParameter create(ApplicationParameterCreateDTO request); -} diff --git a/src/main/java/org/tkit/onecx/parameters/rs/internal/mappers/ParameterMapper.java b/src/main/java/org/tkit/onecx/parameters/rs/internal/mappers/ParameterMapper.java new file mode 100644 index 0000000..d5448fd --- /dev/null +++ b/src/main/java/org/tkit/onecx/parameters/rs/internal/mappers/ParameterMapper.java @@ -0,0 +1,139 @@ +package org.tkit.onecx.parameters.rs.internal.mappers; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jakarta.inject.Inject; + +import org.mapstruct.*; +import org.tkit.onecx.parameters.domain.criteria.KeysSearchCriteria; +import org.tkit.onecx.parameters.domain.criteria.ParameterHistorySearchCriteria; +import org.tkit.onecx.parameters.domain.criteria.ParameterSearchCriteria; +import org.tkit.onecx.parameters.domain.models.ApplicationTuple; +import org.tkit.onecx.parameters.domain.models.Parameter; +import org.tkit.onecx.parameters.domain.models.ParameterHistory; +import org.tkit.onecx.parameters.domain.models.ParameterHistoryCountTuple; +import org.tkit.quarkus.jpa.daos.PageResult; +import org.tkit.quarkus.rs.mappers.OffsetDateTimeMapper; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import gen.org.tkit.onecx.parameters.rs.internal.model.*; + +@Mapper(uses = { OffsetDateTimeMapper.class }) +public abstract class ParameterMapper { + + @Inject + ObjectMapper objectMapper; + + @BeanMapping(nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT) + public abstract KeysSearchCriteria map(String productName, String applicationId); + + @Mapping(target = "removeStreamItem", ignore = true) + public abstract KeysPageResultDTO keys(PageResult page); + + public List apps(List applicationTuple) { + Map> productMap = new HashMap<>(); + + for (ApplicationTuple singleApplicationTuple : applicationTuple) { + productMap + .computeIfAbsent(singleApplicationTuple.productName(), k -> new ArrayList<>()) + .add(singleApplicationTuple.appId()); + } + + List products = new ArrayList<>(); + for (Map.Entry> entry : productMap.entrySet()) { + products.add(new ProductDTO().productName(entry.getKey()).applications(entry.getValue())); + } + + return products; + } + + @BeanMapping(nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT) + public abstract ParameterHistorySearchCriteria map(ParameterHistoryCriteriaDTO criteriaDTO); + + @BeanMapping(nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT) + public abstract ParameterHistorySearchCriteria map(ParameterHistoryCountCriteriaDTO criteriaDTO); + + @BeanMapping(nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT) + public abstract ParameterSearchCriteria map(ParameterSearchCriteriaDTO criteriaDTO); + + @Mapping(target = "removeStreamItem", ignore = true) + public abstract ParameterHistoryPageResultDTO mapHistory(PageResult page); + + public abstract ParameterHistoryDTO mapHistory(ParameterHistory parameterHistory); + + public abstract List mapCountList(List count); + + @Mapping(target = "removeStreamItem", ignore = true) + public abstract ParameterPageResultDTO map(PageResult page); + + @Mapping(target = "value", source = "value", qualifiedByName = "s2o") + @Mapping(target = "importValue", source = "importValue", qualifiedByName = "s2o") + public abstract ParameterDTO map(Parameter parameter); + + @Named("s2o") + public Object s2o(String value) { + if (value == null || value.isBlank()) { + return null; + } + try { + return objectMapper.readValue(value, Object.class); + } catch (Exception e) { + throw new MapperException("Error reading parameter value", e); + } + } + + @Named("o2s") + public String o2s(Object value) { + if (value == null) { + return null; + } + try { + return objectMapper.writeValueAsString(value); + } catch (Exception e) { + throw new MapperException("Error reading parameter value", e); + } + } + + @Mapping(target = "tenantId", ignore = true) + @Mapping(target = "value", source = "value", qualifiedByName = "o2s") + @Mapping(target = "persisted", ignore = true) + @Mapping(target = "name", ignore = true) + @Mapping(target = "modificationUser", ignore = true) + @Mapping(target = "modificationDate", ignore = true) + @Mapping(target = "modificationCount", ignore = true) + @Mapping(target = "importValue", ignore = true) + @Mapping(target = "id", ignore = true) + @Mapping(target = "creationUser", ignore = true) + @Mapping(target = "creationDate", ignore = true) + @Mapping(target = "controlTraceabilityManual", ignore = true) + @Mapping(target = "key", ignore = true) + @Mapping(target = "applicationId", ignore = true) + @Mapping(target = "productName", ignore = true) + public abstract void update(ParameterUpdateDTO dto, @MappingTarget Parameter parameter); + + @Mapping(target = "tenantId", ignore = true) + @Mapping(target = "value", source = "value", qualifiedByName = "o2s") + @Mapping(target = "persisted", ignore = true) + @Mapping(target = "name", ignore = true) + @Mapping(target = "modificationUser", ignore = true) + @Mapping(target = "modificationDate", ignore = true) + @Mapping(target = "modificationCount", ignore = true) + @Mapping(target = "importValue", ignore = true) + @Mapping(target = "id", ignore = true) + @Mapping(target = "creationUser", ignore = true) + @Mapping(target = "creationDate", ignore = true) + @Mapping(target = "controlTraceabilityManual", ignore = true) + public abstract Parameter create(ParameterCreateDTO request); + + public static class MapperException extends RuntimeException { + + public MapperException(String msg, Throwable t) { + super(msg, t); + } + + } +} diff --git a/src/main/openapi/di-v1.yaml b/src/main/openapi/di-v1.yaml deleted file mode 100644 index 493268c..0000000 --- a/src/main/openapi/di-v1.yaml +++ /dev/null @@ -1,54 +0,0 @@ ---- -openapi: 3.0.3 -info: - title: onecx-parameter data import - version: 1.0.0 -servers: - - url: "http://localhost" -paths: - /import/parameter: - post: - security: - - oauth2: [ ocx-pa:write ] - operationId: importParameter - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/DataImport' - responses: - 200: - description: ok -components: - securitySchemes: - oauth2: - type: oauth2 - flows: - clientCredentials: - tokenUrl: https://oauth.simple.api/token - scopes: - ocx-pa:write: Grants write access - schemas: - DataImport: - type: object - properties: - default: - type: string - additionalProperties: - $ref: '#/components/schemas/DataImportApp' - DataImportApp: - type: object - properties: - default: - type: string - additionalProperties: - $ref: '#/components/schemas/DataImportParam' - DataImportParam: - type: object - properties: - description: - type: string - name: - type: string - value: - type: string diff --git a/src/main/openapi/openapi-internal.yaml b/src/main/openapi/openapi-internal.yaml index 19ed9d4..e99cde5 100644 --- a/src/main/openapi/openapi-internal.yaml +++ b/src/main/openapi/openapi-internal.yaml @@ -17,19 +17,19 @@ paths: tags: - histories description: Find all parameters history - operationId: getAllApplicationParametersHistory + operationId: getAllParametersHistory requestBody: content: application/json: schema: - $ref: '#/components/schemas/ApplicationParameterHistoryCriteria' + $ref: '#/components/schemas/ParameterHistoryCriteria' responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/ApplicationParameterHistoryPageResult' + $ref: '#/components/schemas/ParameterHistoryPageResult' /histories/counts: post: security: @@ -59,19 +59,19 @@ paths: tags: - histories description: Find all parameters history latest - operationId: getAllApplicationParametersHistoryLatest + operationId: getAllParametersHistoryLatest requestBody: content: application/json: schema: - $ref: '#/components/schemas/ApplicationParameterHistoryCriteria' + $ref: '#/components/schemas/ParameterHistoryCriteria' responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/ApplicationParameterHistoryPageResult' + $ref: '#/components/schemas/ParameterHistoryPageResult' /histories/{id}: get: security: @@ -79,7 +79,7 @@ paths: tags: - histories description: Find parameters history by Id - operationId: getApplicationParametersHistoryById + operationId: getParametersHistoryById parameters: - name: id in: path @@ -92,7 +92,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ApplicationParameterHistory' + $ref: '#/components/schemas/ParameterHistory' "404": description: Not Found /parameters/search: @@ -102,7 +102,7 @@ paths: tags: - parameters description: Find all parameters by criteria - operationId: searchApplicationParametersByCriteria + operationId: searchParametersByCriteria requestBody: required: true content: @@ -115,7 +115,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ApplicationParameterPageResult' + $ref: '#/components/schemas/ParameterPageResult' "400": description: Bad Request content: @@ -129,13 +129,13 @@ paths: tags: - parameters description: Create parameter - operationId: createParameterValue + operationId: createParameter requestBody: required: true content: application/json: schema: - $ref: '#/components/schemas/ApplicationParameterCreate' + $ref: '#/components/schemas/ParameterCreate' responses: "204": description: No Content @@ -178,7 +178,7 @@ paths: - name: applicationId in: query schema: - description: The application parameter id. + description: The application id. type: string - name: productName in: query @@ -214,7 +214,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ApplicationParameter' + $ref: '#/components/schemas/Parameter' "400": description: Bad request "404": @@ -237,7 +237,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ApplicationParameterUpdate' + $ref: '#/components/schemas/ParameterUpdate' responses: "204": description: No Content @@ -284,7 +284,7 @@ components: ocx-pa:write: Grants write access ocx-pa:delete: Grants access to delete operations schemas: - ApplicationParameterCreate: + ParameterCreate: type: object properties: key: @@ -294,18 +294,10 @@ components: productName: type: string value: - type: string + type: object description: type: string - unit: - type: string - rangeFrom: - format: int32 - type: integer - rangeTo: - format: int32 - type: integer - ApplicationParameter: + Parameter: type: object properties: id: @@ -335,19 +327,11 @@ components: type: string key: type: string - setValue: - type: string + value: + type: object importValue: - type: string - unit: - type: string - rangeFrom: - format: int32 - type: integer - rangeTo: - format: int32 - type: integer - ApplicationParameterHistory: + type: object + ParameterHistory: type: object properties: id: @@ -374,14 +358,14 @@ components: key: type: string usedValue: - type: string + type: object defaultValue: - type: string + type: object type: type: string instanceId: type: string - ApplicationParameterHistoryCriteria: + ParameterHistoryCriteria: type: object properties: applicationId: @@ -402,7 +386,7 @@ components: type: array items: type: string - ApplicationParameterHistoryPageResult: + ParameterHistoryPageResult: type: object properties: totalElements: @@ -421,8 +405,8 @@ components: stream: type: array items: - $ref: '#/components/schemas/ApplicationParameterHistory' - ApplicationParameterPageResult: + $ref: '#/components/schemas/ParameterHistory' + ParameterPageResult: type: object properties: totalElements: @@ -441,21 +425,14 @@ components: stream: type: array items: - $ref: '#/components/schemas/ApplicationParameter' - ApplicationParameterUpdate: + $ref: '#/components/schemas/Parameter' + ParameterUpdate: type: object properties: - value: {} + value: + type: object description: type: string - unit: - type: string - rangeFrom: - format: int32 - type: integer - rangeTo: - format: int32 - type: integer Product: type: object properties: diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 413b9d0..89dc3c5 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -10,7 +10,6 @@ quarkus.http.auth.permission.health.policy=permit quarkus.http.auth.permission.default.paths=/* quarkus.http.auth.permission.default.policy=authenticated -quarkus.banner.enabled=false quarkus.hibernate-orm.database.generation=validate quarkus.hibernate-orm.multitenant=DISCRIMINATOR diff --git a/src/main/resources/db/2024-06-05-drop-apm-param-data.xml b/src/main/resources/db/2024-06-05-drop-apm-param-data.xml deleted file mode 100644 index 96f96ab..0000000 --- a/src/main/resources/db/2024-06-05-drop-apm-param-data.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/db/24-04-2024-multi-tenancy.xml b/src/main/resources/db/24-04-2024-multi-tenancy.xml deleted file mode 100644 index d936f90..0000000 --- a/src/main/resources/db/24-04-2024-multi-tenancy.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/db/changeLog.xml b/src/main/resources/db/changeLog.xml index 4b825a1..44e6ce3 100644 --- a/src/main/resources/db/changeLog.xml +++ b/src/main/resources/db/changeLog.xml @@ -4,8 +4,5 @@ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> - - - - + diff --git a/src/main/resources/db/createTables.xml b/src/main/resources/db/createTables.xml deleted file mode 100644 index 7b964d7..0000000 --- a/src/main/resources/db/createTables.xml +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/db/18-11-2024-rename-tables.xml b/src/main/resources/db/v1/2024-12-13-create-tables.xml similarity index 62% rename from src/main/resources/db/18-11-2024-rename-tables.xml rename to src/main/resources/db/v1/2024-12-13-create-tables.xml index 40c1bcb..ff25c06 100644 --- a/src/main/resources/db/18-11-2024-rename-tables.xml +++ b/src/main/resources/db/v1/2024-12-13-create-tables.xml @@ -1,6 +1,10 @@ - - + + + @@ -12,18 +16,40 @@ - + - + - + + + + + + + + + + + + + + + + + + + + + + + @@ -49,8 +75,5 @@ - - - diff --git a/src/test/java/org/tkit/onecx/parameters/domain/daos/ApplicationParameterDAOTest.java b/src/test/java/org/tkit/onecx/parameters/domain/daos/ApplicationParameterDAOTest.java deleted file mode 100644 index e12cd02..0000000 --- a/src/test/java/org/tkit/onecx/parameters/domain/daos/ApplicationParameterDAOTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.tkit.onecx.parameters.domain.daos; - -import java.util.Map; -import java.util.Set; - -import jakarta.inject.Inject; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.tkit.onecx.parameters.domain.di.v1.ParameterDataImportService; -import org.tkit.onecx.parameters.domain.models.ApplicationParameter; -import org.tkit.quarkus.test.WithDBData; - -import io.quarkus.test.junit.QuarkusTest; - -@QuarkusTest -class ApplicationParameterDAOTest { - - @Inject - ApplicationParameterDAO dao; - - @Test - @WithDBData(value = { "data/parameters-dao-testdata.xml" }, deleteBeforeInsert = true, rinseAndRepeat = true) - void findApplicationParametersByKeysTest() { - Set data = Set.of("app1__param", "app1__integer_param"); - Map result = dao.findApplicationParametersByKeys(data, - ParameterDataImportService.KEY_SEPARATOR); - Assertions.assertNotNull(result); - Assertions.assertEquals(2, result.size()); - } - - @Test - @WithDBData(value = { "data/parameters-dao-testdata.xml" }, deleteBeforeInsert = true, rinseAndRepeat = true) - void findApplicationParametersByKeysNoResultTest() { - Set data = Set.of("appx__paramx"); - Map result = dao.findApplicationParametersByKeys(data, - ParameterDataImportService.KEY_SEPARATOR); - Assertions.assertNotNull(result); - Assertions.assertEquals(0, result.size()); - } -} diff --git a/src/test/java/org/tkit/onecx/parameters/domain/daos/ApplicationParameterDAOExceptionTest.java b/src/test/java/org/tkit/onecx/parameters/domain/daos/ParameterDAOExceptionTest.java similarity index 51% rename from src/test/java/org/tkit/onecx/parameters/domain/daos/ApplicationParameterDAOExceptionTest.java rename to src/test/java/org/tkit/onecx/parameters/domain/daos/ParameterDAOExceptionTest.java index 667d38d..f1abbd5 100644 --- a/src/test/java/org/tkit/onecx/parameters/domain/daos/ApplicationParameterDAOExceptionTest.java +++ b/src/test/java/org/tkit/onecx/parameters/domain/daos/ParameterDAOExceptionTest.java @@ -13,10 +13,10 @@ import io.quarkus.test.junit.QuarkusTest; @QuarkusTest -class ApplicationParameterDAOExceptionTest { +class ParameterDAOExceptionTest { @Inject - ApplicationParameterDAO dao; + ParameterDAO dao; @InjectMock EntityManager em; @@ -26,42 +26,27 @@ void beforeAll() { Mockito.when(em.getCriteriaBuilder()).thenThrow(new RuntimeException("Test technical error exception")); } - @Test - void findApplicationParametersByKeysTest() { - var exc = Assertions.assertThrows(DAOException.class, () -> dao.findApplicationParametersByKeys(null, null)); - Assertions.assertEquals(ApplicationParameterDAO.ErrorKeys.FIND_PARAMETER_BY_APPLICATION_ID_AND_PARAMETER_KEY_FAILED, - exc.key); - } - - @Test - void findByApplicationIdAndParameterKeysTest() { - var exc = Assertions.assertThrows(DAOException.class, - () -> dao.findByApplicationIdAndParameterKeys(null, null)); - Assertions.assertEquals(ApplicationParameterDAO.ErrorKeys.FIND_PARAMETERS_BY_APPLICATION_AND_PARAMETER_KEYS_FAILED, - exc.key); - } - @Test void findAllByApplicationIdTest() { var exc = Assertions.assertThrows(DAOException.class, () -> dao.findAllByProductNameAndApplicationId(null, null)); - Assertions.assertEquals(ApplicationParameterDAO.ErrorKeys.FIND_ALL_PARAMETERS_BY_APPLICATION_ID_FAILED, exc.key); + Assertions.assertEquals(ParameterDAO.ErrorKeys.FIND_ALL_PARAMETERS_BY_APPLICATION_ID_FAILED, exc.key); } @Test void searchByCriteriaTest() { var exc = Assertions.assertThrows(DAOException.class, () -> dao.searchByCriteria(null)); - Assertions.assertEquals(ApplicationParameterDAO.ErrorKeys.FIND_ALL_PARAMETERS_FAILED, exc.key); + Assertions.assertEquals(ParameterDAO.ErrorKeys.FIND_ALL_PARAMETERS_FAILED, exc.key); } @Test void searchAllApplicationsTest() { var exc = Assertions.assertThrows(DAOException.class, () -> dao.searchAllProductNamesAndApplicationIds()); - Assertions.assertEquals(ApplicationParameterDAO.ErrorKeys.FIND_ALL_APPLICATIONS_FAILED, exc.key); + Assertions.assertEquals(ParameterDAO.ErrorKeys.FIND_ALL_APPLICATIONS_FAILED, exc.key); } @Test void searchAllKeysTest() { var exc = Assertions.assertThrows(DAOException.class, () -> dao.searchAllKeys(null)); - Assertions.assertEquals(ApplicationParameterDAO.ErrorKeys.FIND_ALL_KEYS_FAILED, exc.key); + Assertions.assertEquals(ParameterDAO.ErrorKeys.FIND_ALL_KEYS_FAILED, exc.key); } } diff --git a/src/test/java/org/tkit/onecx/parameters/domain/daos/ApplicationParameterHistoryDAOExceptionTest.java b/src/test/java/org/tkit/onecx/parameters/domain/daos/ParameterHistoryDAOExceptionTest.java similarity index 73% rename from src/test/java/org/tkit/onecx/parameters/domain/daos/ApplicationParameterHistoryDAOExceptionTest.java rename to src/test/java/org/tkit/onecx/parameters/domain/daos/ParameterHistoryDAOExceptionTest.java index fb39c90..1c9d3af 100644 --- a/src/test/java/org/tkit/onecx/parameters/domain/daos/ApplicationParameterHistoryDAOExceptionTest.java +++ b/src/test/java/org/tkit/onecx/parameters/domain/daos/ParameterHistoryDAOExceptionTest.java @@ -13,10 +13,10 @@ import io.quarkus.test.junit.QuarkusTest; @QuarkusTest -class ApplicationParameterHistoryDAOExceptionTest { +class ParameterHistoryDAOExceptionTest { @Inject - ApplicationParameterHistoryDAO dao; + ParameterHistoryDAO dao; @InjectMock EntityManager em; @@ -29,21 +29,21 @@ void beforeAll() { @Test void searchByCriteriaTest() { var exc = Assertions.assertThrows(DAOException.class, () -> dao.searchByCriteria(null)); - Assertions.assertEquals(ApplicationParameterHistoryDAO.ErrorKeys.FIND_ALL_PARAMETERS_HISTORY_FAILED, + Assertions.assertEquals(ParameterHistoryDAO.ErrorKeys.FIND_ALL_PARAMETERS_HISTORY_FAILED, exc.key); } @Test void searchOnlyLatestByCriteriaTest() { var exc = Assertions.assertThrows(DAOException.class, () -> dao.searchOnlyLatestByCriteria(null)); - Assertions.assertEquals(ApplicationParameterHistoryDAO.ErrorKeys.FIND_ALL_PARAMETERS_HISTORY_FAILED, + Assertions.assertEquals(ParameterHistoryDAO.ErrorKeys.FIND_ALL_PARAMETERS_HISTORY_FAILED, exc.key); } @Test void searchCountsByCriteriaTest() { var exc = Assertions.assertThrows(DAOException.class, () -> dao.searchCountsByCriteria(null)); - Assertions.assertEquals(ApplicationParameterHistoryDAO.ErrorKeys.FIND_ALL_PARAMETERS_HISTORY_FAILED, + Assertions.assertEquals(ParameterHistoryDAO.ErrorKeys.FIND_ALL_PARAMETERS_HISTORY_FAILED, exc.key); } } diff --git a/src/test/java/org/tkit/onecx/parameters/domain/di/v1/ParameterDataImportServiceTest.java b/src/test/java/org/tkit/onecx/parameters/domain/di/v1/ParameterDataImportServiceTest.java deleted file mode 100644 index 1c786cf..0000000 --- a/src/test/java/org/tkit/onecx/parameters/domain/di/v1/ParameterDataImportServiceTest.java +++ /dev/null @@ -1,244 +0,0 @@ -package org.tkit.onecx.parameters.domain.di.v1; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import jakarta.inject.Inject; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.tkit.onecx.parameters.domain.daos.ApplicationParameterDAO; -import org.tkit.onecx.parameters.domain.models.ApplicationParameter; -import org.tkit.onecx.parameters.test.AbstractTest; -import org.tkit.quarkus.dataimport.DataImportConfig; -import org.tkit.quarkus.test.WithDBData; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import gen.org.tkit.onecx.parameters.di.v1.model.DataImportAppDTOV1; -import gen.org.tkit.onecx.parameters.di.v1.model.DataImportDTOV1; -import gen.org.tkit.onecx.parameters.di.v1.model.DataImportParamDTOV1; -import io.quarkus.test.junit.QuarkusTest; - -@QuarkusTest -@WithDBData(value = { "data/parameters-testdata.xml" }, deleteBeforeInsert = true, rinseAndRepeat = true) -class ParameterDataImportServiceTest extends AbstractTest { - - @Inject - ParameterDataImportService service; - - @Inject - ApplicationParameterDAO dao; - - @Inject - ObjectMapper mapper; - - @Test - void importNoneTest() { - Map metadata = new HashMap<>(); - metadata.put("operation", "CUSTOM_NOT_SUPPORTED"); - DataImportConfig config = new DataImportConfig() { - @Override - public Map getMetadata() { - return metadata; - } - }; - service.importData(config); - - List params = dao.findAll().toList(); - Assertions.assertNotNull(params); - Assertions.assertEquals(9, params.size()); - - config.getMetadata().put("operation", "NONE"); - - params = dao.findAll().toList(); - Assertions.assertNotNull(params); - Assertions.assertEquals(9, params.size()); - } - - @Test - void importCleanInsertTest() { - - DataImportParamDTOV1 k1 = new DataImportParamDTOV1(); - k1.setDescription("desc"); - k1.setName("name-of-name"); - - DataImportAppDTOV1 a1 = new DataImportAppDTOV1(); - a1.put("key1", k1); - - DataImportDTOV1 data = new DataImportDTOV1(); - data.put("app1", a1); - data.put("empty", new DataImportAppDTOV1()); - data.put("null", null); - - service.importData(new DataImportConfig() { - @Override - public Map getMetadata() { - return Map.of("operation", "CLEAN_INSERT"); - } - - @Override - public byte[] getData() { - try { - return mapper.writeValueAsBytes(data); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - }); - - List params = dao.findAll().toList(); - Assertions.assertNotNull(params); - Assertions.assertEquals(1, params.size()); - - } - - @Test - void importUpdateTest() { - - DataImportParamDTOV1 param = new DataImportParamDTOV1(); - param.setDescription("desc"); - param.setName("name-of-name"); - param.setValue("123"); - - DataImportParamDTOV1 emptyValueParam = new DataImportParamDTOV1(); - emptyValueParam.setDescription(""); - emptyValueParam.setName(""); - emptyValueParam.setValue(""); - - DataImportAppDTOV1 appNew = new DataImportAppDTOV1(); - appNew.put("key_new", param); - - DataImportAppDTOV1 app1 = new DataImportAppDTOV1(); - app1.put("param", param); - app1.put("integer_param", new DataImportParamDTOV1()); - app1.put("boolean_param", emptyValueParam); - - DataImportDTOV1 data = new DataImportDTOV1(); - data.put("app1", app1); - data.put("app_new", appNew); - data.put("empty", new DataImportAppDTOV1()); - data.put("null", null); - - service.importData(new DataImportConfig() { - @Override - public Map getMetadata() { - return Map.of("operation", "UPDATE"); - } - - @Override - public byte[] getData() { - try { - return mapper - .writeValueAsBytes(data); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - }); - - List params = dao.findAll().toList(); - Assertions.assertNotNull(params); - Assertions.assertEquals(10, params.size()); - List p1 = dao.findByApplicationIdAndParameterKeys("app1", List.of("param")); - Assertions.assertNotNull(p1); - Assertions.assertEquals(1, p1.size()); - Assertions.assertEquals(param.getName(), p1.get(0).getName()); - Assertions.assertEquals(param.getValue(), p1.get(0).getImportValue()); - - List p2 = dao.findByApplicationIdAndParameterKeys("app_new", List.of("key_new")); - Assertions.assertNotNull(p2); - Assertions.assertEquals(1, p2.size()); - Assertions.assertEquals(param.getName(), p2.get(0).getName()); - Assertions.assertEquals(param.getValue(), p2.get(0).getImportValue()); - } - - @Test - void importUpdateNoDataToUpdateTest() { - - DataImportDTOV1 data = new DataImportDTOV1(); - data.put("empty", new DataImportAppDTOV1()); - data.put("null", null); - - service.importData(new DataImportConfig() { - @Override - public Map getMetadata() { - return Map.of("operation", "UPDATE"); - } - - @Override - public byte[] getData() { - try { - return mapper - .writeValueAsBytes(data); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - }); - - List params = dao.findAll().toList(); - Assertions.assertNotNull(params); - Assertions.assertEquals(9, params.size()); - List p1 = dao.findByApplicationIdAndParameterKeys("app1", List.of("param")); - Assertions.assertNotNull(p1); - Assertions.assertEquals(1, p1.size()); - - } - - @Test - void importEmptyDataTest() { - Assertions.assertDoesNotThrow(() -> { - service.importData(new DataImportConfig() { - @Override - public Map getMetadata() { - return Map.of("operation", "UPDATE"); - } - }); - - service.importData(new DataImportConfig() { - @Override - public Map getMetadata() { - return Map.of("operation", "UPDATE"); - } - - @Override - public byte[] getData() { - return new byte[] {}; - } - }); - - service.importData(new DataImportConfig() { - @Override - public Map getMetadata() { - return Map.of("operation", "UPDATE"); - } - - @Override - public byte[] getData() { - try { - return mapper.writeValueAsBytes(Map.of()); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - }); - - }); - - var config = new DataImportConfig() { - @Override - public Map getMetadata() { - return Map.of("operation", "UPDATE"); - } - - @Override - public byte[] getData() { - return new byte[] { 0 }; - } - }; - Assertions.assertThrows(RuntimeException.class, () -> service.importData(config)); - - } -} diff --git a/src/test/java/org/tkit/onecx/parameters/domain/timer/MaintenanceHistoryServiceExceptionTest.java b/src/test/java/org/tkit/onecx/parameters/domain/timer/MaintenanceHistoryServiceExceptionTest.java index 9b023d5..1ab73e8 100644 --- a/src/test/java/org/tkit/onecx/parameters/domain/timer/MaintenanceHistoryServiceExceptionTest.java +++ b/src/test/java/org/tkit/onecx/parameters/domain/timer/MaintenanceHistoryServiceExceptionTest.java @@ -9,8 +9,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import org.tkit.onecx.parameters.domain.daos.ApplicationParameterHistoryDAO; import org.tkit.onecx.parameters.domain.daos.JobDAO; +import org.tkit.onecx.parameters.domain.daos.ParameterHistoryDAO; import org.tkit.onecx.parameters.domain.models.Job; import org.tkit.quarkus.jpa.exceptions.DAOException; @@ -42,7 +42,7 @@ void testDaoException() { service.maintenanceHistoryData(); }); var de = Assertions.assertInstanceOf(DAOException.class, exc); - Assertions.assertEquals(ApplicationParameterHistoryDAO.ErrorKeys.DELETE_PARAMETER_HISTORY_OLDER_THAN_FAILED, de.key); + Assertions.assertEquals(ParameterHistoryDAO.ErrorKeys.DELETE_PARAMETER_HISTORY_OLDER_THAN_FAILED, de.key); } } diff --git a/src/test/java/org/tkit/onecx/parameters/domain/timer/MaintenanceHistoryServiceTest.java b/src/test/java/org/tkit/onecx/parameters/domain/timer/MaintenanceHistoryServiceTest.java index f0fc29f..3ae5c63 100644 --- a/src/test/java/org/tkit/onecx/parameters/domain/timer/MaintenanceHistoryServiceTest.java +++ b/src/test/java/org/tkit/onecx/parameters/domain/timer/MaintenanceHistoryServiceTest.java @@ -7,9 +7,9 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; -import org.tkit.onecx.parameters.domain.daos.ApplicationParameterHistoryDAO; import org.tkit.onecx.parameters.domain.daos.JobDAO; -import org.tkit.onecx.parameters.domain.models.ApplicationParameterHistory; +import org.tkit.onecx.parameters.domain.daos.ParameterHistoryDAO; +import org.tkit.onecx.parameters.domain.models.ParameterHistory; import org.tkit.quarkus.test.WithDBData; import io.quarkus.test.junit.QuarkusTest; @@ -22,7 +22,7 @@ class MaintenanceHistoryServiceTest { MaintenanceHistoryService service; @Inject - ApplicationParameterHistoryDAO dao; + ParameterHistoryDAO dao; @Inject JobDAO jobDAO; @@ -31,7 +31,7 @@ class MaintenanceHistoryServiceTest { @Order(1) void maintenanceHistoryDataTest() { service.maintenanceHistoryData(); - List result = dao.findAll().toList(); + List result = dao.findAll().toList(); Assertions.assertNotNull(result); Assertions.assertEquals(2, result.size()); } diff --git a/src/test/java/org/tkit/onecx/parameters/rs/external/v1/ParameterRestControllerV1Test.java b/src/test/java/org/tkit/onecx/parameters/rs/external/v1/ParameterRestControllerV1Test.java index c2406dd..74fda93 100644 --- a/src/test/java/org/tkit/onecx/parameters/rs/external/v1/ParameterRestControllerV1Test.java +++ b/src/test/java/org/tkit/onecx/parameters/rs/external/v1/ParameterRestControllerV1Test.java @@ -53,7 +53,7 @@ void shouldNotFindParametersWithGivenApplicationId() { .withContentType(MediaType.APPLICATION_JSON) .withBody(JsonBody.json(new TenantId().tenantId("tenant-100"))))); - Map applicationParameters = given() + given() .auth().oauth2(getKeycloakClientToken("testClient")) .header(HEADER_APM_TOKEN, apm) .when() @@ -61,11 +61,7 @@ void shouldNotFindParametersWithGivenApplicationId() { .pathParam("appId", "not-exist") .get("parameters") .then() - .statusCode(Response.Status.OK.getStatusCode()) - .contentType(APPLICATION_JSON) - .extract() - .body().jsonPath().getMap(".", String.class, String.class); - Assertions.assertTrue(applicationParameters.isEmpty()); + .statusCode(Response.Status.NOT_FOUND.getStatusCode()); } @Test @@ -79,7 +75,7 @@ void shouldReturnImportValueParameter() { .withContentType(MediaType.APPLICATION_JSON) .withBody(JsonBody.json(new TenantId().tenantId("tenant-100"))))); - Map applicationParameters = given() + Map applicationParameters = given() .auth().oauth2(getKeycloakClientToken("testClient")) .header(HEADER_APM_TOKEN, apm) .when() @@ -87,12 +83,12 @@ void shouldReturnImportValueParameter() { .pathParam("productName", "import-product") .pathParam("appId", "import-app") .get("parameters") - .then() + .then().log().all() .statusCode(Response.Status.OK.getStatusCode()) .contentType(APPLICATION_JSON) .extract() - .body().jsonPath().getMap(".", String.class, String.class); - Assertions.assertEquals(1, applicationParameters.size()); + .body().jsonPath().getMap("."); + Assertions.assertEquals(2, applicationParameters.size()); Assertions.assertEquals("import-value", applicationParameters.get("importParam")); } @@ -107,7 +103,7 @@ void shouldReturnImportValueParameterOrg2() { .withContentType(MediaType.APPLICATION_JSON) .withBody(JsonBody.json(new TenantId().tenantId("tenant-200"))))); - Map applicationParameters = given() + Map applicationParameters = given() .auth().oauth2(getKeycloakClientToken("testClient")) .when() .header("apm-principal-token", apm) @@ -119,7 +115,7 @@ void shouldReturnImportValueParameterOrg2() { .statusCode(Response.Status.OK.getStatusCode()) .contentType(APPLICATION_JSON) .extract() - .body().jsonPath().getMap(".", String.class, String.class); + .body().jsonPath().getMap("."); Assertions.assertEquals(1, applicationParameters.size()); Assertions.assertEquals("import-value-200", applicationParameters.get("importParam")); } @@ -134,7 +130,7 @@ void shouldReturnParameter() { .withContentType(MediaType.APPLICATION_JSON) .withBody(JsonBody.json(new TenantId().tenantId("tenant-100"))))); - Map applicationParameters = given() + Map applicationParameters = given() .auth().oauth2(getKeycloakClientToken("testClient")) .header(HEADER_APM_TOKEN, apm) .when() @@ -145,7 +141,7 @@ void shouldReturnParameter() { .statusCode(Response.Status.OK.getStatusCode()) .contentType(APPLICATION_JSON) .extract() - .body().jsonPath().getMap(".", String.class, String.class); + .body().jsonPath().getMap("."); Assertions.assertEquals(1, applicationParameters.size()); Assertions.assertEquals("KOGITO", applicationParameters.get("ENGINE")); } @@ -203,7 +199,7 @@ void shouldCreateNewParameter() { .post("history") .then() .statusCode(Response.Status.NO_CONTENT.getStatusCode()); - Map applicationParameters = given() + given() .auth().oauth2(getKeycloakClientToken("testClient")) .header(HEADER_APM_TOKEN, apm) .when() @@ -211,11 +207,7 @@ void shouldCreateNewParameter() { .pathParam("appId", "new-application") .get("parameters") .then() - .statusCode(Response.Status.OK.getStatusCode()) - .contentType(APPLICATION_JSON) - .extract() - .body().jsonPath().getMap(".", String.class, String.class); - Assertions.assertEquals(0, applicationParameters.size()); + .statusCode(Response.Status.NOT_FOUND.getStatusCode()); } @Test diff --git a/src/test/java/org/tkit/onecx/parameters/rs/internal/ApplicationParameterRestControllerTestIT.java b/src/test/java/org/tkit/onecx/parameters/rs/internal/ParameterHistoryRestControllerIT.java similarity index 55% rename from src/test/java/org/tkit/onecx/parameters/rs/internal/ApplicationParameterRestControllerTestIT.java rename to src/test/java/org/tkit/onecx/parameters/rs/internal/ParameterHistoryRestControllerIT.java index 39aa342..7008613 100644 --- a/src/test/java/org/tkit/onecx/parameters/rs/internal/ApplicationParameterRestControllerTestIT.java +++ b/src/test/java/org/tkit/onecx/parameters/rs/internal/ParameterHistoryRestControllerIT.java @@ -3,5 +3,5 @@ import io.quarkus.test.junit.QuarkusIntegrationTest; @QuarkusIntegrationTest -public class ApplicationParameterRestControllerTestIT extends ApplicationParameterRestControllerTest { +class ParameterHistoryRestControllerIT extends ParameterHistoryRestControllerTest { } diff --git a/src/test/java/org/tkit/onecx/parameters/rs/internal/ApplicationParameterHistoryRestControllerTest.java b/src/test/java/org/tkit/onecx/parameters/rs/internal/ParameterHistoryRestControllerTest.java similarity index 75% rename from src/test/java/org/tkit/onecx/parameters/rs/internal/ApplicationParameterHistoryRestControllerTest.java rename to src/test/java/org/tkit/onecx/parameters/rs/internal/ParameterHistoryRestControllerTest.java index 18c40ec..6c3bfec 100644 --- a/src/test/java/org/tkit/onecx/parameters/rs/internal/ApplicationParameterHistoryRestControllerTest.java +++ b/src/test/java/org/tkit/onecx/parameters/rs/internal/ParameterHistoryRestControllerTest.java @@ -21,25 +21,25 @@ import org.mockserver.client.MockServerClient; import org.mockserver.model.JsonBody; import org.mockserver.model.MediaType; -import org.tkit.onecx.parameters.rs.internal.controllers.ApplicationParameterHistoryRestController; +import org.tkit.onecx.parameters.rs.internal.controllers.HistoryRestController; import org.tkit.onecx.parameters.test.AbstractTest; import org.tkit.quarkus.security.test.GenerateKeycloakClient; import org.tkit.quarkus.test.WithDBData; -import gen.org.tkit.onecx.parameters.rs.internal.model.ApplicationParameterHistoryCriteriaDTO; -import gen.org.tkit.onecx.parameters.rs.internal.model.ApplicationParameterHistoryDTO; -import gen.org.tkit.onecx.parameters.rs.internal.model.ApplicationParameterHistoryPageResultDTO; import gen.org.tkit.onecx.parameters.rs.internal.model.ParameterHistoryCountCriteriaDTO; +import gen.org.tkit.onecx.parameters.rs.internal.model.ParameterHistoryCriteriaDTO; +import gen.org.tkit.onecx.parameters.rs.internal.model.ParameterHistoryDTO; +import gen.org.tkit.onecx.parameters.rs.internal.model.ParameterHistoryPageResultDTO; import gen.org.tkit.onecx.tenant.client.model.TenantId; import io.quarkiverse.mockserver.test.InjectMockServerClient; import io.quarkus.test.common.http.TestHTTPEndpoint; import io.quarkus.test.junit.QuarkusTest; @QuarkusTest -@TestHTTPEndpoint(ApplicationParameterHistoryRestController.class) +@TestHTTPEndpoint(HistoryRestController.class) @WithDBData(value = { "data/parameters-testdata.xml" }, deleteBeforeInsert = true, rinseAndRepeat = true) @GenerateKeycloakClient(clientName = "testClient", scopes = { "ocx-pa:read", "ocx-pa:write", "ocx-pa:delete", "ocx-pa:all" }) -class ApplicationParameterHistoryRestControllerTest extends AbstractTest { +class ParameterHistoryRestControllerTest extends AbstractTest { @InjectMockServerClient MockServerClient mockServerClient; @@ -61,13 +61,13 @@ void shouldFindAllParametersHistoryWithoutCriteria() { var pageResultDTO = given() .auth().oauth2(getKeycloakClientToken("testClient")) .header(HEADER_APM_TOKEN, apm) - .body(new ApplicationParameterHistoryCriteriaDTO()) + .body(new ParameterHistoryCriteriaDTO()) .contentType(APPLICATION_JSON) .post() .then() .statusCode(Response.Status.OK.getStatusCode()) .contentType(APPLICATION_JSON) - .extract().body().as(ApplicationParameterHistoryPageResultDTO.class); + .extract().body().as(ParameterHistoryPageResultDTO.class); Assertions.assertEquals(6, pageResultDTO.getStream().size()); Assertions.assertEquals(Long.valueOf(6), pageResultDTO.getTotalElements()); @@ -76,21 +76,21 @@ void shouldFindAllParametersHistoryWithoutCriteria() { static Stream findByCriteriaTestData() { return Stream.of( - Arguments.of(new ApplicationParameterHistoryCriteriaDTO(), 6), - Arguments.of(new ApplicationParameterHistoryCriteriaDTO().applicationId("").productName("").key("") + Arguments.of(new ParameterHistoryCriteriaDTO(), 6), + Arguments.of(new ParameterHistoryCriteriaDTO().applicationId("").productName("").key("") .type(List.of("")), 0), - Arguments.of(new ApplicationParameterHistoryCriteriaDTO().applicationId("app0").productName("p0").key("key0") + Arguments.of(new ParameterHistoryCriteriaDTO().applicationId("app0").productName("p0").key("key0") .type(List.of("type0")), 0), - Arguments.of(new ApplicationParameterHistoryCriteriaDTO().applicationId("access-mgmt") + Arguments.of(new ParameterHistoryCriteriaDTO().applicationId("access-mgmt") .productName("access-mgmt-product"), 2), - Arguments.of(new ApplicationParameterHistoryCriteriaDTO().applicationId("app0").productName("p0"), 0), - Arguments.of(new ApplicationParameterHistoryCriteriaDTO().applicationId("app1").productName("p1"), 1), - Arguments.of(new ApplicationParameterHistoryCriteriaDTO().applicationId("app2").productName("p2"), 3)); + Arguments.of(new ParameterHistoryCriteriaDTO().applicationId("app0").productName("p0"), 0), + Arguments.of(new ParameterHistoryCriteriaDTO().applicationId("app1").productName("p1"), 1), + Arguments.of(new ParameterHistoryCriteriaDTO().applicationId("app2").productName("p2"), 3)); } @ParameterizedTest @MethodSource("findByCriteriaTestData") - void shouldFindParametersHistoryByCriteria(ApplicationParameterHistoryCriteriaDTO criteriaDTO, Integer expectedArraySize) { + void shouldFindParametersHistoryByCriteria(ParameterHistoryCriteriaDTO criteriaDTO, Integer expectedArraySize) { var apm = createToken("org1"); addExpectation(mockServerClient @@ -110,26 +110,26 @@ void shouldFindParametersHistoryByCriteria(ApplicationParameterHistoryCriteriaDT .statusCode(Response.Status.OK.getStatusCode()) .contentType(APPLICATION_JSON) .extract() - .body().as(ApplicationParameterHistoryPageResultDTO.class); + .body().as(ParameterHistoryPageResultDTO.class); Assertions.assertEquals(expectedArraySize, pageResultDTO.getStream().size()); } static Stream findByCriteriaTestDataQueryLatest() { return Stream.of( - Arguments.of(new ApplicationParameterHistoryCriteriaDTO(), 0), - Arguments.of(new ApplicationParameterHistoryCriteriaDTO().applicationId("access-mgmt") + Arguments.of(new ParameterHistoryCriteriaDTO(), 0), + Arguments.of(new ParameterHistoryCriteriaDTO().applicationId("access-mgmt") .productName("access-mgmt-product"), 0), - Arguments.of(new ApplicationParameterHistoryCriteriaDTO().applicationId("").productName("").key(""), 0), - Arguments.of(new ApplicationParameterHistoryCriteriaDTO().applicationId("").productName("").key("key1"), 0), - Arguments.of(new ApplicationParameterHistoryCriteriaDTO().applicationId("").productName(""), 0), - Arguments.of(new ApplicationParameterHistoryCriteriaDTO().applicationId("app0").productName("p0"), 0), - Arguments.of(new ApplicationParameterHistoryCriteriaDTO().applicationId("app1").productName("p1"), 0), - Arguments.of(new ApplicationParameterHistoryCriteriaDTO().applicationId("app2").productName("p2"), 0)); + Arguments.of(new ParameterHistoryCriteriaDTO().applicationId("").productName("").key(""), 0), + Arguments.of(new ParameterHistoryCriteriaDTO().applicationId("").productName("").key("key1"), 0), + Arguments.of(new ParameterHistoryCriteriaDTO().applicationId("").productName(""), 0), + Arguments.of(new ParameterHistoryCriteriaDTO().applicationId("app0").productName("p0"), 0), + Arguments.of(new ParameterHistoryCriteriaDTO().applicationId("app1").productName("p1"), 0), + Arguments.of(new ParameterHistoryCriteriaDTO().applicationId("app2").productName("p2"), 0)); } @ParameterizedTest @MethodSource("findByCriteriaTestDataQueryLatest") - void shouldFindParametersHistoryByCriteriaQueryLatest(ApplicationParameterHistoryCriteriaDTO criteriaDTO, + void shouldFindParametersHistoryByCriteriaQueryLatest(ParameterHistoryCriteriaDTO criteriaDTO, Integer expectedArraySize) { var apm = createToken("org1"); @@ -150,12 +150,12 @@ void shouldFindParametersHistoryByCriteriaQueryLatest(ApplicationParameterHistor .statusCode(Response.Status.OK.getStatusCode()) .contentType(APPLICATION_JSON) .extract() - .body().as(ApplicationParameterHistoryPageResultDTO.class); + .body().as(ParameterHistoryPageResultDTO.class); Assertions.assertEquals(expectedArraySize, pageResultDTO.getStream().size()); } @Test - void getApplicationParametersHistoryByIdNoFoundTest() { + void getParametersHistoryByIdNoFoundTest() { var apm = createToken("org1"); addExpectation(mockServerClient .when(request().withPath("/v1/tenant").withMethod(HttpMethod.GET).withHeader("apm-principal-token", apm)) @@ -173,7 +173,7 @@ void getApplicationParametersHistoryByIdNoFoundTest() { .statusCode(Response.Status.NOT_FOUND.getStatusCode()); } - static Stream getApplicationParametersHistoryByIds() { + static Stream getParametersHistoryByIds() { return Stream.of( Arguments.of("1", "access-mgmt", "access-mgmt-product"), Arguments.of("2", "access-mgmt", "access-mgmt-product"), @@ -182,8 +182,8 @@ static Stream getApplicationParametersHistoryByIds() { } @ParameterizedTest - @MethodSource("getApplicationParametersHistoryByIds") - void getApplicationParametersHistoryById(String id, String applicationId, String productName) { + @MethodSource("getParametersHistoryByIds") + void getParametersHistoryById(String id, String applicationId, String productName) { var apm = createToken("org1"); addExpectation(mockServerClient .when(request().withPath("/v1/tenant").withMethod(HttpMethod.GET).withHeader("apm-principal-token", apm)) @@ -201,7 +201,7 @@ void getApplicationParametersHistoryById(String id, String applicationId, String .statusCode(Response.Status.OK.getStatusCode()) .contentType(APPLICATION_JSON) .extract() - .body().as(ApplicationParameterHistoryDTO.class); + .body().as(ParameterHistoryDTO.class); Assertions.assertNotNull(result); Assertions.assertEquals(id, result.getId()); Assertions.assertEquals(applicationId, result.getApplicationId()); diff --git a/src/test/java/org/tkit/onecx/parameters/rs/internal/ApplicationParameterRestControllerTest.java b/src/test/java/org/tkit/onecx/parameters/rs/internal/ParameterRestControllerTest.java similarity index 92% rename from src/test/java/org/tkit/onecx/parameters/rs/internal/ApplicationParameterRestControllerTest.java rename to src/test/java/org/tkit/onecx/parameters/rs/internal/ParameterRestControllerTest.java index 15ffa42..ad93169 100644 --- a/src/test/java/org/tkit/onecx/parameters/rs/internal/ApplicationParameterRestControllerTest.java +++ b/src/test/java/org/tkit/onecx/parameters/rs/internal/ParameterRestControllerTest.java @@ -22,7 +22,7 @@ import org.mockserver.client.MockServerClient; import org.mockserver.model.JsonBody; import org.mockserver.model.MediaType; -import org.tkit.onecx.parameters.rs.internal.controllers.ApplicationParameterRestController; +import org.tkit.onecx.parameters.rs.internal.controllers.ParameterRestController; import org.tkit.onecx.parameters.test.AbstractTest; import org.tkit.quarkus.security.test.GenerateKeycloakClient; import org.tkit.quarkus.test.WithDBData; @@ -34,9 +34,9 @@ import io.quarkus.test.junit.QuarkusTest; @QuarkusTest -@TestHTTPEndpoint(ApplicationParameterRestController.class) +@TestHTTPEndpoint(ParameterRestController.class) @GenerateKeycloakClient(clientName = "testClient", scopes = { "ocx-pa:read", "ocx-pa:write", "ocx-pa:delete", "ocx-pa:all" }) -class ApplicationParameterRestControllerTest extends AbstractTest { +class ParameterRestControllerTest extends AbstractTest { static final String PATH_PARAM_ID = "id"; static final String PATH_PARAM_ID_PATH = "{" + PATH_PARAM_ID + "}"; @@ -59,7 +59,7 @@ void shouldFindAllParametersWithoutCriteria() { .withContentType(MediaType.APPLICATION_JSON) .withBody(JsonBody.json(new TenantId().tenantId("tenant-100"))))); - ApplicationParameterPageResultDTO pageResultDTO = given() + ParameterPageResultDTO pageResultDTO = given() .auth().oauth2(getKeycloakClientToken("testClient")) .header(HEADER_APM_TOKEN, apm) .body(new ParameterSearchCriteriaDTO()) @@ -67,7 +67,7 @@ void shouldFindAllParametersWithoutCriteria() { .post("/search") .then() .statusCode(Response.Status.OK.getStatusCode()) - .extract().body().as(ApplicationParameterPageResultDTO.class); + .extract().body().as(ParameterPageResultDTO.class); Assertions.assertEquals(9, pageResultDTO.getStream().size()); Assertions.assertEquals(Long.valueOf(9), pageResultDTO.getTotalElements()); @@ -154,7 +154,7 @@ void shouldFindParametersByCriteria(ParameterSearchCriteriaDTO criteriaDTO, Inte .withContentType(MediaType.APPLICATION_JSON) .withBody(JsonBody.json(new TenantId().tenantId("tenant-100"))))); - ApplicationParameterPageResultDTO pageResultDTO = given() + ParameterPageResultDTO pageResultDTO = given() .auth().oauth2(getKeycloakClientToken("testClient")) .header(HEADER_APM_TOKEN, apm) .when() @@ -165,7 +165,7 @@ void shouldFindParametersByCriteria(ParameterSearchCriteriaDTO criteriaDTO, Inte .statusCode(Response.Status.OK.getStatusCode()) .contentType(APPLICATION_JSON) .extract() - .body().as(ApplicationParameterPageResultDTO.class); + .body().as(ParameterPageResultDTO.class); Assertions.assertEquals(expectedArraySize, pageResultDTO.getStream().size()); } @@ -179,7 +179,7 @@ void shouldFindParameterById() { .withContentType(MediaType.APPLICATION_JSON) .withBody(JsonBody.json(new TenantId().tenantId("tenant-100"))))); - ApplicationParameterDTO applicationParameterDTO = given() + ParameterDTO applicationParameterDTO = given() .auth().oauth2(getKeycloakClientToken("testClient")) .header(HEADER_APM_TOKEN, apm) .when() @@ -189,12 +189,12 @@ void shouldFindParameterById() { .statusCode(Response.Status.OK.getStatusCode()) .contentType(APPLICATION_JSON) .extract() - .body().as(ApplicationParameterDTO.class); + .body().as(ParameterDTO.class); Assertions.assertNotNull(applicationParameterDTO); Assertions.assertEquals("access-mgmt", applicationParameterDTO.getApplicationId()); Assertions.assertEquals("access-mgmt-product", applicationParameterDTO.getProductName()); Assertions.assertEquals("ENGINE", applicationParameterDTO.getKey()); - Assertions.assertEquals("KOGITO", applicationParameterDTO.getSetValue()); + Assertions.assertEquals("KOGITO", applicationParameterDTO.getValue()); Assertions.assertEquals("Engine", applicationParameterDTO.getName()); Assertions.assertNull(applicationParameterDTO.getDescription()); } @@ -227,7 +227,7 @@ void shouldNotFindUpdateParameterById() { .withContentType(MediaType.APPLICATION_JSON) .withBody(JsonBody.json(new TenantId().tenantId("tenant-100"))))); - ApplicationParameterUpdateDTO applicationParameterUpdateDTO = new ApplicationParameterUpdateDTO(); + ParameterUpdateDTO applicationParameterUpdateDTO = new ParameterUpdateDTO(); applicationParameterUpdateDTO.setValue("JBPM"); applicationParameterUpdateDTO.setDescription("Test description"); @@ -262,12 +262,9 @@ void shouldUpdateParameterTest(String appId, String desc, String id, String valu .withContentType(MediaType.APPLICATION_JSON) .withBody(JsonBody.json(new TenantId().tenantId("tenant-100"))))); - var request = new ApplicationParameterUpdateDTO(); + var request = new ParameterUpdateDTO(); request.setValue(value); request.setDescription(desc); - request.setUnit(unit); - request.setRangeTo(to); - request.setRangeFrom(from); given() .auth().oauth2(getKeycloakClientToken("testClient")) @@ -289,14 +286,11 @@ void shouldUpdateParameterTest(String appId, String desc, String id, String valu .then() .statusCode(Response.Status.OK.getStatusCode()) .extract() - .body().as(ApplicationParameterDTO.class); + .body().as(ParameterDTO.class); Assertions.assertNotNull(dto); Assertions.assertEquals(appId, dto.getApplicationId()); - Assertions.assertEquals(value, dto.getSetValue()); + Assertions.assertEquals(value, dto.getValue()); Assertions.assertEquals(desc, dto.getDescription()); - Assertions.assertEquals(checkUnit, dto.getUnit()); - Assertions.assertEquals(from, dto.getRangeFrom()); - Assertions.assertEquals(to, dto.getRangeTo()); } @Test @@ -341,15 +335,12 @@ void createParameterTest(String appId, String productName, String desc, String k .withContentType(MediaType.APPLICATION_JSON) .withBody(JsonBody.json(new TenantId().tenantId("tenant-100"))))); - ApplicationParameterCreateDTO dto = new ApplicationParameterCreateDTO(); + ParameterCreateDTO dto = new ParameterCreateDTO(); dto.setApplicationId(appId); dto.setProductName(productName); dto.setDescription(desc); dto.setKey(key); dto.setValue(value); - dto.setUnit(unit); - dto.setRangeFrom(from); - dto.setRangeTo(to); String uri = given() .auth().oauth2(getKeycloakClientToken("testClient")) @@ -361,7 +352,7 @@ void createParameterTest(String appId, String productName, String desc, String k .statusCode(Response.Status.CREATED.getStatusCode()) .extract().header(HttpHeaders.LOCATION); - ApplicationParameterDTO dto2 = given() + ParameterDTO dto2 = given() .auth().oauth2(getKeycloakClientToken("testClient")) .header(HEADER_APM_TOKEN, apm) .contentType(APPLICATION_JSON) @@ -369,17 +360,14 @@ void createParameterTest(String appId, String productName, String desc, String k .then() .statusCode(Response.Status.OK.getStatusCode()) .extract() - .body().as(ApplicationParameterDTO.class); + .body().as(ParameterDTO.class); Assertions.assertNotNull(dto2); Assertions.assertEquals(dto.getApplicationId(), dto2.getApplicationId()); Assertions.assertEquals(dto.getProductName(), dto2.getProductName()); Assertions.assertEquals(dto.getDescription(), dto2.getDescription()); Assertions.assertEquals(dto.getKey(), dto2.getKey()); - Assertions.assertEquals(dto.getValue(), dto2.getSetValue()); - Assertions.assertEquals(checkUnit, dto2.getUnit()); - Assertions.assertEquals(dto.getRangeFrom(), dto2.getRangeFrom()); - Assertions.assertEquals(dto.getRangeTo(), dto2.getRangeTo()); + Assertions.assertEquals(dto.getValue(), dto2.getValue()); } @@ -392,7 +380,7 @@ void createTwice_Bad_Request_Test() { .withContentType(MediaType.APPLICATION_JSON) .withBody(JsonBody.json(new TenantId().tenantId("tenant-100"))))); - ApplicationParameterCreateDTO dto = new ApplicationParameterCreateDTO(); + ParameterCreateDTO dto = new ParameterCreateDTO(); dto.setApplicationId("app1"); dto.setProductName("productName1"); dto.setKey("key1"); diff --git a/src/test/java/org/tkit/onecx/parameters/rs/internal/ApplicationParameterHistoryRestControllerIT.java b/src/test/java/org/tkit/onecx/parameters/rs/internal/ParameterRestControllerTestIT.java similarity index 54% rename from src/test/java/org/tkit/onecx/parameters/rs/internal/ApplicationParameterHistoryRestControllerIT.java rename to src/test/java/org/tkit/onecx/parameters/rs/internal/ParameterRestControllerTestIT.java index ce01501..f83818e 100644 --- a/src/test/java/org/tkit/onecx/parameters/rs/internal/ApplicationParameterHistoryRestControllerIT.java +++ b/src/test/java/org/tkit/onecx/parameters/rs/internal/ParameterRestControllerTestIT.java @@ -3,5 +3,5 @@ import io.quarkus.test.junit.QuarkusIntegrationTest; @QuarkusIntegrationTest -class ApplicationParameterHistoryRestControllerIT extends ApplicationParameterHistoryRestControllerTest { +public class ParameterRestControllerTestIT extends ParameterRestControllerTest { } diff --git a/src/test/resources/data/parameters-dao-testdata.xml b/src/test/resources/data/parameters-dao-testdata.xml index b1e43cb..3b4e1f3 100644 --- a/src/test/resources/data/parameters-dao-testdata.xml +++ b/src/test/resources/data/parameters-dao-testdata.xml @@ -1,6 +1,6 @@ - - - + + + \ No newline at end of file diff --git a/src/test/resources/data/parameters-importdata.xml b/src/test/resources/data/parameters-importdata.xml index a5a090b..273ce6a 100644 --- a/src/test/resources/data/parameters-importdata.xml +++ b/src/test/resources/data/parameters-importdata.xml @@ -1,5 +1,6 @@ - - + + + \ No newline at end of file diff --git a/src/test/resources/data/parameters-testdata.xml b/src/test/resources/data/parameters-testdata.xml index 7dee31d..198e5f2 100644 --- a/src/test/resources/data/parameters-testdata.xml +++ b/src/test/resources/data/parameters-testdata.xml @@ -1,19 +1,19 @@ - - - - - + + + + + - + - +