rename keep function to obtain
This commit is contained in:
parent
824565204d
commit
47ba0cadb6
@ -95,7 +95,7 @@ public abstract class UseCase<T extends UseCase<?>> {
|
|||||||
return new JsonTemplate(jsonTemplate);
|
return new JsonTemplate(jsonTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void keep(
|
public final void obtain(
|
||||||
final String alias,
|
final String alias,
|
||||||
final Supplier<HttpResponse> http,
|
final Supplier<HttpResponse> http,
|
||||||
final Function<HttpResponse, String> extractor,
|
final Function<HttpResponse, String> extractor,
|
||||||
@ -106,7 +106,7 @@ public abstract class UseCase<T extends UseCase<?>> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void keep(final String alias, final Supplier<HttpResponse> http, final String... extraInfo) {
|
public final void obtain(final String alias, final Supplier<HttpResponse> http, final String... extraInfo) {
|
||||||
withTitle(ScenarioTest.resolve(alias), () -> {
|
withTitle(ScenarioTest.resolve(alias), () -> {
|
||||||
http.get().keep();
|
http.get().keep();
|
||||||
Arrays.stream(extraInfo).forEach(testReport::printPara);
|
Arrays.stream(extraInfo).forEach(testReport::printPara);
|
||||||
|
@ -20,7 +20,7 @@ public class CreateExternalDebitorForPartner extends UseCase<CreateExternalDebit
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HttpResponse run() {
|
protected HttpResponse run() {
|
||||||
keep("BankAccount: Billing GmbH - refund bank account", () ->
|
obtain("BankAccount: Billing GmbH - refund bank account", () ->
|
||||||
httpPost("/api/hs/office/bankaccounts", usingJsonBody("""
|
httpPost("/api/hs/office/bankaccounts", usingJsonBody("""
|
||||||
{
|
{
|
||||||
"holder": "Billing GmbH - refund bank account",
|
"holder": "Billing GmbH - refund bank account",
|
||||||
@ -31,7 +31,7 @@ public class CreateExternalDebitorForPartner extends UseCase<CreateExternalDebit
|
|||||||
.expecting(CREATED).expecting(JSON)
|
.expecting(CREATED).expecting(JSON)
|
||||||
);
|
);
|
||||||
|
|
||||||
keep("Contact: Billing GmbH - Test AG billing", () ->
|
obtain("Contact: Billing GmbH - Test AG billing", () ->
|
||||||
httpPost("/api/hs/office/contacts", usingJsonBody("""
|
httpPost("/api/hs/office/contacts", usingJsonBody("""
|
||||||
{
|
{
|
||||||
"caption": "Billing GmbH, billing for Test AG",
|
"caption": "Billing GmbH, billing for Test AG",
|
||||||
|
@ -15,7 +15,7 @@ public class CreateSelfDebitorForPartner extends UseCase<CreateSelfDebitorForPar
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HttpResponse run() {
|
protected HttpResponse run() {
|
||||||
keep("partnerPersonUuid", () ->
|
obtain("partnerPersonUuid", () ->
|
||||||
httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerPersonTradeName}"))
|
httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerPersonTradeName}"))
|
||||||
.expecting(OK).expecting(JSON),
|
.expecting(OK).expecting(JSON),
|
||||||
response -> response.expectArrayElements(1).getFromBody("[0].holder.uuid"),
|
response -> response.expectArrayElements(1).getFromBody("[0].holder.uuid"),
|
||||||
@ -23,7 +23,7 @@ public class CreateSelfDebitorForPartner extends UseCase<CreateSelfDebitorForPar
|
|||||||
"**HINT**: With production data, you might get multiple results and have to decide which is the right one."
|
"**HINT**: With production data, you might get multiple results and have to decide which is the right one."
|
||||||
);
|
);
|
||||||
|
|
||||||
keep("BankAccount: Test AG - refund bank account", () ->
|
obtain("BankAccount: Test AG - refund bank account", () ->
|
||||||
httpPost("/api/hs/office/bankaccounts", usingJsonBody("""
|
httpPost("/api/hs/office/bankaccounts", usingJsonBody("""
|
||||||
{
|
{
|
||||||
"holder": "Test AG - refund bank account",
|
"holder": "Test AG - refund bank account",
|
||||||
@ -34,7 +34,7 @@ public class CreateSelfDebitorForPartner extends UseCase<CreateSelfDebitorForPar
|
|||||||
.expecting(CREATED).expecting(JSON)
|
.expecting(CREATED).expecting(JSON)
|
||||||
);
|
);
|
||||||
|
|
||||||
keep("Contact: Test AG - billing department", () ->
|
obtain("Contact: Test AG - billing department", () ->
|
||||||
httpPost("/api/hs/office/contacts", usingJsonBody("""
|
httpPost("/api/hs/office/contacts", usingJsonBody("""
|
||||||
{
|
{
|
||||||
"caption": ${billingContactCaption},
|
"caption": ${billingContactCaption},
|
||||||
|
@ -14,7 +14,7 @@ public class CreateSepaMandataForDebitor extends UseCase<CreateSepaMandataForDeb
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HttpResponse run() {
|
protected HttpResponse run() {
|
||||||
keep("BankAccount: Test AG - debit bank account", () ->
|
obtain("BankAccount: Test AG - debit bank account", () ->
|
||||||
httpPost("/api/hs/office/bankaccounts", usingJsonBody("""
|
httpPost("/api/hs/office/bankaccounts", usingJsonBody("""
|
||||||
{
|
{
|
||||||
"holder": "Test AG - debit bank account",
|
"holder": "Test AG - debit bank account",
|
||||||
|
@ -13,7 +13,7 @@ public class CreateMembership extends UseCase<CreateMembership> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HttpResponse run() {
|
protected HttpResponse run() {
|
||||||
keep("Membership: %{partnerName} 00", () ->
|
obtain("Membership: %{partnerName} 00", () ->
|
||||||
httpPost("/api/hs/office/memberships", usingJsonBody("""
|
httpPost("/api/hs/office/memberships", usingJsonBody("""
|
||||||
{
|
{
|
||||||
"partnerUuid": ${Partner: Test AG},
|
"partnerUuid": ${Partner: Test AG},
|
||||||
|
@ -18,14 +18,14 @@ public class AddOperationsContactToPartner extends UseCase<AddOperationsContactT
|
|||||||
@Override
|
@Override
|
||||||
protected HttpResponse run() {
|
protected HttpResponse run() {
|
||||||
|
|
||||||
keep("Person: %{partnerPersonTradeName}", () ->
|
obtain("Person: %{partnerPersonTradeName}", () ->
|
||||||
httpGet("/api/hs/office/persons?name=" + uriEncoded("%{partnerPersonTradeName}"))
|
httpGet("/api/hs/office/persons?name=" + uriEncoded("%{partnerPersonTradeName}"))
|
||||||
.expecting(OK).expecting(JSON),
|
.expecting(OK).expecting(JSON),
|
||||||
response -> response.expectArrayElements(1).getFromBody("[0].uuid"),
|
response -> response.expectArrayElements(1).getFromBody("[0].uuid"),
|
||||||
"In production data this query could result in multiple outputs. In that case, you have to find out which is the right one."
|
"In production data this query could result in multiple outputs. In that case, you have to find out which is the right one."
|
||||||
);
|
);
|
||||||
|
|
||||||
keep("Person: %{operationsContactGivenName} %{operationsContactFamilyName}",
|
obtain("Person: %{operationsContactGivenName} %{operationsContactFamilyName}",
|
||||||
() ->
|
() ->
|
||||||
httpPost("/api/hs/office/persons", usingJsonBody("""
|
httpPost("/api/hs/office/persons", usingJsonBody("""
|
||||||
{
|
{
|
||||||
@ -39,7 +39,7 @@ public class AddOperationsContactToPartner extends UseCase<AddOperationsContactT
|
|||||||
"**HINT**: operations contacts are always connected to a partner-person, thus a person which is a holder of a partner-relation."
|
"**HINT**: operations contacts are always connected to a partner-person, thus a person which is a holder of a partner-relation."
|
||||||
);
|
);
|
||||||
|
|
||||||
keep("Contact: %{operationsContactGivenName} %{operationsContactFamilyName}", () ->
|
obtain("Contact: %{operationsContactGivenName} %{operationsContactFamilyName}", () ->
|
||||||
httpPost("/api/hs/office/contacts", usingJsonBody("""
|
httpPost("/api/hs/office/contacts", usingJsonBody("""
|
||||||
{
|
{
|
||||||
"caption": "%{operationsContactGivenName} %{operationsContactFamilyName}",
|
"caption": "%{operationsContactGivenName} %{operationsContactFamilyName}",
|
||||||
|
@ -18,14 +18,14 @@ public class AddRepresentativeToPartner extends UseCase<AddRepresentativeToPartn
|
|||||||
@Override
|
@Override
|
||||||
protected HttpResponse run() {
|
protected HttpResponse run() {
|
||||||
|
|
||||||
keep("Person: %{partnerPersonTradeName}", () ->
|
obtain("Person: %{partnerPersonTradeName}", () ->
|
||||||
httpGet("/api/hs/office/persons?name=" + uriEncoded("%{partnerPersonTradeName}"))
|
httpGet("/api/hs/office/persons?name=" + uriEncoded("%{partnerPersonTradeName}"))
|
||||||
.expecting(OK).expecting(JSON),
|
.expecting(OK).expecting(JSON),
|
||||||
response -> response.expectArrayElements(1).getFromBody("[0].uuid"),
|
response -> response.expectArrayElements(1).getFromBody("[0].uuid"),
|
||||||
"In production data this query could result in multiple outputs. In that case, you have to find out which is the right one."
|
"In production data this query could result in multiple outputs. In that case, you have to find out which is the right one."
|
||||||
);
|
);
|
||||||
|
|
||||||
keep("Person: %{representativeGivenName} %{representativeFamilyName}", () ->
|
obtain("Person: %{representativeGivenName} %{representativeFamilyName}", () ->
|
||||||
httpPost("/api/hs/office/persons", usingJsonBody("""
|
httpPost("/api/hs/office/persons", usingJsonBody("""
|
||||||
{
|
{
|
||||||
"personType": "NATURAL_PERSON",
|
"personType": "NATURAL_PERSON",
|
||||||
@ -38,7 +38,7 @@ public class AddRepresentativeToPartner extends UseCase<AddRepresentativeToPartn
|
|||||||
"**HINT**: A representative is always a natural person and represents a non-natural-person."
|
"**HINT**: A representative is always a natural person and represents a non-natural-person."
|
||||||
);
|
);
|
||||||
|
|
||||||
keep("Contact: %{representativeGivenName} %{representativeFamilyName}", () ->
|
obtain("Contact: %{representativeGivenName} %{representativeFamilyName}", () ->
|
||||||
httpPost("/api/hs/office/contacts", usingJsonBody("""
|
httpPost("/api/hs/office/contacts", usingJsonBody("""
|
||||||
{
|
{
|
||||||
"caption": "%{representativeGivenName} %{representativeFamilyName}",
|
"caption": "%{representativeGivenName} %{representativeFamilyName}",
|
||||||
|
@ -21,14 +21,14 @@ public class CreatePartner extends UseCase<CreatePartner> {
|
|||||||
@Override
|
@Override
|
||||||
protected HttpResponse run() {
|
protected HttpResponse run() {
|
||||||
|
|
||||||
keep("Person: Hostsharing eG", () ->
|
obtain("Person: Hostsharing eG", () ->
|
||||||
httpGet("/api/hs/office/persons?name=Hostsharing+eG")
|
httpGet("/api/hs/office/persons?name=Hostsharing+eG")
|
||||||
.expecting(OK).expecting(JSON),
|
.expecting(OK).expecting(JSON),
|
||||||
response -> response.expectArrayElements(1).getFromBody("[0].uuid"),
|
response -> response.expectArrayElements(1).getFromBody("[0].uuid"),
|
||||||
"Even in production data we expect this query to return just a single result." // TODO.impl: add constraint?
|
"Even in production data we expect this query to return just a single result." // TODO.impl: add constraint?
|
||||||
);
|
);
|
||||||
|
|
||||||
keep("Person: %{tradeName}", () ->
|
obtain("Person: %{tradeName}", () ->
|
||||||
httpPost("/api/hs/office/persons", usingJsonBody("""
|
httpPost("/api/hs/office/persons", usingJsonBody("""
|
||||||
{
|
{
|
||||||
"personType": ${personType},
|
"personType": ${personType},
|
||||||
@ -38,7 +38,7 @@ public class CreatePartner extends UseCase<CreatePartner> {
|
|||||||
.expecting(HttpStatus.CREATED).expecting(ContentType.JSON)
|
.expecting(HttpStatus.CREATED).expecting(ContentType.JSON)
|
||||||
);
|
);
|
||||||
|
|
||||||
keep("Contact: %{tradeName} - Board of Directors", () ->
|
obtain("Contact: %{tradeName} - Board of Directors", () ->
|
||||||
httpPost("/api/hs/office/contacts", usingJsonBody("""
|
httpPost("/api/hs/office/contacts", usingJsonBody("""
|
||||||
{
|
{
|
||||||
"caption": ${contactCaption},
|
"caption": ${contactCaption},
|
||||||
|
@ -16,7 +16,7 @@ public class RemoveOperationsContactFromPartner extends UseCase<RemoveOperations
|
|||||||
@Override
|
@Override
|
||||||
protected HttpResponse run() {
|
protected HttpResponse run() {
|
||||||
|
|
||||||
keep("Operations-Contact: %{operationsContactPerson}", () ->
|
obtain("Operations-Contact: %{operationsContactPerson}", () ->
|
||||||
httpGet("/api/hs/office/relations?relationType=OPERATIONS&name=" + uriEncoded("%{operationsContactPerson}"))
|
httpGet("/api/hs/office/relations?relationType=OPERATIONS&name=" + uriEncoded("%{operationsContactPerson}"))
|
||||||
.expecting(OK).expecting(JSON),
|
.expecting(OK).expecting(JSON),
|
||||||
response -> response.expectArrayElements(1).getFromBody("[0].uuid"),
|
response -> response.expectArrayElements(1).getFromBody("[0].uuid"),
|
||||||
|
@ -16,7 +16,7 @@ public class SubscribeToMailinglist extends UseCase<SubscribeToMailinglist> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HttpResponse run() {
|
protected HttpResponse run() {
|
||||||
keep("Person: %{subscriberGivenName} %{subscriberFamilyName}", () ->
|
obtain("Person: %{subscriberGivenName} %{subscriberFamilyName}", () ->
|
||||||
httpPost("/api/hs/office/persons", usingJsonBody("""
|
httpPost("/api/hs/office/persons", usingJsonBody("""
|
||||||
{
|
{
|
||||||
"personType": "NATURAL_PERSON",
|
"personType": "NATURAL_PERSON",
|
||||||
@ -27,7 +27,7 @@ public class SubscribeToMailinglist extends UseCase<SubscribeToMailinglist> {
|
|||||||
.expecting(HttpStatus.CREATED).expecting(ContentType.JSON)
|
.expecting(HttpStatus.CREATED).expecting(ContentType.JSON)
|
||||||
);
|
);
|
||||||
|
|
||||||
keep("Contact: %{subscriberGivenName} %{subscriberFamilyName}", () ->
|
obtain("Contact: %{subscriberGivenName} %{subscriberFamilyName}", () ->
|
||||||
httpPost("/api/hs/office/contacts", usingJsonBody("""
|
httpPost("/api/hs/office/contacts", usingJsonBody("""
|
||||||
{
|
{
|
||||||
"caption": "%{subscriberGivenName} %{subscriberFamilyName}",
|
"caption": "%{subscriberGivenName} %{subscriberFamilyName}",
|
||||||
|
Loading…
Reference in New Issue
Block a user