Compare commits
No commits in common. "cbf68f8657fa0647057a649dec4fd38a032510d5" and "e8b74ad1c0faf17aa6b74422e296da5391252f11" have entirely different histories.
cbf68f8657
...
e8b74ad1c0
@ -57,7 +57,7 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public ResponseEntity<HsOfficeCoopSharesTransactionResource> postCoopSharesTransaction(
|
public ResponseEntity<HsOfficeCoopSharesTransactionResource> addCoopSharesTransaction(
|
||||||
final String currentSubject,
|
final String currentSubject,
|
||||||
final String assumedRoles,
|
final String assumedRoles,
|
||||||
final HsOfficeCoopSharesTransactionInsertResource requestBody) {
|
final HsOfficeCoopSharesTransactionInsertResource requestBody) {
|
||||||
@ -131,9 +131,9 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar
|
|||||||
}
|
}
|
||||||
|
|
||||||
final BiConsumer<HsOfficeCoopSharesTransactionInsertResource, HsOfficeCoopSharesTransactionEntity> RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> {
|
final BiConsumer<HsOfficeCoopSharesTransactionInsertResource, HsOfficeCoopSharesTransactionEntity> RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> {
|
||||||
if ( resource.getRevertedShareTxUuid() != null ) {
|
if ( resource.getAdjustedShareTxUuid() != null ) {
|
||||||
entity.setAdjustedShareTx(coopSharesTransactionRepo.findByUuid(resource.getRevertedShareTxUuid())
|
entity.setAdjustedShareTx(coopSharesTransactionRepo.findByUuid(resource.getAdjustedShareTxUuid())
|
||||||
.orElseThrow(() -> new EntityNotFoundException("ERROR: [400] adjustedShareTxUuid %s not found".formatted(resource.getRevertedShareTxUuid()))));
|
.orElseThrow(() -> new EntityNotFoundException("ERROR: [400] adjustedShareTxUuid %s not found".formatted(resource.getAdjustedShareTxUuid()))));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ public interface HsOfficeMembershipRepository extends Repository<HsOfficeMembers
|
|||||||
|
|
||||||
HsOfficeMembershipEntity save(final HsOfficeMembershipEntity entity);
|
HsOfficeMembershipEntity save(final HsOfficeMembershipEntity entity);
|
||||||
|
|
||||||
List<HsOfficeMembershipEntity> findAll();
|
|
||||||
|
|
||||||
@Query("""
|
@Query("""
|
||||||
SELECT membership FROM HsOfficeMembershipEntity membership
|
SELECT membership FROM HsOfficeMembershipEntity membership
|
||||||
@ -23,7 +22,6 @@ public interface HsOfficeMembershipRepository extends Repository<HsOfficeMembers
|
|||||||
ORDER BY membership.partner.partnerNumber, membership.memberNumberSuffix
|
ORDER BY membership.partner.partnerNumber, membership.memberNumberSuffix
|
||||||
""")
|
""")
|
||||||
List<HsOfficeMembershipEntity> findMembershipsByOptionalPartnerUuid(UUID partnerUuid);
|
List<HsOfficeMembershipEntity> findMembershipsByOptionalPartnerUuid(UUID partnerUuid);
|
||||||
|
|
||||||
@Query("""
|
@Query("""
|
||||||
SELECT membership FROM HsOfficeMembershipEntity membership
|
SELECT membership FROM HsOfficeMembershipEntity membership
|
||||||
WHERE (:partnerNumber = membership.partner.partnerNumber)
|
WHERE (:partnerNumber = membership.partner.partnerNumber)
|
||||||
@ -33,18 +31,10 @@ public interface HsOfficeMembershipRepository extends Repository<HsOfficeMembers
|
|||||||
HsOfficeMembershipEntity findMembershipByPartnerNumberAndSuffix(
|
HsOfficeMembershipEntity findMembershipByPartnerNumberAndSuffix(
|
||||||
@NotNull Integer partnerNumber,
|
@NotNull Integer partnerNumber,
|
||||||
@NotNull String suffix);
|
@NotNull String suffix);
|
||||||
|
|
||||||
default HsOfficeMembershipEntity findMembershipByMemberNumber(Integer memberNumber) {
|
default HsOfficeMembershipEntity findMembershipByMemberNumber(Integer memberNumber) {
|
||||||
final var partnerNumber = memberNumber / 100;
|
final var partnerNumber = memberNumber / 100;
|
||||||
final String suffix = String.format("%02d", memberNumber % 100);
|
final var suffix = memberNumber % 100;
|
||||||
final var result = findMembershipByPartnerNumberAndSuffix(partnerNumber, suffix);
|
return findMembershipByPartnerNumberAndSuffix(partnerNumber, String.format("%02d", suffix));
|
||||||
// FIXME: remove
|
|
||||||
if (result == null) {
|
|
||||||
final var all = findAll();
|
|
||||||
all.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long count();
|
long count();
|
||||||
|
@ -6,7 +6,7 @@ components:
|
|||||||
HsOfficeCoopAssetsTransactionType:
|
HsOfficeCoopAssetsTransactionType:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
- ADJUSTMENT # FIXME: rename to REVERSAL
|
- ADJUSTMENT
|
||||||
- DEPOSIT
|
- DEPOSIT
|
||||||
- DISBURSAL
|
- DISBURSAL
|
||||||
- TRANSFER
|
- TRANSFER
|
||||||
@ -32,9 +32,9 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
comment:
|
comment:
|
||||||
type: string
|
type: string
|
||||||
adjustedAssetTx: # FIXME: rename to revertedAssetTx
|
adjustedAssetTx:
|
||||||
$ref: '#/components/schemas/HsOfficeReferencedCoopAssetsTransaction'
|
$ref: '#/components/schemas/HsOfficeReferencedCoopAssetsTransaction'
|
||||||
adjustmentAssetTx: # FIXME: rename to reversalAssetTx
|
adjustmentAssetTx:
|
||||||
$ref: '#/components/schemas/HsOfficeReferencedCoopAssetsTransaction'
|
$ref: '#/components/schemas/HsOfficeReferencedCoopAssetsTransaction'
|
||||||
|
|
||||||
HsOfficeReferencedCoopAssetsTransaction:
|
HsOfficeReferencedCoopAssetsTransaction:
|
||||||
@ -80,7 +80,7 @@ components:
|
|||||||
maxLength: 48
|
maxLength: 48
|
||||||
comment:
|
comment:
|
||||||
type: string
|
type: string
|
||||||
reverseEntry.uuid: # FIXME: rename to revertedAssetTx
|
reverseEntry.uuid:
|
||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
required:
|
required:
|
||||||
|
@ -6,7 +6,7 @@ components:
|
|||||||
HsOfficeCoopSharesTransactionType:
|
HsOfficeCoopSharesTransactionType:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
- ADJUSTMENT # FIXME: rename to REVERSAL
|
- ADJUSTMENT
|
||||||
- SUBSCRIPTION
|
- SUBSCRIPTION
|
||||||
- CANCELLATION
|
- CANCELLATION
|
||||||
|
|
||||||
@ -27,9 +27,9 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
comment:
|
comment:
|
||||||
type: string
|
type: string
|
||||||
revertedShareTx:
|
adjustedShareTx:
|
||||||
$ref: '#/components/schemas/HsOfficeReferencedCoopSharesTransaction'
|
$ref: '#/components/schemas/HsOfficeReferencedCoopSharesTransaction'
|
||||||
reversalShareTx:
|
adjustmentShareTx:
|
||||||
$ref: '#/components/schemas/HsOfficeReferencedCoopSharesTransaction'
|
$ref: '#/components/schemas/HsOfficeReferencedCoopSharesTransaction'
|
||||||
|
|
||||||
HsOfficeReferencedCoopSharesTransaction:
|
HsOfficeReferencedCoopSharesTransaction:
|
||||||
@ -73,7 +73,7 @@ components:
|
|||||||
maxLength: 48
|
maxLength: 48
|
||||||
comment:
|
comment:
|
||||||
type: string
|
type: string
|
||||||
revertedShareTx.uuid:
|
adjustedShareTx.uuid:
|
||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
required:
|
required:
|
||||||
|
@ -46,7 +46,7 @@ post:
|
|||||||
summary: Adds a new cooperative share transaction.
|
summary: Adds a new cooperative share transaction.
|
||||||
tags:
|
tags:
|
||||||
- hs-office-coopShares
|
- hs-office-coopShares
|
||||||
operationId: postCoopSharesTransaction
|
operationId: addCoopSharesTransaction
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||||
|
@ -28,9 +28,6 @@ create table if not exists hs_office.relation
|
|||||||
);
|
);
|
||||||
--//
|
--//
|
||||||
|
|
||||||
-- TODO.impl: unique constraint, to prevent using the same person multiple times as a partner, or better:
|
|
||||||
-- ( anchorUuid, holderUuid, type)
|
|
||||||
|
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
--changeset michael.hoennig:hs-office-relation-MAIN-TABLE-JOURNAL endDelimiter:--//
|
--changeset michael.hoennig:hs-office-relation-MAIN-TABLE-JOURNAL endDelimiter:--//
|
||||||
|
@ -12,9 +12,7 @@ import net.hostsharing.hsadminng.hs.office.scenarios.debitor.FinallyDeleteSepaMa
|
|||||||
import net.hostsharing.hsadminng.hs.office.scenarios.debitor.DontDeleteDefaultDebitor;
|
import net.hostsharing.hsadminng.hs.office.scenarios.debitor.DontDeleteDefaultDebitor;
|
||||||
import net.hostsharing.hsadminng.hs.office.scenarios.debitor.InvalidateSepaMandateForDebitor;
|
import net.hostsharing.hsadminng.hs.office.scenarios.debitor.InvalidateSepaMandateForDebitor;
|
||||||
import net.hostsharing.hsadminng.hs.office.scenarios.membership.CancelMembership;
|
import net.hostsharing.hsadminng.hs.office.scenarios.membership.CancelMembership;
|
||||||
import net.hostsharing.hsadminng.hs.office.scenarios.membership.CreateCoopSharesCancellationTransaction;
|
import net.hostsharing.hsadminng.hs.office.scenarios.membership.CoopSharesTransactionUseCase;
|
||||||
import net.hostsharing.hsadminng.hs.office.scenarios.membership.CreateCoopSharesRevertTransaction;
|
|
||||||
import net.hostsharing.hsadminng.hs.office.scenarios.membership.CreateCoopSharesSubscriptionTransaction;
|
|
||||||
import net.hostsharing.hsadminng.hs.office.scenarios.membership.CreateMembership;
|
import net.hostsharing.hsadminng.hs.office.scenarios.membership.CreateMembership;
|
||||||
import net.hostsharing.hsadminng.hs.office.scenarios.partner.AddOperationsContactToPartner;
|
import net.hostsharing.hsadminng.hs.office.scenarios.partner.AddOperationsContactToPartner;
|
||||||
import net.hostsharing.hsadminng.hs.office.scenarios.partner.CreatePartner;
|
import net.hostsharing.hsadminng.hs.office.scenarios.partner.CreatePartner;
|
||||||
@ -264,18 +262,18 @@ class HsOfficeScenarioTests extends ScenarioTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(2020)
|
@Order(2020)
|
||||||
@Requires("Debitor: D-3101000 - Test AG - main debitor")
|
@Requires("Debitor: Test AG - main debitor")
|
||||||
@Disabled("see TODO.spec in DontDeleteDefaultDebitor")
|
@Disabled("see TODO.spec in DontDeleteDefaultDebitor")
|
||||||
void shouldNotDeleteDefaultDebitor() {
|
void shouldNotDeleteDefaultDebitor() {
|
||||||
new DontDeleteDefaultDebitor(this)
|
new DontDeleteDefaultDebitor(this)
|
||||||
.given("partnerNumber", 31010)
|
.given("partnerNumber", 31020)
|
||||||
.given("debitorSuffix", "00")
|
.given("debitorSuffix", "00")
|
||||||
.doRun();
|
.doRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(3100)
|
@Order(3100)
|
||||||
@Requires("Debitor: D-3101000 - Test AG - main debitor")
|
@Requires("Debitor: Test AG - main debitor")
|
||||||
@Produces("SEPA-Mandate: Test AG")
|
@Produces("SEPA-Mandate: Test AG")
|
||||||
void shouldCreateSepaMandateForDebitor() {
|
void shouldCreateSepaMandateForDebitor() {
|
||||||
new CreateSepaMandateForDebitor(this)
|
new CreateSepaMandateForDebitor(this)
|
||||||
@ -317,7 +315,7 @@ class HsOfficeScenarioTests extends ScenarioTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(4000)
|
@Order(4000)
|
||||||
@Requires("Partner: P-31010 - Test AG")
|
@Requires("Partner: P-31010 - Test AG")
|
||||||
@Produces("Membership: M-3101000 - Test AG")
|
@Produces("Membership: Test AG 00")
|
||||||
void shouldCreateMembershipForPartner() {
|
void shouldCreateMembershipForPartner() {
|
||||||
new CreateMembership(this)
|
new CreateMembership(this)
|
||||||
.given("partnerName", "Test AG")
|
.given("partnerName", "Test AG")
|
||||||
@ -330,14 +328,15 @@ class HsOfficeScenarioTests extends ScenarioTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(4201)
|
@Order(4200)
|
||||||
@Requires("Membership: M-3101000 - Test AG")
|
@Requires("Membership: Test AG 00")
|
||||||
@Produces("Coop-Shares SUBSCRIPTION Transaction")
|
@Produces("Coop-Shares SUBSCRIPTION Transaction")
|
||||||
void shouldSubscribeCoopShares() {
|
void testCoopSharesSubscriptionTransaction() {
|
||||||
new CreateCoopSharesSubscriptionTransaction(this)
|
new CoopSharesTransactionUseCase(this)
|
||||||
.given("memberNumber", "3101000")
|
.given("memberNumber", "3101000")
|
||||||
|
.given("transactionType", "SUBSCRIPTION")
|
||||||
.given("reference", "sign 2024-01-15")
|
.given("reference", "sign 2024-01-15")
|
||||||
.given("shareCount", 100)
|
.given("shareCount", "100")
|
||||||
.given("comment", "Signing the Membership")
|
.given("comment", "Signing the Membership")
|
||||||
.given("transactionDate", "2024-01-15")
|
.given("transactionDate", "2024-01-15")
|
||||||
.doRun();
|
.doRun();
|
||||||
@ -345,12 +344,16 @@ class HsOfficeScenarioTests extends ScenarioTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(4201)
|
@Order(4201)
|
||||||
@Requires("Membership: M-3101000 - Test AG")
|
@Requires("Coop-Shares SUBSCRIPTION Transaction")
|
||||||
void shouldRevertCoopSharesSubscription() {
|
@Produces("Coop-Shares ADJUSTMENT Transaction")
|
||||||
new CreateCoopSharesRevertTransaction(this)
|
void testCoopSharesAdjustmentTransaction() {
|
||||||
.given("memberNumber", "3101000")
|
new CoopSharesTransactionUseCase(this)
|
||||||
.given("comment", "reverting some incorrect subscription")
|
.given("memberNumber", "3102000")
|
||||||
.given("dateOfIncorrectTransaction", "2024-02-15")
|
.given("transactionType", "ADJUSTMENT")
|
||||||
|
.given("reference", "adjust 2024-01-16")
|
||||||
|
.given("shareCount", "-90")
|
||||||
|
.given("comment", "Cancelling 90 Shares, correcting wrong number of digits in subscription")
|
||||||
|
.given("transactionDate", "2024-01-16")
|
||||||
.doRun();
|
.doRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,11 +361,12 @@ class HsOfficeScenarioTests extends ScenarioTest {
|
|||||||
@Order(4202)
|
@Order(4202)
|
||||||
@Requires("Coop-Shares SUBSCRIPTION Transaction")
|
@Requires("Coop-Shares SUBSCRIPTION Transaction")
|
||||||
@Produces("Coop-Shares CANCELLATION Transaction")
|
@Produces("Coop-Shares CANCELLATION Transaction")
|
||||||
void shouldCancelCoopSharesSubscription() {
|
void testCoopSharesCancellationTransaction() {
|
||||||
new CreateCoopSharesCancellationTransaction(this)
|
new CoopSharesTransactionUseCase(this)
|
||||||
.given("memberNumber", "3101000")
|
.given("memberNumber", "3102000")
|
||||||
|
.given("transactionType", "CANCELLATION")
|
||||||
.given("reference", "cancel 2024-01-15")
|
.given("reference", "cancel 2024-01-15")
|
||||||
.given("sharesToCancel", 8)
|
.given("shareCount", "8")
|
||||||
.given("comment", "Cancelling 8 Shares")
|
.given("comment", "Cancelling 8 Shares")
|
||||||
.given("transactionDate", "2024-02-15")
|
.given("transactionDate", "2024-02-15")
|
||||||
.doRun();
|
.doRun();
|
||||||
@ -370,7 +374,7 @@ class HsOfficeScenarioTests extends ScenarioTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(4900)
|
@Order(4900)
|
||||||
@Requires("Membership: M-3101000 - Test AG")
|
@Requires("Membership: Test AG 00")
|
||||||
void shouldCancelMembershipOfPartner() {
|
void shouldCancelMembershipOfPartner() {
|
||||||
new CancelMembership(this)
|
new CancelMembership(this)
|
||||||
.given("memberNumber", "3101000")
|
.given("memberNumber", "3101000")
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.hostsharing.hsadminng.hs.office.scenarios;
|
package net.hostsharing.hsadminng.hs.office.scenarios;
|
||||||
|
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.junit.jupiter.api.Order;
|
import org.junit.jupiter.api.Order;
|
||||||
import org.junit.jupiter.api.TestInfo;
|
import org.junit.jupiter.api.TestInfo;
|
||||||
|
|
||||||
@ -16,27 +15,23 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
|
|
||||||
public class TestReport {
|
public class TestReport {
|
||||||
|
|
||||||
private final static File markdownLogFile = new File("doc/scenarios/last-debug-log.md");
|
|
||||||
|
|
||||||
private final Map<String, ?> aliases;
|
private final Map<String, ?> aliases;
|
||||||
private final PrintWriter markdownLog; // records everything for debugging purposes
|
private final StringBuilder markdownLog = new StringBuilder(); // records everything for debugging purposes
|
||||||
private File markdownReportFile;
|
|
||||||
private PrintWriter markdownReport; // records only the use-case under test, without its pre-requisites
|
private PrintWriter markdownReport;
|
||||||
private int silent; // do not print anything to test-report if >0
|
private int silent; // do not print anything to test-report if >0
|
||||||
|
|
||||||
@SneakyThrows
|
|
||||||
public TestReport(final Map<String, ?> aliases) {
|
public TestReport(final Map<String, ?> aliases) {
|
||||||
this.aliases = aliases;
|
this.aliases = aliases;
|
||||||
this.markdownLog = new PrintWriter(new FileWriter(markdownLogFile));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createTestLogMarkdownFile(final TestInfo testInfo) throws IOException {
|
public void createTestLogMarkdownFile(final TestInfo testInfo) throws IOException {
|
||||||
final var testMethodName = testInfo.getTestMethod().map(Method::getName).orElseThrow();
|
final var testMethodName = testInfo.getTestMethod().map(Method::getName).orElseThrow();
|
||||||
final var testMethodOrder = testInfo.getTestMethod().map(m -> m.getAnnotation(Order.class).value()).orElseThrow();
|
final var testMethodOrder = testInfo.getTestMethod().map(m -> m.getAnnotation(Order.class).value()).orElseThrow();
|
||||||
assertThat(new File("doc/scenarios/").isDirectory() || new File("doc/scenarios/").mkdirs()).as("mkdir doc/scenarios/").isTrue();
|
assertThat(new File("doc/scenarios/").isDirectory() || new File("doc/scenarios/").mkdirs()).as("mkdir doc/scenarios/").isTrue();
|
||||||
markdownReportFile = new File("doc/scenarios/" + testMethodOrder + "-" + testMethodName + ".md");
|
markdownReport = new PrintWriter(new FileWriter("doc/scenarios/" + testMethodOrder + "-" + testMethodName + ".md"));
|
||||||
markdownReport = new PrintWriter(new FileWriter(markdownReportFile));
|
print("## Scenario #" + testInfo.getTestMethod().map(TestReport::orderNumber).orElseThrow() + ": " +
|
||||||
print("## Scenario #" + determineScenarioTitle(testInfo));
|
testMethodName.replaceAll("([a-z])([A-Z]+)", "$1 $2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@ -50,7 +45,7 @@ public class TestReport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// but the debugLog should contain all output, even if silent
|
// but the debugLog should contain all output, even if silent
|
||||||
markdownLog.print(outputWithCommentsForUuids);
|
markdownLog.append(outputWithCommentsForUuids);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printLine(final String output) {
|
public void printLine(final String output) {
|
||||||
@ -64,21 +59,7 @@ public class TestReport {
|
|||||||
public void close() {
|
public void close() {
|
||||||
if (markdownReport != null) {
|
if (markdownReport != null) {
|
||||||
markdownReport.close();
|
markdownReport.close();
|
||||||
System.out.println("SCENARIO REPORT: " + asClickableLink(markdownReportFile));
|
|
||||||
}
|
}
|
||||||
markdownLog.close();
|
|
||||||
System.out.println("DEBUG LOG: " + asClickableLink(markdownLogFile));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static @NotNull String determineScenarioTitle(final TestInfo testInfo) {
|
|
||||||
final var convertedTestMethodName =
|
|
||||||
testInfo.getTestMethod().map(TestReport::orderNumber).orElseThrow() + ": " +
|
|
||||||
testInfo.getTestMethod().map(Method::getName).map(t -> t.replaceAll("([a-z])([A-Z]+)", "$1 $2")).orElseThrow();
|
|
||||||
return convertedTestMethodName.replaceAll(": should ", ": ");
|
|
||||||
}
|
|
||||||
|
|
||||||
private String asClickableLink(final File file) {
|
|
||||||
return file.toURI().toString().replace("file:/", "file:///");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Object orderNumber(final Method method) {
|
private static Object orderNumber(final Method method) {
|
||||||
@ -107,4 +88,5 @@ public class TestReport {
|
|||||||
code.run();
|
code.run();
|
||||||
silent--;
|
silent--;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package net.hostsharing.hsadminng.hs.office.scenarios;
|
|||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.jayway.jsonpath.JsonPath;
|
import com.jayway.jsonpath.JsonPath;
|
||||||
import com.jayway.jsonpath.PathNotFoundException;
|
|
||||||
import io.restassured.http.ContentType;
|
import io.restassured.http.ContentType;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
@ -82,7 +81,7 @@ public abstract class UseCase<T extends UseCase<?>> {
|
|||||||
testReport.silent(() ->
|
testReport.silent(() ->
|
||||||
requirements.forEach((alias, factory) -> {
|
requirements.forEach((alias, factory) -> {
|
||||||
if (!ScenarioTest.containsAlias(alias)) {
|
if (!ScenarioTest.containsAlias(alias)) {
|
||||||
factory.apply(alias).run().keepAs(alias);
|
factory.apply(alias).run().keep();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -127,7 +126,7 @@ public abstract class UseCase<T extends UseCase<?>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public HttpResponse withTitle(final String title, final Supplier<HttpResponse> code) {
|
public HttpResponse withTitle(final String title, final Supplier<HttpResponse> code) {
|
||||||
this.nextTitle = ScenarioTest.resolve(title);
|
this.nextTitle = title;
|
||||||
final var response = code.get();
|
final var response = code.get();
|
||||||
this.nextTitle = null;
|
this.nextTitle = null;
|
||||||
return response;
|
return response;
|
||||||
@ -277,18 +276,13 @@ public abstract class UseCase<T extends UseCase<?>> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpResponse keepAs(final String alias) {
|
|
||||||
ScenarioTest.putAlias(
|
|
||||||
alias == null ? "unknown alias" : alias, // FIXME
|
|
||||||
new ScenarioTest.Alias<>(UseCase.this.getClass(), locationUuid));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HttpResponse keep() {
|
public HttpResponse keep() {
|
||||||
final var alias = nextTitle != null ? nextTitle : resultAlias;
|
final var alias = nextTitle != null ? nextTitle : resultAlias;
|
||||||
// FIXME assertThat(alias).as("cannot keep result, no title or alias found for locationUuid: " + locationUuid).isNotNull();
|
assertThat(alias).as("cannot keep result, no alias found").isNotNull();
|
||||||
|
ScenarioTest.putAlias(
|
||||||
return keepAs(alias);
|
alias,
|
||||||
|
new ScenarioTest.Alias<>(UseCase.this.getClass(), locationUuid));
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@ -311,7 +305,8 @@ public abstract class UseCase<T extends UseCase<?>> {
|
|||||||
public <T> Optional<T> getFromBodyAsOptional(final String path) {
|
public <T> Optional<T> getFromBodyAsOptional(final String path) {
|
||||||
try {
|
try {
|
||||||
return Optional.ofNullable(JsonPath.parse(response.body()).read(ScenarioTest.resolve(path)));
|
return Optional.ofNullable(JsonPath.parse(response.body()).read(ScenarioTest.resolve(path)));
|
||||||
} catch (final PathNotFoundException e) {
|
} catch (final Exception e) {
|
||||||
|
// FIXME: catch more precise exception class
|
||||||
return null; // means the property did not exist at all, not that it was there with value null
|
return null; // means the property did not exist at all, not that it was there with value null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,9 @@ import org.springframework.http.HttpStatus;
|
|||||||
import static io.restassured.http.ContentType.JSON;
|
import static io.restassured.http.ContentType.JSON;
|
||||||
import static org.springframework.http.HttpStatus.OK;
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
|
|
||||||
public abstract class CreateCoopSharesTransaction extends UseCase<CreateCoopSharesTransaction> {
|
public class CoopSharesTransactionUseCase extends UseCase<CoopSharesTransactionUseCase> {
|
||||||
|
|
||||||
public CreateCoopSharesTransaction(final ScenarioTest testSuite) {
|
public CoopSharesTransactionUseCase(final ScenarioTest testSuite) {
|
||||||
super(testSuite);
|
super(testSuite);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,20 +23,17 @@ public abstract class CreateCoopSharesTransaction extends UseCase<CreateCoopShar
|
|||||||
response -> response.getFromBody("$[0].uuid")
|
response -> response.getFromBody("$[0].uuid")
|
||||||
);
|
);
|
||||||
|
|
||||||
return withTitle("Create the CoopShares-%{transactionType} Transaction", () ->
|
return httpPost("/api/hs/office/coopsharestransactions", usingJsonBody("""
|
||||||
httpPost("/api/hs/office/coopsharestransactions", usingJsonBody("""
|
|
||||||
{
|
{
|
||||||
"membership.uuid": ${membershipUuid},
|
"membership.uuid": ${membershipUuid},
|
||||||
"transactionType": ${transactionType},
|
"transactionType": ${transactionType},
|
||||||
"reference": ${reference},
|
"reference": ${reference},
|
||||||
"shareCount": ${shareCount},
|
"shareCount": ${shareCount},
|
||||||
"comment": ${comment},
|
"comment": ${comment},
|
||||||
"valueDate": ${transactionDate},
|
"valueDate": ${transactionDate}
|
||||||
"revertedShareTx.uuid": ${revertedShareTx???}
|
|
||||||
}
|
}
|
||||||
"""))
|
"""))
|
||||||
.expecting(HttpStatus.CREATED).expecting(ContentType.JSON)
|
.expecting(HttpStatus.CREATED).expecting(ContentType.JSON);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -44,7 +41,8 @@ public abstract class CreateCoopSharesTransaction extends UseCase<CreateCoopShar
|
|||||||
verify("Verify Coop-Shares %{transactionType}-Transaction",
|
verify("Verify Coop-Shares %{transactionType}-Transaction",
|
||||||
() -> httpGet("/api/hs/office/coopsharestransactions/" + response.getLocationUuid())
|
() -> httpGet("/api/hs/office/coopsharestransactions/" + response.getLocationUuid())
|
||||||
.expecting(HttpStatus.OK).expecting(ContentType.JSON),
|
.expecting(HttpStatus.OK).expecting(ContentType.JSON),
|
||||||
path("transactionType").contains("%{transactionType}"),
|
// path("transactionType").contains("%{transactionType}"),
|
||||||
|
// path("memberNumber").contains("%{memberNumber}"),
|
||||||
path("shareCount").contains("%{shareCount}"),
|
path("shareCount").contains("%{shareCount}"),
|
||||||
path("comment").contains("%{comment}"),
|
path("comment").contains("%{comment}"),
|
||||||
path("valueDate").contains("%{transactionDate}")
|
path("valueDate").contains("%{transactionDate}")
|
@ -1,17 +0,0 @@
|
|||||||
package net.hostsharing.hsadminng.hs.office.scenarios.membership;
|
|
||||||
|
|
||||||
import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest;
|
|
||||||
|
|
||||||
public class CreateCoopSharesCancellationTransaction extends CreateCoopSharesTransaction {
|
|
||||||
|
|
||||||
public CreateCoopSharesCancellationTransaction(final ScenarioTest testSuite) {
|
|
||||||
super(testSuite);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected HttpResponse run() {
|
|
||||||
given("transactionType", "CANCELLATION");
|
|
||||||
given("shareCount", "-%{sharesToCancel}");
|
|
||||||
return super.run();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package net.hostsharing.hsadminng.hs.office.scenarios.membership;
|
|
||||||
|
|
||||||
import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest;
|
|
||||||
|
|
||||||
public class CreateCoopSharesRevertTransaction extends CreateCoopSharesTransaction {
|
|
||||||
|
|
||||||
public CreateCoopSharesRevertTransaction(final ScenarioTest testSuite) {
|
|
||||||
super(testSuite);
|
|
||||||
|
|
||||||
requires("CoopShares-Transaction with incorrect shareCount", alias ->
|
|
||||||
new CreateCoopSharesSubscriptionTransaction(testSuite)
|
|
||||||
.given("memberNumber", "3101000")
|
|
||||||
.given("reference", "sign %{dateOfIncorrectTransaction}") // same as revertedShareTx
|
|
||||||
.given("shareCount", 100)
|
|
||||||
.given("comment", "reverting subscription transaction with wrong share count")
|
|
||||||
.given("transactionDate", "%{dateOfIncorrectTransaction}")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected HttpResponse run() {
|
|
||||||
given("transactionType", "ADJUSTMENT");
|
|
||||||
given("shareCount", -100);
|
|
||||||
given("revertedShareTx", uuid("CoopShares-Transaction with incorrect shareCount"));
|
|
||||||
return super.run();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
package net.hostsharing.hsadminng.hs.office.scenarios.membership;
|
|
||||||
|
|
||||||
import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest;
|
|
||||||
|
|
||||||
public class CreateCoopSharesSubscriptionTransaction extends CreateCoopSharesTransaction {
|
|
||||||
|
|
||||||
public CreateCoopSharesSubscriptionTransaction(final ScenarioTest testSuite) {
|
|
||||||
super(testSuite);
|
|
||||||
|
|
||||||
given("transactionType", "SUBSCRIPTION");
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user