From 8731f4a7b202ed04ee1b3cfbd812ef22cc53cb63 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 31 Aug 2022 15:44:06 +0200 Subject: [PATCH] migrate hs-api to test-api --- README.md | 6 ++--- .../test/cust/TestCustomerController.java | 18 ++++++------- .../hsadminng/test/pac/PackageRepository.java | 17 ------------ ...roller.java => TestPackageController.java} | 26 +++++++++---------- ...kageEntity.java => TestPackageEntity.java} | 2 +- .../test/pac/TestPackageRepository.java | 17 ++++++++++++ src/main/resources/api-definition.yaml | 12 ++++----- ...chemas.yaml => test-customer-schemas.yaml} | 2 +- ...{hs-customers.yaml => test-customers.yaml} | 10 +++---- ...schemas.yaml => test-package-schemas.yaml} | 6 ++--- ...ages-uuid.yaml => test-packages-uuid.yaml} | 6 ++--- .../{hs-packages.yaml => test-packages.yaml} | 4 +-- src/main/resources/api-mappings.yaml | 3 +-- .../TestCustomerControllerAcceptanceTest.java | 16 ++++++------ .../hsadminng/test/pac/TestPackage.java | 10 +++---- ... TestPackageControllerAcceptanceTest.java} | 18 ++++++------- ...TestPackageRepositoryIntegrationTest.java} | 26 +++++++++---------- 17 files changed, 99 insertions(+), 100 deletions(-) delete mode 100644 src/main/java/net/hostsharing/hsadminng/test/pac/PackageRepository.java rename src/main/java/net/hostsharing/hsadminng/test/pac/{PackageController.java => TestPackageController.java} (56%) rename src/main/java/net/hostsharing/hsadminng/test/pac/{PackageEntity.java => TestPackageEntity.java} (94%) create mode 100644 src/main/java/net/hostsharing/hsadminng/test/pac/TestPackageRepository.java rename src/main/resources/api-definition/{hs-customer-schemas.yaml => test-customer-schemas.yaml} (94%) rename src/main/resources/api-definition/{hs-customers.yaml => test-customers.yaml} (82%) rename src/main/resources/api-definition/{hs-package-schemas.yaml => test-package-schemas.yaml} (77%) rename src/main/resources/api-definition/{hs-packages-uuid.yaml => test-packages-uuid.yaml} (77%) rename src/main/resources/api-definition/{hs-packages.yaml => test-packages.yaml} (84%) rename src/test/java/net/hostsharing/hsadminng/test/pac/{PackageControllerAcceptanceTest.java => TestPackageControllerAcceptanceTest.java} (89%) rename src/test/java/net/hostsharing/hsadminng/test/pac/{PackageRepositoryIntegrationTest.java => TestPackageRepositoryIntegrationTest.java} (81%) diff --git a/README.md b/README.md index a46a9905..f6c7c481 100644 --- a/README.md +++ b/README.md @@ -66,18 +66,18 @@ If you have at least Docker, the Java JDK and Gradle installed in appropriate ve # the following command should return a JSON array with just all customers: curl \ -H 'current-user: mike@example.org' \ - http://localhost:8080/api/customers + http://localhost:8080/api/test-customers # the following command should return a JSON array with just all packages visible for the admin of the customer yyy: curl \ -H 'current-user: mike@example.org' -H 'assumed-roles: test_customer#yyy.admin' \ - http://localhost:8080/api/packages + http://localhost:8080/api/test-packages # add a new customer curl \ -H 'current-user: mike@example.org' -H "Content-Type: application/json" \ -d '{ "prefix":"ttt", "reference":80001, "adminUserName":"admin@ttt.example.com" }' \ - -X POST http://localhost:8080/api/customers + -X POST http://localhost:8080/api/test-customers If you wonder who 'mike@example.org' and 'sven@example.org' are and where the data comes from: Mike and Sven are just example global admin accounts as part of the example data which is automatically inserted in Testcontainers and Development environments. diff --git a/src/main/java/net/hostsharing/hsadminng/test/cust/TestCustomerController.java b/src/main/java/net/hostsharing/hsadminng/test/cust/TestCustomerController.java index 85fe469b..deb2ca3c 100644 --- a/src/main/java/net/hostsharing/hsadminng/test/cust/TestCustomerController.java +++ b/src/main/java/net/hostsharing/hsadminng/test/cust/TestCustomerController.java @@ -1,8 +1,8 @@ package net.hostsharing.hsadminng.test.cust; import net.hostsharing.hsadminng.context.Context; -import net.hostsharing.hsadminng.generated.api.v1.api.CustomersApi; -import net.hostsharing.hsadminng.generated.api.v1.model.CustomerResource; +import net.hostsharing.hsadminng.generated.api.v1.api.TestCustomersApi; +import net.hostsharing.hsadminng.generated.api.v1.model.TestCustomerResource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.transaction.annotation.Transactional; @@ -17,7 +17,7 @@ import static net.hostsharing.hsadminng.Mapper.mapList; @RestController -public class TestCustomerController implements CustomersApi { +public class TestCustomerController implements TestCustomersApi { @Autowired private Context context; @@ -27,7 +27,7 @@ public class TestCustomerController implements CustomersApi { @Override @Transactional(readOnly = true) - public ResponseEntity> listCustomers( + public ResponseEntity> listCustomers( String currentUser, String assumedRoles, String prefix @@ -36,15 +36,15 @@ public class TestCustomerController implements CustomersApi { final var result = testCustomerRepository.findCustomerByOptionalPrefixLike(prefix); - return ResponseEntity.ok(mapList(result, CustomerResource.class)); + return ResponseEntity.ok(mapList(result, TestCustomerResource.class)); } @Override @Transactional - public ResponseEntity addCustomer( + public ResponseEntity addCustomer( final String currentUser, final String assumedRoles, - final CustomerResource customer) { + final TestCustomerResource customer) { context.define(currentUser, assumedRoles); @@ -56,10 +56,10 @@ public class TestCustomerController implements CustomersApi { final var uri = MvcUriComponentsBuilder.fromController(getClass()) - .path("/api/customers/{id}") + .path("/api/test-customers/{id}") .buildAndExpand(customer.getUuid()) .toUri(); - return ResponseEntity.created(uri).body(map(saved, CustomerResource.class)); + return ResponseEntity.created(uri).body(map(saved, TestCustomerResource.class)); } } diff --git a/src/main/java/net/hostsharing/hsadminng/test/pac/PackageRepository.java b/src/main/java/net/hostsharing/hsadminng/test/pac/PackageRepository.java deleted file mode 100644 index 7e3f1e63..00000000 --- a/src/main/java/net/hostsharing/hsadminng/test/pac/PackageRepository.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.hostsharing.hsadminng.test.pac; - -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.Repository; - -import java.util.List; -import java.util.UUID; - -public interface PackageRepository extends Repository { - - @Query("SELECT p FROM PackageEntity p WHERE :name is null or p.name like concat(:name, '%')") - List findAllByOptionalNameLike(final String name); - - PackageEntity findByUuid(UUID packageUuid); - - PackageEntity save(PackageEntity current); -} diff --git a/src/main/java/net/hostsharing/hsadminng/test/pac/PackageController.java b/src/main/java/net/hostsharing/hsadminng/test/pac/TestPackageController.java similarity index 56% rename from src/main/java/net/hostsharing/hsadminng/test/pac/PackageController.java rename to src/main/java/net/hostsharing/hsadminng/test/pac/TestPackageController.java index d86a13c3..d625a4f9 100644 --- a/src/main/java/net/hostsharing/hsadminng/test/pac/PackageController.java +++ b/src/main/java/net/hostsharing/hsadminng/test/pac/TestPackageController.java @@ -2,9 +2,9 @@ package net.hostsharing.hsadminng.test.pac; import net.hostsharing.hsadminng.OptionalFromJson; import net.hostsharing.hsadminng.context.Context; -import net.hostsharing.hsadminng.generated.api.v1.api.PackagesApi; -import net.hostsharing.hsadminng.generated.api.v1.model.PackageResource; -import net.hostsharing.hsadminng.generated.api.v1.model.PackageUpdateResource; +import net.hostsharing.hsadminng.generated.api.v1.api.TestPackagesApi; +import net.hostsharing.hsadminng.generated.api.v1.model.TestPackageResource; +import net.hostsharing.hsadminng.generated.api.v1.model.TestPackageUpdateResource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.transaction.annotation.Transactional; @@ -17,41 +17,41 @@ import static net.hostsharing.hsadminng.Mapper.map; import static net.hostsharing.hsadminng.Mapper.mapList; @RestController -public class PackageController implements PackagesApi { +public class TestPackageController implements TestPackagesApi { @Autowired private Context context; @Autowired - private PackageRepository packageRepository; + private TestPackageRepository testPackageRepository; @Override @Transactional(readOnly = true) - public ResponseEntity> listPackages( + public ResponseEntity> listPackages( String currentUser, String assumedRoles, String name ) { context.define(currentUser, assumedRoles); - final var result = packageRepository.findAllByOptionalNameLike(name); - return ResponseEntity.ok(mapList(result, PackageResource.class)); + final var result = testPackageRepository.findAllByOptionalNameLike(name); + return ResponseEntity.ok(mapList(result, TestPackageResource.class)); } @Override @Transactional - public ResponseEntity updatePackage( + public ResponseEntity updatePackage( final String currentUser, final String assumedRoles, final UUID packageUuid, - final PackageUpdateResource body) { + final TestPackageUpdateResource body) { context.define(currentUser, assumedRoles); - final var current = packageRepository.findByUuid(packageUuid); + final var current = testPackageRepository.findByUuid(packageUuid); OptionalFromJson.of(body.getDescription()).ifPresent(current::setDescription); - final var saved = packageRepository.save(current); - final var mapped = map(saved, PackageResource.class); + final var saved = testPackageRepository.save(current); + final var mapped = map(saved, TestPackageResource.class); return ResponseEntity.ok(mapped); } } diff --git a/src/main/java/net/hostsharing/hsadminng/test/pac/PackageEntity.java b/src/main/java/net/hostsharing/hsadminng/test/pac/TestPackageEntity.java similarity index 94% rename from src/main/java/net/hostsharing/hsadminng/test/pac/PackageEntity.java rename to src/main/java/net/hostsharing/hsadminng/test/pac/TestPackageEntity.java index b07062ae..a33ecca3 100644 --- a/src/main/java/net/hostsharing/hsadminng/test/pac/PackageEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/test/pac/TestPackageEntity.java @@ -15,7 +15,7 @@ import java.util.UUID; @Setter @NoArgsConstructor @AllArgsConstructor -public class PackageEntity { +public class TestPackageEntity { private @Id UUID uuid; diff --git a/src/main/java/net/hostsharing/hsadminng/test/pac/TestPackageRepository.java b/src/main/java/net/hostsharing/hsadminng/test/pac/TestPackageRepository.java new file mode 100644 index 00000000..610d8fdc --- /dev/null +++ b/src/main/java/net/hostsharing/hsadminng/test/pac/TestPackageRepository.java @@ -0,0 +1,17 @@ +package net.hostsharing.hsadminng.test.pac; + +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.Repository; + +import java.util.List; +import java.util.UUID; + +public interface TestPackageRepository extends Repository { + + @Query("SELECT p FROM TestPackageEntity p WHERE :name is null or p.name like concat(:name, '%')") + List findAllByOptionalNameLike(final String name); + + TestPackageEntity findByUuid(UUID packageUuid); + + TestPackageEntity save(TestPackageEntity current); +} diff --git a/src/main/resources/api-definition.yaml b/src/main/resources/api-definition.yaml index d2f43735..90373ea7 100644 --- a/src/main/resources/api-definition.yaml +++ b/src/main/resources/api-definition.yaml @@ -30,14 +30,14 @@ paths: # HS - /api/customers: - $ref: "./api-definition/hs-customers.yaml" + /api/test-customers: + $ref: "./api-definition/test-customers.yaml" - /api/packages: - $ref: "./api-definition/hs-packages.yaml" + /api/test-packages: + $ref: "./api-definition/test-packages.yaml" - /api/packages/{packageUUID}: - $ref: "./api-definition/hs-packages-uuid.yaml" + /api/test-packages/{packageUUID}: + $ref: "./api-definition/test-packages-uuid.yaml" # Other diff --git a/src/main/resources/api-definition/hs-customer-schemas.yaml b/src/main/resources/api-definition/test-customer-schemas.yaml similarity index 94% rename from src/main/resources/api-definition/hs-customer-schemas.yaml rename to src/main/resources/api-definition/test-customer-schemas.yaml index 63d662bf..3e51b749 100644 --- a/src/main/resources/api-definition/hs-customer-schemas.yaml +++ b/src/main/resources/api-definition/test-customer-schemas.yaml @@ -3,7 +3,7 @@ components: schemas: - Customer: + TestCustomer: type: object properties: uuid: diff --git a/src/main/resources/api-definition/hs-customers.yaml b/src/main/resources/api-definition/test-customers.yaml similarity index 82% rename from src/main/resources/api-definition/hs-customers.yaml rename to src/main/resources/api-definition/test-customers.yaml index 5895e41a..f9570b42 100644 --- a/src/main/resources/api-definition/hs-customers.yaml +++ b/src/main/resources/api-definition/test-customers.yaml @@ -2,7 +2,7 @@ get: summary: Returns a list of (optionally filtered) customers. description: Returns the list of (optionally filtered) customers which are visible to the current user or any of it's assumed roles. tags: - - customers + - testCustomers operationId: listCustomers parameters: - $ref: './api-definition/auth.yaml#/components/parameters/currentUser' @@ -21,7 +21,7 @@ get: schema: type: array items: - $ref: './api-definition/hs-customer-schemas.yaml#/components/schemas/Customer' + $ref: './api-definition/test-customer-schemas.yaml#/components/schemas/TestCustomer' "401": $ref: './api-definition/error-responses.yaml#/components/responses/Unauthorized' "403": @@ -30,7 +30,7 @@ get: post: summary: Adds a new customer. tags: - - customers + - testCustomers operationId: addCustomer parameters: - $ref: './api-definition/auth.yaml#/components/parameters/currentUser' @@ -39,7 +39,7 @@ post: content: 'application/json': schema: - $ref: './api-definition/api-definition/hs-customer-schemas.yaml#/components/schemas/Customer' + $ref: './api-definition/api-definition/test-customer-schemas.yaml#/components/schemas/TestCustomer' required: true responses: "201": @@ -47,7 +47,7 @@ post: content: 'application/json': schema: - $ref: './api-definition/hs-customer-schemas.yaml#/components/schemas/Customer' + $ref: './api-definition/test-customer-schemas.yaml#/components/schemas/TestCustomer' "401": $ref: './api-definition/error-responses.yaml#/components/responses/Unauthorized' "403": diff --git a/src/main/resources/api-definition/hs-package-schemas.yaml b/src/main/resources/api-definition/test-package-schemas.yaml similarity index 77% rename from src/main/resources/api-definition/hs-package-schemas.yaml rename to src/main/resources/api-definition/test-package-schemas.yaml index 92b0c4ed..913c6b05 100644 --- a/src/main/resources/api-definition/hs-package-schemas.yaml +++ b/src/main/resources/api-definition/test-package-schemas.yaml @@ -3,20 +3,20 @@ components: schemas: - Package: + TestPackage: type: object properties: uuid: type: string format: uuid customer: - $ref: './api-definition/hs-customer-schemas.yaml#/components/schemas/Customer' + $ref: './api-definition/test-customer-schemas.yaml#/components/schemas/TestCustomer' name: type: string description: type: string maxLength: 80 - PackageUpdate: + TestPackageUpdate: type: object properties: description: diff --git a/src/main/resources/api-definition/hs-packages-uuid.yaml b/src/main/resources/api-definition/test-packages-uuid.yaml similarity index 77% rename from src/main/resources/api-definition/hs-packages-uuid.yaml rename to src/main/resources/api-definition/test-packages-uuid.yaml index 269a9e45..ae3f0425 100644 --- a/src/main/resources/api-definition/hs-packages-uuid.yaml +++ b/src/main/resources/api-definition/test-packages-uuid.yaml @@ -1,6 +1,6 @@ patch: tags: - - packages + - testPackages operationId: updatePackage parameters: - $ref: './api-definition/auth.yaml#/components/parameters/currentUser' @@ -15,14 +15,14 @@ patch: content: 'application/json': schema: - $ref: './api-definition/hs-package-schemas.yaml#/components/schemas/PackageUpdate' + $ref: './api-definition/test-package-schemas.yaml#/components/schemas/TestPackageUpdate' responses: "200": description: OK content: 'application/json': schema: - $ref: './api-definition/hs-package-schemas.yaml#/components/schemas/Package' + $ref: './api-definition/test-package-schemas.yaml#/components/schemas/TestPackage' "401": $ref: './api-definition/error-responses.yaml#/components/responses/Unauthorized' "403": diff --git a/src/main/resources/api-definition/hs-packages.yaml b/src/main/resources/api-definition/test-packages.yaml similarity index 84% rename from src/main/resources/api-definition/hs-packages.yaml rename to src/main/resources/api-definition/test-packages.yaml index 1888ceb2..1671174b 100644 --- a/src/main/resources/api-definition/hs-packages.yaml +++ b/src/main/resources/api-definition/test-packages.yaml @@ -1,6 +1,6 @@ get: tags: - - packages + - testPackages operationId: listPackages parameters: - $ref: './api-definition/auth.yaml#/components/parameters/currentUser' @@ -18,7 +18,7 @@ get: schema: type: array items: - $ref: './api-definition/hs-package-schemas.yaml#/components/schemas/Package' + $ref: './api-definition/test-package-schemas.yaml#/components/schemas/TestPackage' "401": $ref: './api-definition/error-responses.yaml#/components/responses/Unauthorized' "403": diff --git a/src/main/resources/api-mappings.yaml b/src/main/resources/api-mappings.yaml index 260edebf..9e7539f5 100644 --- a/src/main/resources/api-mappings.yaml +++ b/src/main/resources/api-mappings.yaml @@ -7,11 +7,10 @@ options: map: result: org.springframework.http.ResponseEntity - types: - type: array => java.util.List - type: string:uuid => java.util.UUID paths: - /api/packages/{packageUUID}: + /api/test-packages/{packageUUID}: null: org.openapitools.jackson.nullable.JsonNullable diff --git a/src/test/java/net/hostsharing/hsadminng/test/cust/TestCustomerControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/test/cust/TestCustomerControllerAcceptanceTest.java index 920b4ab0..8f9950ad 100644 --- a/src/test/java/net/hostsharing/hsadminng/test/cust/TestCustomerControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/test/cust/TestCustomerControllerAcceptanceTest.java @@ -45,7 +45,7 @@ class TestCustomerControllerAcceptanceTest { .header("current-user", "mike@example.org") .port(port) .when() - .get("http://localhost/api/customers") + .get("http://localhost/api/test-customers") .then().assertThat() .statusCode(200) .contentType("application/json") @@ -63,7 +63,7 @@ class TestCustomerControllerAcceptanceTest { .header("current-user", "mike@example.org") .port(port) .when() - .get("http://localhost/api/customers?prefix=y") + .get("http://localhost/api/test-customers?prefix=y") .then().assertThat() .statusCode(200) .contentType("application/json") @@ -80,7 +80,7 @@ class TestCustomerControllerAcceptanceTest { .header("assumed-roles", "test_customer#yyy.admin") .port(port) .when() - .get("http://localhost/api/customers") + .get("http://localhost/api/test-customers") .then().assertThat() .statusCode(200) .contentType("application/json") @@ -96,7 +96,7 @@ class TestCustomerControllerAcceptanceTest { .header("current-user", "customer-admin@yyy.example.com") .port(port) .when() - .get("http://localhost/api/customers") + .get("http://localhost/api/test-customers") .then().assertThat() .statusCode(200) .contentType("application/json") @@ -125,7 +125,7 @@ class TestCustomerControllerAcceptanceTest { """) .port(port) .when() - .post("http://localhost/api/customers") + .post("http://localhost/api/test-customers") .then().assertThat() .statusCode(201) .contentType(ContentType.JSON) @@ -160,7 +160,7 @@ class TestCustomerControllerAcceptanceTest { """.formatted(givenUuid)) .port(port) .when() - .post("http://localhost/api/customers") + .post("http://localhost/api/test-customers") .then().assertThat() .statusCode(201) .contentType(ContentType.JSON) @@ -196,7 +196,7 @@ class TestCustomerControllerAcceptanceTest { """) .port(port) .when() - .post("http://localhost/api/customers") + .post("http://localhost/api/test-customers") .then().assertThat() .statusCode(403) .contentType(ContentType.JSON) @@ -225,7 +225,7 @@ class TestCustomerControllerAcceptanceTest { """) .port(port) .when() - .post("http://localhost/api/customers") + .post("http://localhost/api/test-customers") .then().assertThat() .statusCode(403) .contentType(ContentType.JSON) diff --git a/src/test/java/net/hostsharing/hsadminng/test/pac/TestPackage.java b/src/test/java/net/hostsharing/hsadminng/test/pac/TestPackage.java index accfc416..b97daeaa 100644 --- a/src/test/java/net/hostsharing/hsadminng/test/pac/TestPackage.java +++ b/src/test/java/net/hostsharing/hsadminng/test/pac/TestPackage.java @@ -7,11 +7,11 @@ import static java.util.UUID.randomUUID; public class TestPackage { - public static final PackageEntity xxx00 = hsPackage(TestCustomer.xxx, "xxx00"); - public static final PackageEntity xxx01 = hsPackage(TestCustomer.xxx, "xxx01"); - public static final PackageEntity xxx02 = hsPackage(TestCustomer.xxx, "xxx02"); + public static final TestPackageEntity xxx00 = hsPackage(TestCustomer.xxx, "xxx00"); + public static final TestPackageEntity xxx01 = hsPackage(TestCustomer.xxx, "xxx01"); + public static final TestPackageEntity xxx02 = hsPackage(TestCustomer.xxx, "xxx02"); - public static PackageEntity hsPackage(final TestCustomerEntity customer, final String name) { - return new PackageEntity(randomUUID(), 0, customer, name, "initial description of package " + name); + public static TestPackageEntity hsPackage(final TestCustomerEntity customer, final String name) { + return new TestPackageEntity(randomUUID(), 0, customer, name, "initial description of package " + name); } } diff --git a/src/test/java/net/hostsharing/hsadminng/test/pac/PackageControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/test/pac/TestPackageControllerAcceptanceTest.java similarity index 89% rename from src/test/java/net/hostsharing/hsadminng/test/pac/PackageControllerAcceptanceTest.java rename to src/test/java/net/hostsharing/hsadminng/test/pac/TestPackageControllerAcceptanceTest.java index a2d1ef51..42925a6a 100644 --- a/src/test/java/net/hostsharing/hsadminng/test/pac/PackageControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/test/pac/TestPackageControllerAcceptanceTest.java @@ -25,7 +25,7 @@ import static org.hamcrest.Matchers.is; classes = HsadminNgApplication.class ) @Transactional -class PackageControllerAcceptanceTest { +class TestPackageControllerAcceptanceTest { @LocalServerPort Integer port; @@ -33,7 +33,7 @@ class PackageControllerAcceptanceTest { Context context; @Autowired - PackageRepository packageRepository; + TestPackageRepository testPackageRepository; @Nested class ListPackages { @@ -47,7 +47,7 @@ class PackageControllerAcceptanceTest { .header("assumed-roles", "test_customer#xxx.admin") .port(port) .when() - .get("http://localhost/api/packages") + .get("http://localhost/api/test-packages") .then().assertThat() .statusCode(200) .contentType("application/json") @@ -69,7 +69,7 @@ class PackageControllerAcceptanceTest { .header("assumed-roles", "test_customer#xxx.admin") .port(port) .when() - .get("http://localhost/api/packages?name=xxx01") + .get("http://localhost/api/test-packages?name=xxx01") .then().assertThat() .statusCode(200) .contentType("application/json") @@ -103,7 +103,7 @@ class PackageControllerAcceptanceTest { """, randomDescription)) .port(port) .when() - .patch("http://localhost/api/packages/{uuidOfPackage}", getUuidOfPackage("xxx00")) + .patch("http://localhost/api/test-packages/{uuidOfPackage}", getUuidOfPackage("xxx00")) .then() .assertThat() .statusCode(200) @@ -133,7 +133,7 @@ class PackageControllerAcceptanceTest { """) .port(port) .when() - .patch("http://localhost/api/packages/{uuidOfPackage}", getUuidOfPackage("xxx01")) + .patch("http://localhost/api/test-packages/{uuidOfPackage}", getUuidOfPackage("xxx01")) .then() .assertThat() .statusCode(200) @@ -158,7 +158,7 @@ class PackageControllerAcceptanceTest { .body("{}") .port(port) .when() - .patch("http://localhost/api/packages/{uuidOfPackage}", getUuidOfPackage("xxx02")) + .patch("http://localhost/api/test-packages/{uuidOfPackage}", getUuidOfPackage("xxx02")) .then().assertThat() .statusCode(200) .contentType("application/json") @@ -176,7 +176,7 @@ class PackageControllerAcceptanceTest { .header("assumed-roles", "test_customer#xxx.admin") .port(port) .when() - .get("http://localhost/api/packages?name={packageName}", packageName) + .get("http://localhost/api/test-packages?name={packageName}", packageName) .then() .statusCode(200) .contentType("application/json") @@ -186,6 +186,6 @@ class PackageControllerAcceptanceTest { String getDescriptionOfPackage(final String packageName) { context.define("mike@example.org","test_customer#xxx.admin"); - return packageRepository.findAllByOptionalNameLike(packageName).get(0).getDescription(); + return testPackageRepository.findAllByOptionalNameLike(packageName).get(0).getDescription(); } } diff --git a/src/test/java/net/hostsharing/hsadminng/test/pac/PackageRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/test/pac/TestPackageRepositoryIntegrationTest.java similarity index 81% rename from src/test/java/net/hostsharing/hsadminng/test/pac/PackageRepositoryIntegrationTest.java rename to src/test/java/net/hostsharing/hsadminng/test/pac/TestPackageRepositoryIntegrationTest.java index c95702b5..1f52d66e 100644 --- a/src/test/java/net/hostsharing/hsadminng/test/pac/PackageRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/test/pac/TestPackageRepositoryIntegrationTest.java @@ -21,13 +21,13 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @ComponentScan(basePackageClasses = { Context.class, TestCustomerRepository.class, JpaAttempt.class }) @DirtiesContext -class PackageRepositoryIntegrationTest { +class TestPackageRepositoryIntegrationTest { @Autowired Context context; @Autowired - PackageRepository packageRepository; + TestPackageRepository testPackageRepository; @Autowired EntityManager em; @@ -47,7 +47,7 @@ class PackageRepositoryIntegrationTest { context.define("mike@example.org"); // when - final var result = packageRepository.findAllByOptionalNameLike(null); + final var result = testPackageRepository.findAllByOptionalNameLike(null); // then noPackagesAreReturned(result); @@ -59,7 +59,7 @@ class PackageRepositoryIntegrationTest { context.define("mike@example.org", "global#test-global.admin"); // when - final var result = packageRepository.findAllByOptionalNameLike(null); + final var result = testPackageRepository.findAllByOptionalNameLike(null); then: noPackagesAreReturned(result); @@ -71,7 +71,7 @@ class PackageRepositoryIntegrationTest { context.define("customer-admin@xxx.example.com"); // when: - final var result = packageRepository.findAllByOptionalNameLike(null); + final var result = testPackageRepository.findAllByOptionalNameLike(null); // then: exactlyThesePackagesAreReturned(result, "xxx00", "xxx01", "xxx02"); @@ -81,7 +81,7 @@ class PackageRepositoryIntegrationTest { public void customerAdmin_withAssumedOwnedPackageAdminRole_canViewOnlyItsOwnPackages() { context.define("customer-admin@xxx.example.com", "test_package#xxx00.admin"); - final var result = packageRepository.findAllByOptionalNameLike(null); + final var result = testPackageRepository.findAllByOptionalNameLike(null); exactlyThesePackagesAreReturned(result, "xxx00"); } @@ -94,18 +94,18 @@ class PackageRepositoryIntegrationTest { public void supportsOptimisticLocking() throws InterruptedException { // given testGlobalAdminWithAssumedRole("test_package#xxx00.admin"); - final var pac = packageRepository.findAllByOptionalNameLike("%").get(0); + final var pac = testPackageRepository.findAllByOptionalNameLike("%").get(0); // when final var result1 = jpaAttempt.transacted(() -> { testGlobalAdminWithAssumedRole("test_package#xxx00.admin"); pac.setDescription("description set by thread 1"); - packageRepository.save(pac); + testPackageRepository.save(pac); }); final var result2 = jpaAttempt.transacted(() -> { testGlobalAdminWithAssumedRole("test_package#xxx00.admin"); pac.setDescription("description set by thread 2"); - packageRepository.save(pac); + testPackageRepository.save(pac); sleep(1500); }); @@ -129,15 +129,15 @@ class PackageRepositoryIntegrationTest { context.define("mike@example.org", assumedRoles); } - void noPackagesAreReturned(final List actualResult) { + void noPackagesAreReturned(final List actualResult) { assertThat(actualResult) - .extracting(PackageEntity::getName) + .extracting(TestPackageEntity::getName) .isEmpty(); } - void exactlyThesePackagesAreReturned(final List actualResult, final String... packageNames) { + void exactlyThesePackagesAreReturned(final List actualResult, final String... packageNames) { assertThat(actualResult) - .extracting(PackageEntity::getName) + .extracting(TestPackageEntity::getName) .containsExactlyInAnyOrder(packageNames); }