| | |
| | | |
| | | These interfaces have to be implemented by subclasses named `*Controller`. |
| | | |
| | | All gradle tasks which need the generated interfaces depend on the Gradle task `processSpring` which controls the code generation. |
| | | All gradle tasks which need the generated interfaces depend on the Gradle task `openApiGenerate` which controls the code generation. |
| | | It can also be executed directly: |
| | | |
| | | ```shell |
| | | gw processSpring |
| | | gw openApiGenerate |
| | | ``` |
| | | |
| | | ### How to Generate Database Table Diagrams? |
| | |
| | | plugins { |
| | | id 'java' |
| | | id 'org.springframework.boot' version '2.7.5' |
| | | id 'io.openapiprocessor.openapi-processor' version '2022.2' |
| | | id 'org.springframework.boot' version '3.0.0-SNAPSHOT' |
| | | id 'io.spring.dependency-management' version '1.1.0' |
| | | id 'io.openapiprocessor.openapi-processor' version '2022.2' |
| | | id 'com.github.jk1.dependency-license-report' version '2.1' |
| | | id "org.owasp.dependencycheck" version "7.3.0" |
| | | id "com.diffplug.spotless" version "6.11.0" |
| | |
| | | |
| | | repositories { |
| | | mavenCentral() |
| | | maven { url 'https://repo.spring.io/milestone' } |
| | | maven { url 'https://repo.spring.io/snapshot' } |
| | | } |
| | | |
| | | java { |
| | |
| | | implementation 'org.springframework.boot:spring-boot-starter-web' |
| | | implementation 'org.springframework.boot:spring-boot-starter-validation' |
| | | implementation 'com.github.gavlyukovskiy:datasource-proxy-spring-boot-starter:1.8.1' |
| | | implementation 'org.springdoc:springdoc-openapi-ui:1.6.12' |
| | | implementation 'org.springdoc:springdoc-openapi:2.0.0-M7' |
| | | implementation 'org.liquibase:liquibase-core' |
| | | implementation 'com.vladmihalcea:hibernate-types-55:2.20.0' |
| | | implementation 'com.vladmihalcea:hibernate-types-60:2.20.0' |
| | | implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.4' |
| | | implementation 'org.openapitools:jackson-databind-nullable:0.2.3' |
| | | implementation 'org.openapitools:jackson-databind-nullable:0.2.4' |
| | | implementation 'org.apache.commons:commons-text:1.10.0' |
| | | implementation 'org.modelmapper:modelmapper:3.1.0' |
| | | implementation 'org.iban4j:iban4j:3.2.3-RELEASE' |
| | | |
| | |
| | | processor 'io.openapiprocessor:openapi-processor-spring:2022.5' |
| | | apiPath "$projectDir/src/main/resources/api-definition.yaml" |
| | | mapping "$projectDir/src/main/resources/api-mappings.yaml" |
| | | targetDir "$projectDir/build/generated/sources/openapi" |
| | | targetDir "$projectDir/build/generated/sources/openapi-javax" |
| | | showWarnings true |
| | | openApiNullable true |
| | | } |
| | |
| | | processor 'io.openapiprocessor:openapi-processor-spring:2022.5' |
| | | apiPath "$projectDir/src/main/resources/api-definition/rbac/rbac.yaml" |
| | | mapping "$projectDir/src/main/resources/api-definition/rbac/api-mappings.yaml" |
| | | targetDir "$projectDir/build/generated/sources/openapi" |
| | | targetDir "$projectDir/build/generated/sources/openapi-javax" |
| | | showWarnings true |
| | | openApiNullable true |
| | | } |
| | |
| | | processor 'io.openapiprocessor:openapi-processor-spring:2022.5' |
| | | apiPath "$projectDir/src/main/resources/api-definition/test/test.yaml" |
| | | mapping "$projectDir/src/main/resources/api-definition/test/api-mappings.yaml" |
| | | targetDir "$projectDir/build/generated/sources/openapi" |
| | | targetDir "$projectDir/build/generated/sources/openapi-javax" |
| | | showWarnings true |
| | | openApiNullable true |
| | | } |
| | |
| | | processor 'io.openapiprocessor:openapi-processor-spring:2022.5' |
| | | apiPath "$projectDir/src/main/resources/api-definition/hs-office/hs-office.yaml" |
| | | mapping "$projectDir/src/main/resources/api-definition/hs-office/api-mappings.yaml" |
| | | targetDir "$projectDir/build/generated/sources/openapi" |
| | | targetDir "$projectDir/build/generated/sources/openapi-javax" |
| | | showWarnings true |
| | | openApiNullable true |
| | | } |
| | |
| | | } |
| | | project.tasks.processResources.dependsOn processSpring |
| | | project.tasks.compileJava.dependsOn processSpring |
| | | |
| | | // Rename javax to jakarta in OpenApi generated java files because |
| | | // io.openapiprocessor.openapi-processor 2022.2 does not yet support the openapiprocessor useSpringBoot3 config option. |
| | | task openApiGenerate(type: Copy) { |
| | | from "$buildDir/generated/sources/openapi-javax" |
| | | into "$buildDir/generated/sources/openapi" |
| | | filter { line -> line.replaceAll('javax', 'jakarta') } |
| | | } |
| | | compileJava.source "$buildDir/generated/sources/openapi" |
| | | compileJava.dependsOn openApiGenerate |
| | | openApiGenerate.dependsOn processSpring |
| | | |
| | | // Spotless Code Formatting |
| | | spotless { |
| | |
| | | targetTests = ['net.hostsharing.hsadminng.**.*UnitTest', 'net.hostsharing.hsadminng.**.*RestTest'] |
| | | excludedTestClasses = ['**AcceptanceTest*', '**IntegrationTest*'] |
| | | |
| | | pitestVersion = '1.9.0' |
| | | junit5PluginVersion = '1.0.0' |
| | | pitestVersion = '1.9.9' |
| | | junit5PluginVersion = '1.1.0' |
| | | |
| | | threads = 4 |
| | | |
| | |
| | | { |
| | | "allowedLicenses": [ |
| | | { "moduleLicense": "Apache 2.0" }, |
| | | { "moduleLicense": "Apache 2" }, |
| | | { "moduleLicense": "Apache License 2.0" }, |
| | | { "moduleLicense": "Apache License, Version 2.0" }, |
| | | { "moduleLicense": "The Apache Software License, Version 2.0" }, |
| | | |
| | | { "moduleLicense": "BSD License" }, |
| | | { "moduleLicense": "BSD-2-Clause" }, |
| | | { "moduleLicense": "The BSD License" }, |
| | | |
| | | { "moduleLicense": "CDDL 1.1" }, |
| | | { "moduleLicense": "CDDL/GPLv2+CE" }, |
| | |
| | | { "moduleLicense": "MIT License" }, |
| | | { "moduleLicense": "MIT" }, |
| | | { "moduleLicense": "The MIT License (MIT)" }, |
| | | { "moduleLicense": "The MIT License" } |
| | | { "moduleLicense": "The MIT License" }, |
| | | |
| | | { "moduleName": "org.springdoc:springdoc-openapi" } |
| | | ] |
| | | } |
| | |
| | | |
| | | # Spring BOM overrides |
| | | postgresql.version = 42.4.1 |
| | | snakeyaml.version = 1.32 |
| | | jackson-databind = 2.13.4 |
| | | # postgresql.version = 42.4.1 |
| | | # snakeyaml.version = 1.32 |
| | | # jackson-databind = 2.13.4 |
| | | |
| | | # TODO: can be removed if all dependencies are JDK 16 compliant, check with `gw clean check` |
| | | # and check output for "cannot access class ... because module jdk.compiler does not export ..." |
| | |
| | | --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \ |
| | | --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \ |
| | | --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \ |
| | | --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED |
| | | --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \ |
| | | |
| | | # --add-exports com.vladmihalcea.hibernate.type.array.internal.StringArrayTypeDescriptor\ |
| | | # --add-exports org.hibernate.type.descriptor.java.BasicPluralJavaType |
| | |
| | | pluginManagement { |
| | | repositories { |
| | | maven { url 'https://repo.spring.io/milestone' } |
| | | maven { url 'https://repo.spring.io/snapshot' } |
| | | gradlePluginPortal() |
| | | mavenCentral() |
| | | } |
| | | } |
| | | |
| | | rootProject.name = 'hsadmin-ng' |
| | |
| | | package net.hostsharing.hsadminng.config; |
| | | |
| | | import org.hibernate.dialect.PostgreSQL95Dialect; |
| | | import org.hibernate.dialect.PostgreSQLDialect; |
| | | |
| | | import java.sql.Types; |
| | | import static org.hibernate.dialect.DatabaseVersion.make; |
| | | |
| | | @SuppressWarnings("unused") // configured in application.yml |
| | | public class PostgresCustomDialect extends PostgreSQL95Dialect { |
| | | public class PostgresCustomDialect extends PostgreSQLDialect { |
| | | |
| | | public PostgresCustomDialect() { |
| | | this.registerHibernateType(Types.OTHER, "pg-uuid"); |
| | | this.registerHibernateType(Types.ARRAY, "array"); |
| | | super(make(13, 7)); |
| | | } |
| | | |
| | | } |
| | |
| | | package net.hostsharing.hsadminng.context; |
| | | |
| | | import com.vladmihalcea.hibernate.type.array.StringArrayType; |
| | | import com.vladmihalcea.hibernate.type.array.UUIDArrayType; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.SneakyThrows; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import java.util.Collections; |
| | | import java.util.Optional; |
| | | import java.util.Set; |
| | |
| | | } |
| | | |
| | | public UUID getCurrentUserUUid() { |
| | | return (UUID) em.createNativeQuery("select currentUserUUid()").getSingleResult(); |
| | | return (UUID) em.createNativeQuery("select currentUserUUid()", UUID.class).getSingleResult(); |
| | | } |
| | | |
| | | public String[] getAssumedRoles() { |
| | | return (String[]) em.createNativeQuery("select assumedRoles() as roles") |
| | | .unwrap(org.hibernate.query.NativeQuery.class) |
| | | .addScalar("roles", StringArrayType.INSTANCE) |
| | | .getSingleResult(); |
| | | return (String[]) em.createNativeQuery("select assumedRoles() as roles", String[].class).getSingleResult(); |
| | | } |
| | | |
| | | public UUID[] currentSubjectsUuids() { |
| | | return (UUID[]) em.createNativeQuery("select currentSubjectsUuids() as uuids") |
| | | .unwrap(org.hibernate.query.NativeQuery.class) |
| | | .addScalar("uuids", UUIDArrayType.INSTANCE) // TODO.blog |
| | | .getSingleResult(); |
| | | return (UUID[]) em.createNativeQuery("select currentSubjectsUuids() as uuids", UUID[].class).getSingleResult(); |
| | | } |
| | | |
| | | public static String getCallerMethodNameFromStackFrame(final int skipFrames) { |
| | |
| | | .filter(c -> c.getDeclaringClass() |
| | | .getPackageName() |
| | | .startsWith("net.hostsharing.hsadminng")) |
| | | .filter(c -> !c.getDeclaringClass().getName().contains("BySpringCGLIB$$")) |
| | | .filter(c -> !c.getDeclaringClass().getName().contains("$$SpringCGLIB$$")) |
| | | .findFirst()); |
| | | return caller.map( |
| | | c -> c.getDeclaringClass().getSimpleName() + "." + c.getMethodName()) |
| | |
| | | package net.hostsharing.hsadminng.context; |
| | | |
| | | import javax.servlet.ReadListener; |
| | | import javax.servlet.ServletInputStream; |
| | | import jakarta.servlet.ReadListener; |
| | | import jakarta.servlet.ServletInputStream; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.filter.OncePerRequestFilter; |
| | | |
| | | import javax.servlet.FilterChain; |
| | | import javax.servlet.ServletException; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import jakarta.servlet.FilterChain; |
| | | import jakarta.servlet.ServletException; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | |
| | | @Component |
| | |
| | | |
| | | import org.springframework.util.StreamUtils; |
| | | |
| | | import javax.servlet.ServletInputStream; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletRequestWrapper; |
| | | import jakarta.servlet.ServletInputStream; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import jakarta.servlet.http.HttpServletRequestWrapper; |
| | | import java.io.BufferedReader; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.IOException; |
| | |
| | | import org.springframework.dao.DataIntegrityViolationException; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.HttpStatusCode; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.http.converter.HttpMessageNotReadableException; |
| | | import org.springframework.lang.Nullable; |
| | | import org.springframework.orm.jpa.JpaObjectRetrievalFailureException; |
| | | import org.springframework.orm.jpa.JpaSystemException; |
| | |
| | | import org.springframework.web.context.request.WebRequest; |
| | | import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; |
| | | |
| | | import javax.persistence.EntityNotFoundException; |
| | | import javax.validation.ValidationException; |
| | | import jakarta.persistence.EntityNotFoundException; |
| | | import jakarta.validation.ValidationException; |
| | | import java.util.NoSuchElementException; |
| | | import java.util.Optional; |
| | | import java.util.regex.Pattern; |
| | |
| | | @Override |
| | | @SuppressWarnings("unchecked,rawtypes") |
| | | protected ResponseEntity handleExceptionInternal( |
| | | Exception exc, @Nullable Object body, HttpHeaders headers, HttpStatus status, WebRequest request) { |
| | | Exception exc, @Nullable Object body, HttpHeaders headers, HttpStatusCode statusCode, WebRequest request) { |
| | | |
| | | final var response = super.handleExceptionInternal(exc, body, headers, status, request); |
| | | return errorResponse(request, response.getStatusCode(), |
| | | final var response = super.handleExceptionInternal(exc, body, headers, statusCode, request); |
| | | return errorResponse(request, HttpStatus.valueOf(statusCode.value()), |
| | | Optional.ofNullable(response.getBody()).map(Object::toString).orElse(firstMessageLine(exc))); |
| | | } |
| | | @Override |
| | | @SuppressWarnings("unchecked,rawtypes") |
| | | protected ResponseEntity handleHttpMessageNotReadable( |
| | | HttpMessageNotReadableException exc, HttpHeaders headers, HttpStatusCode status, WebRequest request) { |
| | | final var message = line(exc.getMessage(), 0); |
| | | return errorResponse(request, HttpStatus.BAD_REQUEST, message); |
| | | } |
| | | |
| | | @Override |
| | |
| | | protected ResponseEntity handleMethodArgumentNotValid( |
| | | MethodArgumentNotValidException exc, |
| | | HttpHeaders headers, |
| | | HttpStatus status, |
| | | HttpStatusCode statusCode, |
| | | WebRequest request) { |
| | | final var errorList = exc |
| | | .getBindingResult() |
| | |
| | | package net.hostsharing.hsadminng.hs.office.bankaccount; |
| | | |
| | | import net.hostsharing.hsadminng.mapper.Mapper; |
| | | import net.hostsharing.hsadminng.context.Context; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeBankAccountsApi; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeBankAccountInsertResource; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeBankAccountResource; |
| | | import net.hostsharing.hsadminng.mapper.Mapper; |
| | | import org.iban4j.BicUtil; |
| | | import org.iban4j.IbanUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | final var entityToSave = mapper.map(body, HsOfficeBankAccountEntity.class); |
| | | |
| | | |
| | | final var saved = bankAccountRepo.save(entityToSave); |
| | | // em.persist(entityToSave); |
| | | // final var saved = entityToSave; |
| | | // em.flush(); |
| | | |
| | | final var uri = |
| | | MvcUriComponentsBuilder.fromController(getClass()) |
| | |
| | | import net.hostsharing.hsadminng.errors.DisplayName; |
| | | import net.hostsharing.hsadminng.stringify.Stringify; |
| | | import net.hostsharing.hsadminng.stringify.Stringifyable; |
| | | import org.hibernate.annotations.GenericGenerator; |
| | | |
| | | import javax.persistence.Entity; |
| | | import javax.persistence.GeneratedValue; |
| | | import javax.persistence.Id; |
| | | import javax.persistence.Table; |
| | | import jakarta.persistence.Entity; |
| | | import jakarta.persistence.GeneratedValue; |
| | | import jakarta.persistence.Id; |
| | | import jakarta.persistence.Table; |
| | | import java.util.UUID; |
| | | |
| | | import static net.hostsharing.hsadminng.stringify.Stringify.stringify; |
| | |
| | | @Id |
| | | @GeneratedValue |
| | | private UUID uuid; |
| | | |
| | | private String holder; |
| | | |
| | | private String iban; |
| | |
| | | |
| | | List<HsOfficeBankAccountEntity> findByIbanOrderByIban(String iban); |
| | | |
| | | HsOfficeBankAccountEntity save(final HsOfficeBankAccountEntity entity); |
| | | <S extends HsOfficeBankAccountEntity> S save(S entity); |
| | | |
| | | int deleteByUuid(final UUID uuid); |
| | | |
| | |
| | | import net.hostsharing.hsadminng.stringify.Stringifyable; |
| | | import org.hibernate.annotations.GenericGenerator; |
| | | |
| | | import javax.persistence.*; |
| | | import jakarta.persistence.*; |
| | | import java.util.UUID; |
| | | |
| | | import static net.hostsharing.hsadminng.stringify.Stringify.stringify; |
| | |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeCoopAssetsApi; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeCoopAssetsTransactionInsertResource; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeCoopAssetsTransactionResource; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeCoopSharesTransactionResource; |
| | | import net.hostsharing.hsadminng.mapper.Mapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder; |
| | | |
| | | import javax.validation.Valid; |
| | | import javax.validation.ValidationException; |
| | | import jakarta.validation.Valid; |
| | | import jakarta.validation.ValidationException; |
| | | import java.time.LocalDate; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | import net.hostsharing.hsadminng.stringify.Stringifyable; |
| | | import org.hibernate.annotations.GenericGenerator; |
| | | import org.hibernate.annotations.Type; |
| | | import org.hibernate.annotations.TypeDef; |
| | | |
| | | import javax.persistence.*; |
| | | import jakarta.persistence.*; |
| | | import java.math.BigDecimal; |
| | | import java.text.DecimalFormat; |
| | | import java.time.LocalDate; |
| | |
| | | |
| | | @Entity |
| | | @Table(name = "hs_office_coopassetstransaction_rv") |
| | | @TypeDef( |
| | | name = "pgsql_enum", |
| | | typeClass = PostgreSQLEnumType.class |
| | | ) |
| | | @Getter |
| | | @Setter |
| | | @Builder |
| | |
| | | |
| | | @Column(name = "transactiontype") |
| | | @Enumerated(EnumType.STRING) |
| | | @Type( type = "pgsql_enum" ) |
| | | @Type(PostgreSQLEnumType.class) |
| | | private HsOfficeCoopAssetsTransactionType transactionType; |
| | | |
| | | @Column(name = "valuedate") |
| | |
| | | package net.hostsharing.hsadminng.hs.office.coopshares; |
| | | |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeContactResource; |
| | | import net.hostsharing.hsadminng.mapper.Mapper; |
| | | import net.hostsharing.hsadminng.context.Context; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeCoopSharesApi; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeCoopSharesTransactionInsertResource; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeCoopSharesTransactionResource; |
| | | import net.hostsharing.hsadminng.mapper.Mapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.springframework.format.annotation.DateTimeFormat.ISO; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder; |
| | | |
| | | import javax.validation.Valid; |
| | | import javax.validation.ValidationException; |
| | | import jakarta.validation.Valid; |
| | | import jakarta.validation.ValidationException; |
| | | import java.time.LocalDate; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | import net.hostsharing.hsadminng.stringify.Stringify; |
| | | import net.hostsharing.hsadminng.stringify.Stringifyable; |
| | | import org.hibernate.annotations.Type; |
| | | import org.hibernate.annotations.TypeDef; |
| | | |
| | | import javax.persistence.*; |
| | | import jakarta.persistence.*; |
| | | import java.time.LocalDate; |
| | | import java.util.UUID; |
| | | |
| | |
| | | |
| | | @Entity |
| | | @Table(name = "hs_office_coopsharestransaction_rv") |
| | | @TypeDef( |
| | | name = "pgsql_enum", |
| | | typeClass = PostgreSQLEnumType.class |
| | | ) |
| | | @Getter |
| | | @Setter |
| | | @Builder |
| | |
| | | |
| | | @Column(name = "transactiontype") |
| | | @Enumerated(EnumType.STRING) |
| | | @Type(type = "pgsql_enum") |
| | | @Type(PostgreSQLEnumType.class) |
| | | private HsOfficeCoopSharesTransactionType transactionType; |
| | | |
| | | @Column(name = "valuedate") |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | |
| | | import net.hostsharing.hsadminng.stringify.Stringifyable; |
| | | import org.hibernate.annotations.GenericGenerator; |
| | | |
| | | import javax.persistence.*; |
| | | import jakarta.persistence.*; |
| | | import java.util.UUID; |
| | | |
| | | import static net.hostsharing.hsadminng.stringify.Stringify.stringify; |
| | |
| | | package net.hostsharing.hsadminng.hs.office.debitor; |
| | | |
| | | import net.hostsharing.hsadminng.mapper.EntityPatcher; |
| | | import net.hostsharing.hsadminng.mapper.OptionalFromJson; |
| | | import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorPatchResource; |
| | | import net.hostsharing.hsadminng.mapper.EntityPatcher; |
| | | import net.hostsharing.hsadminng.mapper.OptionalFromJson; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import jakarta.persistence.EntityManager; |
| | | |
| | | class HsOfficeDebitorEntityPatcher implements EntityPatcher<HsOfficeDebitorPatchResource> { |
| | | |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import javax.validation.Valid; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import jakarta.validation.Valid; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | import java.util.function.BiConsumer; |
| | |
| | | import org.hibernate.annotations.Fetch; |
| | | import org.hibernate.annotations.FetchMode; |
| | | import org.hibernate.annotations.Type; |
| | | import org.hibernate.annotations.TypeDef; |
| | | |
| | | import javax.persistence.*; |
| | | import jakarta.persistence.*; |
| | | import java.time.LocalDate; |
| | | import java.util.UUID; |
| | | |
| | |
| | | |
| | | @Entity |
| | | @Table(name = "hs_office_membership_rv") |
| | | @TypeDef( |
| | | name = "pgsql_enum", |
| | | typeClass = PostgreSQLEnumType.class |
| | | ) |
| | | @Getter |
| | | @Setter |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @DisplayName("Membership") |
| | | @TypeDef( |
| | | typeClass = PostgreSQLRangeType.class, |
| | | defaultForType = Range.class |
| | | ) |
| | | public class HsOfficeMembershipEntity implements Stringifyable { |
| | | |
| | | private static Stringify<HsOfficeMembershipEntity> stringify = stringify(HsOfficeMembershipEntity.class) |
| | |
| | | private int memberNumber; |
| | | |
| | | @Column(name = "validity", columnDefinition = "daterange") |
| | | @Type(PostgreSQLRangeType.class) |
| | | private Range<LocalDate> validity; |
| | | |
| | | @Column(name = "reasonfortermination") |
| | | @Enumerated(EnumType.STRING) |
| | | @Type(type = "pgsql_enum") |
| | | @Type(PostgreSQLEnumType.class) |
| | | private HsOfficeReasonForTermination reasonForTermination; |
| | | |
| | | public void setValidFrom(final LocalDate validFrom) { |
| | |
| | | import net.hostsharing.hsadminng.mapper.Mapper; |
| | | import net.hostsharing.hsadminng.mapper.OptionalFromJson; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import jakarta.persistence.EntityManager; |
| | | import java.util.Optional; |
| | | import java.util.UUID; |
| | | |
| | |
| | | package net.hostsharing.hsadminng.hs.office.partner; |
| | | |
| | | import net.hostsharing.hsadminng.context.Context; |
| | | import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficePartnersApi; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerInsertResource; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerPatchResource; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | |
| | | import net.hostsharing.hsadminng.stringify.Stringify; |
| | | import net.hostsharing.hsadminng.stringify.Stringifyable; |
| | | |
| | | import javax.persistence.*; |
| | | import jakarta.persistence.*; |
| | | import java.time.LocalDate; |
| | | import java.util.UUID; |
| | | |
| | |
| | | package net.hostsharing.hsadminng.hs.office.partner; |
| | | |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerDetailsPatchResource; |
| | | import net.hostsharing.hsadminng.mapper.EntityPatcher; |
| | | import net.hostsharing.hsadminng.mapper.OptionalFromJson; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerDetailsPatchResource; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import jakarta.persistence.EntityManager; |
| | | |
| | | class HsOfficePartnerDetailsEntityPatcher implements EntityPatcher<HsOfficePartnerDetailsPatchResource> { |
| | | |
| | |
| | | import org.hibernate.annotations.NotFound; |
| | | import org.hibernate.annotations.NotFoundAction; |
| | | |
| | | import javax.persistence.*; |
| | | import jakarta.persistence.*; |
| | | import java.util.UUID; |
| | | |
| | | import static net.hostsharing.hsadminng.stringify.Stringify.stringify; |
| | |
| | | package net.hostsharing.hsadminng.hs.office.partner; |
| | | |
| | | import net.hostsharing.hsadminng.mapper.EntityPatcher; |
| | | import net.hostsharing.hsadminng.mapper.OptionalFromJson; |
| | | import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerPatchResource; |
| | | import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; |
| | | import net.hostsharing.hsadminng.mapper.EntityPatcher; |
| | | import net.hostsharing.hsadminng.mapper.OptionalFromJson; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import jakarta.persistence.EntityManager; |
| | | import java.util.UUID; |
| | | |
| | | class HsOfficePartnerEntityPatcher implements EntityPatcher<HsOfficePartnerPatchResource> { |
| | |
| | | import net.hostsharing.hsadminng.stringify.Stringifyable; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.hibernate.annotations.Type; |
| | | import org.hibernate.annotations.TypeDef; |
| | | |
| | | import javax.persistence.*; |
| | | import jakarta.persistence.*; |
| | | import java.util.UUID; |
| | | |
| | | import static net.hostsharing.hsadminng.stringify.Stringify.stringify; |
| | | |
| | | @Entity |
| | | @Table(name = "hs_office_person_rv") |
| | | @TypeDef( |
| | | name = "pgsql_enum", |
| | | typeClass = PostgreSQLEnumType.class |
| | | ) |
| | | @Getter |
| | | @Setter |
| | | @Builder |
| | |
| | | |
| | | @Column(name = "persontype") |
| | | @Enumerated(EnumType.STRING) |
| | | @Type(type = "pgsql_enum") |
| | | @Type(PostgreSQLEnumType.class) |
| | | private HsOfficePersonType personType; |
| | | |
| | | @Column(name = "tradename") |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import java.util.List; |
| | | import java.util.NoSuchElementException; |
| | | import java.util.UUID; |
| | |
| | | import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; |
| | | import net.hostsharing.hsadminng.stringify.Stringify; |
| | | import org.hibernate.annotations.Type; |
| | | import org.hibernate.annotations.TypeDef; |
| | | |
| | | import javax.persistence.*; |
| | | import jakarta.persistence.*; |
| | | import java.util.UUID; |
| | | |
| | | import static net.hostsharing.hsadminng.stringify.Stringify.stringify; |
| | | |
| | | @Entity |
| | | @Table(name = "hs_office_relationship_rv") |
| | | @TypeDef( |
| | | name = "pgsql_enum", |
| | | typeClass = PostgreSQLEnumType.class |
| | | ) |
| | | @Getter |
| | | @Setter |
| | | @Builder |
| | |
| | | |
| | | @Column(name = "reltype") |
| | | @Enumerated(EnumType.STRING) |
| | | @Type(type = "pgsql_enum") |
| | | @Type(PostgreSQLEnumType.class) |
| | | private HsOfficeRelationshipType relType; |
| | | |
| | | @Override |
| | |
| | | package net.hostsharing.hsadminng.hs.office.relationship; |
| | | |
| | | import net.hostsharing.hsadminng.mapper.EntityPatcher; |
| | | import net.hostsharing.hsadminng.mapper.OptionalFromJson; |
| | | import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeRelationshipPatchResource; |
| | | import net.hostsharing.hsadminng.mapper.EntityPatcher; |
| | | import net.hostsharing.hsadminng.mapper.OptionalFromJson; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import jakarta.persistence.EntityManager; |
| | | import java.util.UUID; |
| | | |
| | | class HsOfficeRelationshipEntityPatcher implements EntityPatcher<HsOfficeRelationshipPatchResource> { |
| | |
| | | import org.springframework.data.jpa.repository.Query; |
| | | import org.springframework.data.repository.Repository; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.UUID; |
| | |
| | | package net.hostsharing.hsadminng.hs.office.sepamandate; |
| | | |
| | | import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipEntityPatcher; |
| | | import net.hostsharing.hsadminng.mapper.Mapper; |
| | | import net.hostsharing.hsadminng.context.Context; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeSepaMandatesApi; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeSepaMandateInsertResource; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import javax.validation.Valid; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import jakarta.validation.Valid; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | import java.util.function.BiConsumer; |
| | |
| | | import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity; |
| | | import net.hostsharing.hsadminng.stringify.Stringify; |
| | | import net.hostsharing.hsadminng.stringify.Stringifyable; |
| | | import org.hibernate.annotations.TypeDef; |
| | | import org.hibernate.annotations.Type; |
| | | |
| | | import javax.persistence.*; |
| | | import jakarta.persistence.*; |
| | | import java.time.LocalDate; |
| | | import java.util.UUID; |
| | | |
| | |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @DisplayName("SEPA-Mandate") |
| | | @TypeDef( |
| | | typeClass = PostgreSQLRangeType.class, |
| | | defaultForType = Range.class |
| | | ) |
| | | public class HsOfficeSepaMandateEntity implements Stringifyable { |
| | | |
| | | private static Stringify<HsOfficeSepaMandateEntity> stringify = stringify(HsOfficeSepaMandateEntity.class) |
| | |
| | | private LocalDate agreement; |
| | | |
| | | @Column(name = "validity", columnDefinition = "daterange") |
| | | @Type(PostgreSQLRangeType.class) |
| | | private Range<LocalDate> validity = Range.infinite(LocalDate.class); |
| | | |
| | | public void setValidFrom(final LocalDate validFrom) { |
| | |
| | | |
| | | import net.hostsharing.hsadminng.errors.DisplayName; |
| | | import org.modelmapper.ModelMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.ReflectionUtils; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.ManyToOne; |
| | | import javax.persistence.PersistenceContext; |
| | | import javax.validation.ValidationException; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.ManyToOne; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import jakarta.validation.ValidationException; |
| | | import java.lang.reflect.Field; |
| | | import java.util.List; |
| | | import java.util.function.BiConsumer; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | |
| | | import net.hostsharing.hsadminng.rbac.rbacrole.RbacRoleType; |
| | | import org.springframework.data.annotation.Immutable; |
| | | |
| | | import javax.persistence.*; |
| | | import jakarta.persistence.*; |
| | | import java.util.UUID; |
| | | |
| | | @Entity |
| | |
| | | |
| | | import lombok.*; |
| | | import org.hibernate.annotations.Formula; |
| | | import org.hibernate.annotations.GenericGenerator; |
| | | import org.springframework.data.annotation.Immutable; |
| | | |
| | | import javax.persistence.*; |
| | | import jakarta.persistence.*; |
| | | import java.util.UUID; |
| | | |
| | | @Entity |
| | |
| | | public class RbacRoleEntity { |
| | | |
| | | @Id |
| | | @GeneratedValue(generator = "UUID") |
| | | @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator") |
| | | @GeneratedValue |
| | | private UUID uuid; |
| | | |
| | | @Column(name = "objectuuid") |
| | |
| | | package net.hostsharing.hsadminng.rbac.rbacuser; |
| | | |
| | | import lombok.*; |
| | | import org.hibernate.annotations.GenericGenerator; |
| | | import org.springframework.data.annotation.Immutable; |
| | | |
| | | import javax.persistence.Entity; |
| | | import javax.persistence.GeneratedValue; |
| | | import javax.persistence.Id; |
| | | import javax.persistence.Table; |
| | | import jakarta.persistence.Entity; |
| | | import jakarta.persistence.GeneratedValue; |
| | | import jakarta.persistence.Id; |
| | | import jakarta.persistence.Table; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.ChronoUnit; |
| | |
| | | private static DateTimeFormatter DATE_FORMAT_WITH_FULLHOUR = DateTimeFormatter.ofPattern("MM-dd-yyyy HH"); |
| | | |
| | | @Id |
| | | @GeneratedValue(generator = "UUID") |
| | | @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator") |
| | | @GeneratedValue |
| | | private UUID uuid; |
| | | |
| | | private String name; |
| | |
| | | |
| | | import net.hostsharing.hsadminng.errors.DisplayName; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.Setter; |
| | | |
| | | import javax.persistence.*; |
| | | import jakarta.persistence.*; |
| | | import java.util.UUID; |
| | | |
| | | @Entity |
| | |
| | | import lombok.Setter; |
| | | import net.hostsharing.hsadminng.test.cust.TestCustomerEntity; |
| | | |
| | | import javax.persistence.*; |
| | | import jakarta.persistence.*; |
| | | import java.util.UUID; |
| | | |
| | | @Entity |
| | |
| | | import org.springframework.data.jpa.repository.JpaRepository; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import static com.tngtech.archunit.core.domain.JavaModifier.*; |
| | | import static com.tngtech.archunit.core.domain.JavaModifier.ABSTRACT; |
| | | import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.*; |
| | | import static com.tngtech.archunit.library.dependencies.SlicesRuleDefinition.slices; |
| | | |
| | |
| | | |
| | | @ArchTest |
| | | @SuppressWarnings("unused") |
| | | public static final ArchRule doNotUseJavaxTransactionAnnotationAtClassLevel = noClasses() |
| | | .should().beAnnotatedWith(javax.transaction.Transactional.class.getName()) |
| | | public static final ArchRule doNotUsejakartaTransactionAnnotationAtClassLevel = noClasses() |
| | | .should().beAnnotatedWith(jakarta.transaction.Transactional.class.getName()) |
| | | .as("Use @%s instead of @%s.".formatted( |
| | | org.springframework.transaction.annotation.Transactional.class.getName(), |
| | | javax.transaction.Transactional.class)); |
| | | jakarta.transaction.Transactional.class)); |
| | | |
| | | @ArchTest |
| | | @SuppressWarnings("unused") |
| | | public static final ArchRule doNotUseJavaxTransactionAnnotationAtMethodLevel = noMethods() |
| | | .should().beAnnotatedWith(javax.transaction.Transactional.class) |
| | | public static final ArchRule doNotUsejakartaTransactionAnnotationAtMethodLevel = noMethods() |
| | | .should().beAnnotatedWith(jakarta.transaction.Transactional.class) |
| | | .as("Use @%s instead of @%s.".formatted( |
| | | org.springframework.transaction.annotation.Transactional.class.getName(), |
| | | javax.transaction.Transactional.class.getName())); |
| | | jakarta.transaction.Transactional.class.getName())); |
| | | |
| | | @ArchTest |
| | | @SuppressWarnings("unused") |
| | |
| | | import org.springframework.test.annotation.DirtiesContext; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | |
| | | import static org.assertj.core.api.Assertions.assertThat; |
| | | |
| | |
| | | |
| | | // then |
| | | result.assertExceptionWithRootCauseMessage( |
| | | javax.persistence.PersistenceException.class, |
| | | jakarta.persistence.PersistenceException.class, |
| | | "ERROR: [403] undefined has no permission to assume role test_package#yyy00.admin"); |
| | | } |
| | | |
| | |
| | | |
| | | // then |
| | | result.assertExceptionWithRootCauseMessage( |
| | | javax.persistence.PersistenceException.class, |
| | | jakarta.persistence.PersistenceException.class, |
| | | "[401] user unknown@example.org given in `defineContext(...)` does not exist"); |
| | | } |
| | | |
| | |
| | | |
| | | // then |
| | | result.assertExceptionWithRootCauseMessage( |
| | | javax.persistence.PersistenceException.class, |
| | | jakarta.persistence.PersistenceException.class, |
| | | "ERROR: [403] user customer-admin@xxx.example.com has no permission to assume role test_package#yyy00.admin"); |
| | | } |
| | | } |
| | |
| | | import org.springframework.web.context.request.RequestAttributes; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.Query; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.Query; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.util.Collections; |
| | |
| | | import org.springframework.dao.DataIntegrityViolationException; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.orm.jpa.JpaObjectRetrievalFailureException; |
| | | import org.springframework.orm.jpa.JpaSystemException; |
| | | import org.springframework.validation.BindingResult; |
| | |
| | | import org.springframework.web.bind.MethodArgumentNotValidException; |
| | | import org.springframework.web.context.request.WebRequest; |
| | | |
| | | import javax.persistence.EntityNotFoundException; |
| | | import jakarta.persistence.EntityNotFoundException; |
| | | import java.util.List; |
| | | import java.util.NoSuchElementException; |
| | | |
| | |
| | | final var errorResponse = exceptionHandler.handleConflict(givenException, givenWebRequest); |
| | | |
| | | // then |
| | | assertThat(errorResponse.getStatusCodeValue()).isEqualTo(409); |
| | | assertThat(errorResponse.getBody().getStatusCode()).isEqualTo(409); |
| | | assertThat(errorResponse.getBody().getMessage()).isEqualTo("First Line"); |
| | | } |
| | | |
| | |
| | | final var errorResponse = exceptionHandler.handleConflict(givenException, givenWebRequest); |
| | | |
| | | // then |
| | | assertThat(errorResponse.getStatusCodeValue()).isEqualTo(400); |
| | | assertThat(errorResponse.getBody().getStatusCode()).isEqualTo(400); |
| | | assertThat(errorResponse.getBody()).isNotNull() |
| | | .extracting(CustomErrorResponse::getMessage).isEqualTo("Second Line"); |
| | | } |
| | |
| | | final var errorResponse = exceptionHandler.handleJpaExceptions(givenException, givenWebRequest); |
| | | |
| | | // then |
| | | assertThat(errorResponse.getStatusCodeValue()).isEqualTo(401); |
| | | assertThat(errorResponse.getBody().getStatusCode()).isEqualTo(401); |
| | | assertThat(errorResponse.getBody().getMessage()).isEqualTo("ERROR: [401] First Line"); |
| | | } |
| | | |
| | |
| | | final var errorResponse = exceptionHandler.handleJpaObjectRetrievalFailureException(givenException, givenWebRequest); |
| | | |
| | | // then |
| | | assertThat(errorResponse.getStatusCodeValue()).isEqualTo(400); |
| | | assertThat(errorResponse.getBody().getStatusCode()).isEqualTo(400); |
| | | assertThat(errorResponse.getBody().getMessage()).isEqualTo("Unable to find Partner with uuid 12345-123454"); |
| | | } |
| | | |
| | |
| | | final var errorResponse = exceptionHandler.handleJpaObjectRetrievalFailureException(givenException, givenWebRequest); |
| | | |
| | | // then |
| | | assertThat(errorResponse.getStatusCodeValue()).isEqualTo(400); |
| | | assertThat(errorResponse.getBody().getStatusCode()).isEqualTo(400); |
| | | assertThat(errorResponse.getBody().getMessage()).isEqualTo( |
| | | "Unable to find net.hostsharing.hsadminng.WhateverEntity with id 12345-123454"); |
| | | } |
| | |
| | | final var errorResponse = exceptionHandler.handleJpaObjectRetrievalFailureException(givenException, givenWebRequest); |
| | | |
| | | // then |
| | | assertThat(errorResponse.getStatusCodeValue()).isEqualTo(400); |
| | | assertThat(errorResponse.getBody().getStatusCode()).isEqualTo(400); |
| | | assertThat(errorResponse.getBody().getMessage()).isEqualTo("whatever error message"); |
| | | } |
| | | |
| | |
| | | final var errorResponse = exceptionHandler.handleJpaObjectRetrievalFailureException(givenException, givenWebRequest); |
| | | |
| | | // then |
| | | assertThat(errorResponse.getStatusCodeValue()).isEqualTo(400); |
| | | assertThat(errorResponse.getBody().getStatusCode()).isEqualTo(400); |
| | | assertThat(errorResponse.getBody().getMessage()).isEqualTo("Unable to find NoDisplayNameEntity with uuid 12345-123454"); |
| | | } |
| | | |
| | |
| | | final var errorResponse = exceptionHandler.handleJpaExceptions(givenException, givenWebRequest); |
| | | |
| | | // then |
| | | assertThat(errorResponse.getStatusCodeValue()).isEqualTo(500); |
| | | assertThat(errorResponse.getBody().getStatusCode()).isEqualTo(500); |
| | | assertThat(errorResponse.getBody().getMessage()).isEqualTo("ERROR: [999] First Line"); |
| | | } |
| | | |
| | |
| | | final var errorResponse = exceptionHandler.handleNoSuchElementException(givenException, givenWebRequest); |
| | | |
| | | // then |
| | | assertThat(errorResponse.getStatusCodeValue()).isEqualTo(404); |
| | | assertThat(errorResponse.getBody().getStatusCode()).isEqualTo(404); |
| | | assertThat(errorResponse.getBody().getMessage()).isEqualTo("some error message"); |
| | | } |
| | | |
| | |
| | | final var errorResponse = exceptionHandler.handleIbanAndBicExceptions(givenException, givenWebRequest); |
| | | |
| | | // then |
| | | assertThat(errorResponse.getStatusCodeValue()).isEqualTo(400); |
| | | assertThat(errorResponse.getBody().getStatusCode()).isEqualTo(400); |
| | | assertThat(errorResponse.getBody().getMessage()).isEqualTo("given error message"); |
| | | } |
| | | |
| | |
| | | HttpHeaders.EMPTY, HttpStatus.BAD_REQUEST, givenWebRequest); |
| | | |
| | | // then |
| | | assertThat(errorResponse.getStatusCodeValue()).isEqualTo(400); |
| | | assertThat(errorResponse.getBody()) |
| | | .isInstanceOf(CustomErrorResponse.class) |
| | | .extracting("statusCode").isEqualTo(400); |
| | | assertThat(errorResponse.getBody()) |
| | | .extracting("message") |
| | | .isEqualTo("[someField expected to be something but is \"someRejectedValue\"]"); |
| | | } |
| | |
| | | final var errorResponse = exceptionHandler.handleOtherExceptions(givenThrowable, givenWebRequest); |
| | | |
| | | // then |
| | | assertThat(errorResponse.getStatusCodeValue()).isEqualTo(500); |
| | | assertThat(errorResponse.getBody().getStatusCode()).isEqualTo(500); |
| | | assertThat(errorResponse.getBody().getMessage()).isEqualTo("First Line"); |
| | | } |
| | | |
| | |
| | | final var errorResponse = exceptionHandler.handleOtherExceptions(givenThrowable, givenWebRequest); |
| | | |
| | | // then |
| | | assertThat(errorResponse.getStatusCodeValue()).isEqualTo(418); |
| | | assertThat(errorResponse.getBody().getStatusCode()).isEqualTo(418); |
| | | assertThat(errorResponse.getBody().getMessage()).isEqualTo("ERROR: [418] First Line"); |
| | | } |
| | | |
| | |
| | | final var errorResponse = exceptionHandler.handleOtherExceptions(givenThrowable, givenWebRequest); |
| | | |
| | | // then |
| | | assertThat(errorResponse.getStatusCodeValue()).isEqualTo(500); |
| | | assertThat(errorResponse.getBody().getStatusCode()).isEqualTo(500); |
| | | assertThat(errorResponse.getBody().getMessage()).isEqualTo("ERROR: [500] java.lang.Error"); |
| | | } |
| | | |
| | |
| | | |
| | | import io.restassured.RestAssured; |
| | | import io.restassured.http.ContentType; |
| | | import net.hostsharing.hsadminng.mapper.Mapper; |
| | | import net.hostsharing.test.Accepts; |
| | | import net.hostsharing.hsadminng.HsadminNgApplication; |
| | | import net.hostsharing.hsadminng.context.Context; |
| | | import net.hostsharing.test.Accepts; |
| | | import net.hostsharing.test.JpaAttempt; |
| | | import org.apache.commons.lang3.RandomStringUtils; |
| | | import org.json.JSONException; |
| | |
| | | import org.springframework.boot.test.web.server.LocalServerPort; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import java.util.UUID; |
| | | |
| | | import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid; |
| | |
| | | return jpaAttempt.transacted(() -> { |
| | | context.define(creatingUser); |
| | | final var newBankAccount = HsOfficeBankAccountEntity.builder() |
| | | .uuid(UUID.randomUUID()) |
| | | .holder("temp acc #" + RandomStringUtils.randomAlphabetic(3)) |
| | | .iban("DE93500105179473626226") |
| | | .bic("INGDDEFFXXX") |
| | |
| | | import org.junit.jupiter.api.BeforeEach; |
| | | import org.junit.jupiter.api.Nested; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.junit.runner.RunWith; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; |
| | | import org.springframework.boot.test.mock.mockito.MockBean; |
| | | import org.springframework.context.annotation.ComponentScan; |
| | | import org.springframework.context.annotation.Import; |
| | | import org.springframework.test.annotation.DirtiesContext; |
| | | import org.springframework.test.context.junit4.SpringRunner; |
| | | import org.testcontainers.junit.jupiter.Container; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.function.Supplier; |
| | |
| | | import static org.assertj.core.api.Assertions.assertThat; |
| | | |
| | | @DataJpaTest |
| | | @Import( { Context.class, JpaAttempt.class }) |
| | | @Import({ Context.class, JpaAttempt.class }) |
| | | class HsOfficeBankAccountRepositoryIntegrationTest extends ContextBasedTest { |
| | | |
| | | @Autowired |
| | |
| | | |
| | | @MockBean |
| | | HttpServletRequest request; |
| | | |
| | | @Container |
| | | Container postgres; |
| | | |
| | | @Nested |
| | | class CreateBankAccount { |
| | |
| | | // when |
| | | attempt(em, () -> bankAccountRepo.save( |
| | | hsOfficeBankAccount("some temp acc C", "DE25500105176934832579", "INGDDEFFXXX")) |
| | | ).assumeSuccessful(); |
| | | ).assertSuccessful(); |
| | | |
| | | // then |
| | | final var roles = rawRoleRepo.findAll(); |
| | |
| | | |
| | | import io.restassured.RestAssured; |
| | | import io.restassured.http.ContentType; |
| | | import net.hostsharing.test.Accepts; |
| | | import net.hostsharing.hsadminng.HsadminNgApplication; |
| | | import net.hostsharing.hsadminng.context.Context; |
| | | import net.hostsharing.test.Accepts; |
| | | import net.hostsharing.test.JpaAttempt; |
| | | import org.apache.commons.lang3.RandomStringUtils; |
| | | import org.json.JSONException; |
| | |
| | | import org.springframework.boot.test.web.server.LocalServerPort; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import java.util.UUID; |
| | | |
| | | import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; |
| | | import org.springframework.boot.test.mock.mockito.MockBean; |
| | | import org.springframework.context.annotation.ComponentScan; |
| | | import org.springframework.context.annotation.Import; |
| | | import org.springframework.test.annotation.DirtiesContext; |
| | | import org.testcontainers.junit.jupiter.Container; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.function.Supplier; |
| | |
| | | import io.restassured.http.ContentType; |
| | | import net.hostsharing.hsadminng.HsadminNgApplication; |
| | | import net.hostsharing.hsadminng.context.Context; |
| | | import net.hostsharing.hsadminng.hs.office.coopassets.HsOfficeCoopAssetsTransactionRepository; |
| | | import net.hostsharing.hsadminng.hs.office.coopassets.HsOfficeCoopAssetsTransactionRepository; |
| | | import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipRepository; |
| | | import net.hostsharing.test.Accepts; |
| | | import net.hostsharing.test.JpaAttempt; |
| | |
| | | import org.springframework.boot.test.web.server.LocalServerPort; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import java.time.LocalDate; |
| | | import java.util.UUID; |
| | | |
| | |
| | | } |
| | | |
| | | @Nested |
| | | @Accepts({"CoopAssetTransaction:R(Read)"}) |
| | | @Accepts({ "CoopAssetTransaction:R(Read)" }) |
| | | class GetCoopAssetTransaction { |
| | | |
| | | @Test |
| | | void globalAdmin_withoutAssumedRole_canGetArbitraryCoopAssetTransaction() { |
| | | context.define("superuser-alex@hostsharing.net"); |
| | | final var givenCoopAssetTransactionUuid = coopAssetsTransactionRepo.findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange(null, LocalDate.of(2010, 3, 15), LocalDate.of(2010, 3, 15)).get(0).getUuid(); |
| | | final var givenCoopAssetTransactionUuid = coopAssetsTransactionRepo.findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange( |
| | | null, |
| | | LocalDate.of(2010, 3, 15), |
| | | LocalDate.of(2010, 3, 15)).get(0).getUuid(); |
| | | |
| | | RestAssured // @formatter:off |
| | | .given().header("current-user", "superuser-alex@hostsharing.net").port(port).when().get("http://localhost/api/hs/office/coopassetstransactions/" + givenCoopAssetTransactionUuid).then().log().body().assertThat().statusCode(200).contentType("application/json").body("", lenientlyEquals(""" |
| | | .given().header("current-user", "superuser-alex@hostsharing.net") |
| | | .port(port) |
| | | .when() |
| | | .get("http://localhost/api/hs/office/coopassetstransactions/" + givenCoopAssetTransactionUuid) |
| | | .then().log().body().assertThat() |
| | | .statusCode(200) |
| | | .contentType("application/json") |
| | | .body("", lenientlyEquals(""" |
| | | { |
| | | "transactionType": "DEPOSIT" |
| | | } |
| | |
| | | } |
| | | |
| | | @Test |
| | | @Accepts({"CoopAssetTransaction:X(Access Control)"}) |
| | | @Accepts({ "CoopAssetTransaction:X(Access Control)" }) |
| | | void normalUser_canNotGetUnrelatedCoopAssetTransaction() { |
| | | context.define("superuser-alex@hostsharing.net"); |
| | | final var givenCoopAssetTransactionUuid = coopAssetsTransactionRepo.findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange(null, LocalDate.of(2010, 3, 15), LocalDate.of(2010, 3, 15)).get(0).getUuid(); |
| | | final var givenCoopAssetTransactionUuid = coopAssetsTransactionRepo.findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange( |
| | | null, |
| | | LocalDate.of(2010, 3, 15), |
| | | LocalDate.of(2010, 3, 15)).get(0).getUuid(); |
| | | |
| | | RestAssured // @formatter:off |
| | | .given().header("current-user", "selfregistered-user-drew@hostsharing.org").port(port).when().get("http://localhost/api/hs/office/coopassetstransactions/" + givenCoopAssetTransactionUuid).then().log().body().assertThat().statusCode(404); // @formatter:on |
| | | .given().header("current-user", "selfregistered-user-drew@hostsharing.org") |
| | | .port(port) |
| | | .when() |
| | | .get("http://localhost/api/hs/office/coopassetstransactions/" + givenCoopAssetTransactionUuid) |
| | | .then().log().body().assertThat() |
| | | .statusCode(404); // @formatter:on |
| | | } |
| | | |
| | | @Test |
| | | @Accepts({"CoopAssetTransaction:X(Access Control)"}) |
| | | @Accepts({ "CoopAssetTransaction:X(Access Control)" }) |
| | | void contactAdminUser_canGetRelatedCoopAssetTransaction() { |
| | | context.define("superuser-alex@hostsharing.net"); |
| | | final var givenCoopAssetTransactionUuid = coopAssetsTransactionRepo.findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange(null, LocalDate.of(2010, 3, 15), LocalDate.of(2010, 3, 15)).get(0).getUuid(); |
| | | final var givenCoopAssetTransactionUuid = coopAssetsTransactionRepo.findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange( |
| | | null, |
| | | LocalDate.of(2010, 3, 15), |
| | | LocalDate.of(2010, 3, 15)).get(0).getUuid(); |
| | | |
| | | RestAssured // @formatter:off |
| | | .given().header("current-user", "contact-admin@firstcontact.example.com").port(port).when().get("http://localhost/api/hs/office/coopassetstransactions/" + givenCoopAssetTransactionUuid).then().log().body().assertThat().statusCode(200).contentType("application/json").body("", lenientlyEquals(""" |
| | | .given() |
| | | .header("current-user", "contact-admin@firstcontact.example.com") |
| | | .port(port) |
| | | .when() |
| | | .get("http://localhost/api/hs/office/coopassetstransactions/" + givenCoopAssetTransactionUuid) |
| | | .then().log().body().assertThat() |
| | | .statusCode(200) |
| | | .contentType("application/json") |
| | | .body("", lenientlyEquals(""" |
| | | { |
| | | "transactionType": "DEPOSIT", |
| | | "assetValue": 320 |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; |
| | | import org.springframework.boot.test.mock.mockito.MockBean; |
| | | import org.springframework.context.annotation.ComponentScan; |
| | | import org.springframework.context.annotation.Import; |
| | | import org.springframework.test.annotation.DirtiesContext; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.grantDisplaysOf; |
| | | import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.roleNamesOf; |
| | |
| | | |
| | | import io.restassured.RestAssured; |
| | | import io.restassured.http.ContentType; |
| | | import net.hostsharing.test.Accepts; |
| | | import net.hostsharing.hsadminng.HsadminNgApplication; |
| | | import net.hostsharing.hsadminng.context.Context; |
| | | import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipRepository; |
| | | import net.hostsharing.test.Accepts; |
| | | import net.hostsharing.test.JpaAttempt; |
| | | import org.junit.jupiter.api.AfterEach; |
| | | import org.junit.jupiter.api.BeforeEach; |
| | |
| | | import org.springframework.boot.test.web.server.LocalServerPort; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import java.time.LocalDate; |
| | | import java.util.UUID; |
| | | |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; |
| | | import org.springframework.boot.test.mock.mockito.MockBean; |
| | | import org.springframework.context.annotation.ComponentScan; |
| | | import org.springframework.context.annotation.Import; |
| | | import org.springframework.test.annotation.DirtiesContext; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import java.time.LocalDate; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.grantDisplaysOf; |
| | | import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.roleNamesOf; |
| | |
| | | import org.springframework.boot.test.web.server.LocalServerPort; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import java.util.UUID; |
| | | |
| | | import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid; |
| | |
| | | package net.hostsharing.hsadminng.hs.office.debitor; |
| | | |
| | | import net.hostsharing.test.PatchUnitTestBase; |
| | | import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorPatchResource; |
| | | import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity; |
| | | import net.hostsharing.test.PatchUnitTestBase; |
| | | import org.junit.jupiter.api.BeforeEach; |
| | | import org.junit.jupiter.api.TestInstance; |
| | | import org.junit.jupiter.api.extension.ExtendWith; |
| | | import org.mockito.Mock; |
| | | import org.mockito.junit.jupiter.MockitoExtension; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import jakarta.persistence.EntityManager; |
| | | import java.util.UUID; |
| | | import java.util.stream.Stream; |
| | | |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; |
| | | import org.springframework.boot.test.mock.mockito.MockBean; |
| | | import org.springframework.context.annotation.ComponentScan; |
| | | import org.springframework.context.annotation.Import; |
| | | import org.springframework.orm.jpa.JpaSystemException; |
| | | import org.springframework.test.annotation.DirtiesContext; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.*; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import java.util.Arrays; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.grantDisplaysOf; |
| | | import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.roleNamesOf; |
| | |
| | | import org.springframework.boot.test.web.server.LocalServerPort; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import java.time.LocalDate; |
| | | import java.util.UUID; |
| | | |
| | |
| | | import net.hostsharing.hsadminng.mapper.Mapper; |
| | | import org.junit.jupiter.api.BeforeEach; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.junit.runner.RunWith; |
| | | import org.mockito.Mock; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestEntityManager; |
| | | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; |
| | | import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; |
| | | import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; |
| | | import org.springframework.boot.test.mock.mockito.MockBean; |
| | | import org.springframework.context.annotation.Import; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.test.context.junit4.SpringRunner; |
| | | import org.springframework.test.web.servlet.MockMvc; |
| | | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.EntityManagerFactory; |
| | | import javax.persistence.SynchronizationType; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.EntityManagerFactory; |
| | | import jakarta.persistence.SynchronizationType; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | |
| | | import org.junit.jupiter.api.extension.ExtendWith; |
| | | import org.mockito.Mock; |
| | | import org.mockito.junit.jupiter.MockitoExtension; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import jakarta.persistence.EntityManager; |
| | | import java.time.LocalDate; |
| | | import java.util.UUID; |
| | | import java.util.stream.Stream; |
| | |
| | | import com.vladmihalcea.hibernate.type.range.Range; |
| | | import org.junit.jupiter.api.Test; |
| | | |
| | | import javax.persistence.PrePersist; |
| | | import jakarta.persistence.PrePersist; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.time.LocalDate; |
| | | import java.util.Arrays; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; |
| | | import org.springframework.boot.test.mock.mockito.MockBean; |
| | | import org.springframework.context.annotation.ComponentScan; |
| | | import org.springframework.context.annotation.Import; |
| | | import org.springframework.orm.jpa.JpaSystemException; |
| | | import org.springframework.test.annotation.DirtiesContext; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.Arrays; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.grantDisplaysOf; |
| | | import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.roleNamesOf; |
| | |
| | | import org.springframework.boot.test.web.server.LocalServerPort; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import java.util.UUID; |
| | | |
| | | import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid; |
| | |
| | | package net.hostsharing.hsadminng.hs.office.partner; |
| | | |
| | | import net.hostsharing.test.PatchUnitTestBase; |
| | | import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerDetailsPatchResource; |
| | | import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; |
| | | import net.hostsharing.test.PatchUnitTestBase; |
| | | import org.junit.jupiter.api.BeforeEach; |
| | | import org.junit.jupiter.api.TestInstance; |
| | | import org.junit.jupiter.api.extension.ExtendWith; |
| | | import org.mockito.Mock; |
| | | import org.mockito.junit.jupiter.MockitoExtension; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import jakarta.persistence.EntityManager; |
| | | import java.time.LocalDate; |
| | | import java.util.UUID; |
| | | import java.util.stream.Stream; |
| | |
| | | package net.hostsharing.hsadminng.hs.office.partner; |
| | | |
| | | import net.hostsharing.test.PatchUnitTestBase; |
| | | import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerPatchResource; |
| | | import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; |
| | | import net.hostsharing.test.PatchUnitTestBase; |
| | | import org.junit.jupiter.api.BeforeEach; |
| | | import org.junit.jupiter.api.TestInstance; |
| | | import org.junit.jupiter.api.extension.ExtendWith; |
| | | import org.mockito.Mock; |
| | | import org.mockito.junit.jupiter.MockitoExtension; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import jakarta.persistence.EntityManager; |
| | | import java.util.UUID; |
| | | import java.util.stream.Stream; |
| | | |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; |
| | | import org.springframework.boot.test.mock.mockito.MockBean; |
| | | import org.springframework.context.annotation.ComponentScan; |
| | | import org.springframework.context.annotation.Import; |
| | | import org.springframework.orm.jpa.JpaSystemException; |
| | | import org.springframework.test.annotation.DirtiesContext; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.*; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import java.util.Arrays; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.grantDisplaysOf; |
| | | import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.roleNamesOf; |
| | |
| | | import org.springframework.boot.test.web.server.LocalServerPort; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import java.util.UUID; |
| | | |
| | | import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; |
| | | import org.springframework.boot.test.mock.mockito.MockBean; |
| | | import org.springframework.context.annotation.ComponentScan; |
| | | import org.springframework.context.annotation.Import; |
| | | import org.springframework.test.annotation.DirtiesContext; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.function.Supplier; |
| | |
| | | package net.hostsharing.hsadminng.hs.office.relationship; |
| | | |
| | | import net.hostsharing.test.PatchUnitTestBase; |
| | | import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity; |
| | | import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeRelationshipPatchResource; |
| | | import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; |
| | | import net.hostsharing.test.PatchUnitTestBase; |
| | | import org.junit.jupiter.api.BeforeEach; |
| | | import org.junit.jupiter.api.TestInstance; |
| | | import org.junit.jupiter.api.extension.ExtendWith; |
| | | import org.mockito.Mock; |
| | | import org.mockito.junit.jupiter.MockitoExtension; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import jakarta.persistence.EntityManager; |
| | | import java.util.UUID; |
| | | import java.util.stream.Stream; |
| | | |
| | |
| | | import org.springframework.context.annotation.Import; |
| | | import org.springframework.orm.jpa.JpaSystemException; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.*; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import java.util.Arrays; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.grantDisplaysOf; |
| | | import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.roleNamesOf; |
| | |
| | | import org.springframework.boot.test.web.server.LocalServerPort; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import java.time.LocalDate; |
| | | import java.util.UUID; |
| | | |
| | |
| | | import org.mockito.Mock; |
| | | import org.mockito.junit.jupiter.MockitoExtension; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import jakarta.persistence.EntityManager; |
| | | import java.time.LocalDate; |
| | | import java.util.UUID; |
| | | import java.util.stream.Stream; |
| | |
| | | import org.springframework.orm.jpa.JpaSystemException; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import java.time.LocalDate; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.springframework.data.annotation.Immutable; |
| | | |
| | | import javax.persistence.*; |
| | | import jakarta.persistence.Column; |
| | | import jakarta.persistence.Entity; |
| | | import jakarta.persistence.Id; |
| | | import jakarta.persistence.Table; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | import java.util.stream.Collectors; |
| | |
| | | import io.restassured.RestAssured; |
| | | import io.restassured.http.ContentType; |
| | | import io.restassured.response.ValidatableResponse; |
| | | import net.hostsharing.test.Accepts; |
| | | import net.hostsharing.hsadminng.HsadminNgApplication; |
| | | import net.hostsharing.hsadminng.context.ContextBasedTest; |
| | | import net.hostsharing.hsadminng.rbac.rbacrole.RbacRoleEntity; |
| | | import net.hostsharing.hsadminng.rbac.rbacrole.RbacRoleRepository; |
| | | import net.hostsharing.hsadminng.rbac.rbacuser.RbacUserEntity; |
| | | import net.hostsharing.hsadminng.rbac.rbacuser.RbacUserRepository; |
| | | import net.hostsharing.test.Accepts; |
| | | import net.hostsharing.test.JpaAttempt; |
| | | import org.apache.commons.lang3.RandomStringUtils; |
| | | import org.junit.jupiter.api.Nested; |
| | |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | |
| | | package net.hostsharing.hsadminng.rbac.rbacgrant; |
| | | |
| | | import net.hostsharing.test.Accepts; |
| | | import net.hostsharing.hsadminng.context.Context; |
| | | import net.hostsharing.hsadminng.context.ContextBasedTest; |
| | | import net.hostsharing.hsadminng.rbac.rbacrole.RbacRoleRepository; |
| | | import net.hostsharing.hsadminng.rbac.rbacuser.RbacUserEntity; |
| | | import net.hostsharing.hsadminng.rbac.rbacuser.RbacUserRepository; |
| | | import net.hostsharing.test.Accepts; |
| | | import net.hostsharing.test.JpaAttempt; |
| | | import org.junit.jupiter.api.Nested; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; |
| | | import org.springframework.boot.test.mock.mockito.MockBean; |
| | | import org.springframework.context.annotation.ComponentScan; |
| | | import org.springframework.context.annotation.Import; |
| | | import org.springframework.orm.jpa.JpaSystemException; |
| | | import org.springframework.test.annotation.DirtiesContext; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.springframework.data.annotation.Immutable; |
| | | |
| | | import javax.persistence.*; |
| | | import jakarta.persistence.*; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | import java.util.stream.Collectors; |
| | |
| | | package net.hostsharing.hsadminng.rbac.rbacrole; |
| | | |
| | | import io.restassured.RestAssured; |
| | | import net.hostsharing.test.Accepts; |
| | | import net.hostsharing.hsadminng.HsadminNgApplication; |
| | | import net.hostsharing.hsadminng.context.Context; |
| | | import net.hostsharing.hsadminng.rbac.rbacuser.RbacUserRepository; |
| | | import net.hostsharing.test.Accepts; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | import org.springframework.boot.test.web.server.LocalServerPort; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | |
| | | import static org.hamcrest.Matchers.*; |
| | | |
| | |
| | | import org.springframework.test.web.servlet.MockMvc; |
| | | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.EntityManagerFactory; |
| | | import javax.persistence.SynchronizationType; |
| | | |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.EntityManagerFactory; |
| | | import jakarta.persistence.SynchronizationType; |
| | | import java.util.Map; |
| | | |
| | | import static java.util.Arrays.asList; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; |
| | | import org.springframework.boot.test.mock.mockito.MockBean; |
| | | import org.springframework.context.annotation.ComponentScan; |
| | | import org.springframework.context.annotation.Import; |
| | | import org.springframework.orm.jpa.JpaSystemException; |
| | | import org.springframework.test.annotation.DirtiesContext; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | | |
| | | import static net.hostsharing.test.JpaAttempt.attempt; |
| | |
| | | |
| | | import io.restassured.RestAssured; |
| | | import io.restassured.http.ContentType; |
| | | import net.hostsharing.test.Accepts; |
| | | import net.hostsharing.hsadminng.HsadminNgApplication; |
| | | import net.hostsharing.hsadminng.context.Context; |
| | | import net.hostsharing.test.Accepts; |
| | | import net.hostsharing.test.JpaAttempt; |
| | | import org.junit.jupiter.api.Nested; |
| | | import org.junit.jupiter.api.Test; |
| | |
| | | import org.springframework.boot.test.web.server.LocalServerPort; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import java.util.UUID; |
| | | |
| | | import static org.assertj.core.api.Assertions.assertThat; |
| | |
| | | import org.springframework.test.web.servlet.MockMvc; |
| | | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.EntityManagerFactory; |
| | | import javax.persistence.SynchronizationType; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.EntityManagerFactory; |
| | | import jakarta.persistence.SynchronizationType; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; |
| | | import org.springframework.boot.test.mock.mockito.MockBean; |
| | | import org.springframework.context.annotation.ComponentScan; |
| | | import org.springframework.context.annotation.Import; |
| | | import org.springframework.orm.jpa.JpaSystemException; |
| | | import org.springframework.test.annotation.DirtiesContext; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | |
| | | import org.springframework.boot.test.web.server.LocalServerPort; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import java.util.UUID; |
| | | |
| | | import static org.assertj.core.api.Assertions.assertThat; |
| | |
| | | import org.springframework.boot.test.mock.mockito.MockBean; |
| | | import org.springframework.context.annotation.Import; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import javax.persistence.PersistenceException; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import jakarta.persistence.PersistenceException; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | |
| | | package net.hostsharing.hsadminng.test.pac; |
| | | |
| | | import net.hostsharing.hsadminng.context.Context; |
| | | import net.hostsharing.hsadminng.test.cust.TestCustomerRepository; |
| | | import net.hostsharing.test.JpaAttempt; |
| | | import org.junit.jupiter.api.Nested; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; |
| | | import org.springframework.boot.test.mock.mockito.MockBean; |
| | | import org.springframework.context.annotation.ComponentScan; |
| | | import org.springframework.context.annotation.Import; |
| | | import org.springframework.orm.ObjectOptimisticLockingFailureException; |
| | | import org.springframework.test.annotation.DirtiesContext; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.PersistenceContext; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.PersistenceContext; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | | |
| | | import static org.assertj.core.api.Assertions.assertThat; |
| | |
| | | import org.springframework.transaction.TransactionDefinition; |
| | | import org.springframework.transaction.support.TransactionTemplate; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import jakarta.persistence.EntityManager; |
| | | import java.util.Optional; |
| | | import java.util.function.Supplier; |
| | | |
| | |
| | | import org.mockito.Mock; |
| | | import org.mockito.junit.jupiter.MockitoExtension; |
| | | |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.ManyToOne; |
| | | import javax.validation.ValidationException; |
| | | import jakarta.persistence.EntityManager; |
| | | import jakarta.persistence.ManyToOne; |
| | | import jakarta.validation.ValidationException; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | |
| | | |
| | | import lombok.experimental.UtilityClass; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import java.util.Map; |
| | | |
| | | import static liquibase.repackaged.org.apache.commons.text.StringSubstitutor.replace; |
| | | import static org.apache.commons.lang3.StringUtils.stripEnd; |
| | | import static org.apache.commons.text.StringSubstitutor.replace; |
| | | |
| | | @UtilityClass |
| | | public class StringTemplater { |