refactoring packages, moving Hostsharing related entities etc. to hs package

This commit is contained in:
Michael Hoennig 2022-08-03 06:11:39 +02:00
parent 142aac2bce
commit bb05eb4ac4
14 changed files with 35 additions and 27 deletions

View File

@ -23,7 +23,7 @@ public class RestResponseEntityExceptionHandler
final RuntimeException exc, final WebRequest request) { final RuntimeException exc, final WebRequest request) {
return new ResponseEntity<>( return new ResponseEntity<>(
new CustomErrorResponse(exc, HttpStatus.CONFLICT), HttpStatus.CONFLICT); new CustomErrorResponse(request.getContextPath(), exc, HttpStatus.CONFLICT), HttpStatus.CONFLICT);
} }
@ExceptionHandler(JpaSystemException.class) @ExceptionHandler(JpaSystemException.class)
@ -31,7 +31,7 @@ public class RestResponseEntityExceptionHandler
final RuntimeException exc, final WebRequest request) { final RuntimeException exc, final WebRequest request) {
return new ResponseEntity<>( return new ResponseEntity<>(
new CustomErrorResponse(exc, HttpStatus.FORBIDDEN), HttpStatus.FORBIDDEN); new CustomErrorResponse(request.getContextPath(), exc, HttpStatus.FORBIDDEN), HttpStatus.FORBIDDEN);
} }
} }
@ -41,13 +41,19 @@ class CustomErrorResponse {
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd hh:mm:ss") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd hh:mm:ss")
private final LocalDateTime timestamp; private final LocalDateTime timestamp;
private final HttpStatus status; private final String path;
private final int status;
private final String error;
private final String message; private final String message;
public CustomErrorResponse(final RuntimeException exc, final HttpStatus status) { public CustomErrorResponse(final String path, final RuntimeException exc, final HttpStatus status) {
this.timestamp = LocalDateTime.now(); this.timestamp = LocalDateTime.now();
this.status = status; this.path = path;
this.status = status.value();
this.error = status.getReasonPhrase();
this.message = firstLine(NestedExceptionUtils.getMostSpecificCause(exc).getMessage()); this.message = firstLine(NestedExceptionUtils.getMostSpecificCause(exc).getMessage());
} }

View File

@ -1,4 +1,4 @@
package net.hostsharing.hsadminng.hscustomer; package net.hostsharing.hsadminng.hs.hscustomer;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;

View File

@ -1,4 +1,4 @@
package net.hostsharing.hsadminng.hscustomer; package net.hostsharing.hsadminng.hs.hscustomer;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;

View File

@ -1,4 +1,4 @@
package net.hostsharing.hsadminng.hscustomer; package net.hostsharing.hsadminng.hs.hscustomer;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;

View File

@ -1,4 +1,4 @@
package net.hostsharing.hsadminng.hspackage; package net.hostsharing.hsadminng.hs.hspackage;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;

View File

@ -1,9 +1,9 @@
package net.hostsharing.hsadminng.hspackage; package net.hostsharing.hsadminng.hs.hspackage;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import net.hostsharing.hsadminng.hscustomer.CustomerEntity; import net.hostsharing.hsadminng.hs.hscustomer.CustomerEntity;
import javax.persistence.*; import javax.persistence.*;
import java.util.UUID; import java.util.UUID;

View File

@ -1,4 +1,4 @@
package net.hostsharing.hsadminng.hspackage; package net.hostsharing.hsadminng.hs.hspackage;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;

View File

@ -39,16 +39,16 @@ public class ArchUnitTest {
@ArchTest @ArchTest
@SuppressWarnings("unused") @SuppressWarnings("unused")
public static final ArchRule hsPackagesRule = classes() public static final ArchRule hsPackagesRule = classes()
.that().resideInAPackage("..hs*") .that().resideInAPackage("..hs.(*)..")
.should().onlyBeAccessed().byClassesThat() .should().onlyBeAccessed().byClassesThat()
.resideInAnyPackage("..hs*"); .resideInAnyPackage("..hs.(*)..");
@ArchTest @ArchTest
@SuppressWarnings("unused") @SuppressWarnings("unused")
public static final ArchRule hsPackagePackageRule = classes() public static final ArchRule hsPackagePackageRule = classes()
.that().resideInAPackage("..hspackage..") .that().resideInAPackage("..hs.hspackage..")
.should().onlyBeAccessed().byClassesThat() .should().onlyBeAccessed().byClassesThat()
.resideInAnyPackage("..hspackage.."); .resideInAnyPackage("..hs.hspackage..");
@Test @Test
public void everythingShouldBeFreeOfCycles() { public void everythingShouldBeFreeOfCycles() {

View File

@ -1,4 +1,4 @@
package net.hostsharing.hsadminng.hscustomer; package net.hostsharing.hsadminng.hs.hscustomer;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,4 +1,4 @@
package net.hostsharing.hsadminng.hscustomer; package net.hostsharing.hsadminng.hs.hscustomer;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,8 @@
package net.hostsharing.hsadminng.hscustomer; package net.hostsharing.hsadminng.hs.hscustomer;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.hscustomer.CustomerEntity;
import net.hostsharing.hsadminng.hs.hscustomer.CustomerRepository;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;

View File

@ -1,4 +1,6 @@
package net.hostsharing.hsadminng.hscustomer; package net.hostsharing.hsadminng.hs.hscustomer;
import net.hostsharing.hsadminng.hs.hscustomer.CustomerEntity;
import static java.util.UUID.randomUUID; import static java.util.UUID.randomUUID;

View File

@ -1,7 +1,6 @@
package net.hostsharing.hsadminng.hspackage; package net.hostsharing.hsadminng.hs.hspackage;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hscustomer.TestCustomer;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
@ -10,8 +9,6 @@ import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import java.util.UUID;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;

View File

@ -1,7 +1,8 @@
package net.hostsharing.hsadminng.hspackage; package net.hostsharing.hsadminng.hs.hspackage;
import net.hostsharing.hsadminng.hscustomer.CustomerEntity; import net.hostsharing.hsadminng.hs.hscustomer.CustomerEntity;
import net.hostsharing.hsadminng.hscustomer.TestCustomer; import net.hostsharing.hsadminng.hs.hspackage.PackageEntity;
import net.hostsharing.hsadminng.hs.hscustomer.TestCustomer;
import static java.util.UUID.randomUUID; import static java.util.UUID.randomUUID;