migrate hs-api to test-api
This commit is contained in:
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
@ -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<PackageEntity> actualResult) {
|
||||
void noPackagesAreReturned(final List<TestPackageEntity> actualResult) {
|
||||
assertThat(actualResult)
|
||||
.extracting(PackageEntity::getName)
|
||||
.extracting(TestPackageEntity::getName)
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
void exactlyThesePackagesAreReturned(final List<PackageEntity> actualResult, final String... packageNames) {
|
||||
void exactlyThesePackagesAreReturned(final List<TestPackageEntity> actualResult, final String... packageNames) {
|
||||
assertThat(actualResult)
|
||||
.extracting(PackageEntity::getName)
|
||||
.extracting(TestPackageEntity::getName)
|
||||
.containsExactlyInAnyOrder(packageNames);
|
||||
}
|
||||
|
Reference in New Issue
Block a user