Compare commits

..

2 Commits

Author SHA1 Message Date
Michael Hoennig
6817219553 cleanup according to code-review 2024-10-30 11:30:12 +01:00
Michael Hoennig
0b6912afaf explicitly fetch contact emailaddress in UnsubscribeFromMailinglist 2024-10-30 11:29:54 +01:00
7 changed files with 31 additions and 55 deletions

View File

@ -3,8 +3,8 @@ package net.hostsharing.hsadminng.hs.office.scenarios;
import net.hostsharing.hsadminng.HsadminNgApplication; import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.hs.office.scenarios.debitor.CreateExternalDebitorForPartner; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.CreateExternalDebitorForPartner;
import net.hostsharing.hsadminng.hs.office.scenarios.debitor.CreateSelfDebitorForPartner; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.CreateSelfDebitorForPartner;
import net.hostsharing.hsadminng.hs.office.scenarios.debitor.CreateSepaMandataForDebitor; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.CreateSepaMandateForDebitor;
import net.hostsharing.hsadminng.hs.office.scenarios.debitor.DeleteSepaMandataForDebitor; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.DeleteSepaMandateForDebitor;
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.CreateMembership; import net.hostsharing.hsadminng.hs.office.scenarios.membership.CreateMembership;
@ -172,7 +172,7 @@ class HsOfficeScenarioTests extends ScenarioTest {
@Requires("Debitor: 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 CreateSepaMandataForDebitor(this) new CreateSepaMandateForDebitor(this)
.given("debitor", "Test AG") .given("debitor", "Test AG")
.given("memberNumberSuffix", "00") .given("memberNumberSuffix", "00")
.given("validFrom", "2024-10-15") .given("validFrom", "2024-10-15")
@ -195,7 +195,7 @@ class HsOfficeScenarioTests extends ScenarioTest {
@Order(3109) @Order(3109)
@Requires("SEPA-Mandate: Test AG") @Requires("SEPA-Mandate: Test AG")
void shouldDeleteSepaMandateForDebitor() { void shouldDeleteSepaMandateForDebitor() {
new DeleteSepaMandataForDebitor(this) new DeleteSepaMandateForDebitor(this)
.given("sepaMandateUuid", "%{SEPA-Mandate: Test AG}") .given("sepaMandateUuid", "%{SEPA-Mandate: Test AG}")
.doRun(); .doRun();
} }
@ -233,7 +233,8 @@ class HsOfficeScenarioTests extends ScenarioTest {
@Requires("Subscription: Michael Miller to operations-announce") @Requires("Subscription: Michael Miller to operations-announce")
void shouldUnsubscribeNewPersonAndContactToMailinglist() { void shouldUnsubscribeNewPersonAndContactToMailinglist() {
new UnsubscribeFromMailinglist(this) new UnsubscribeFromMailinglist(this)
.given("subscriptionUuid", "%{Subscription: Michael Miller to operations-announce}") .given("mailingList", "operations-announce")
.given("subscriberEMailAddress", "michael.miller@example.org")
.doRun(); .doRun();
} }
} }

View File

@ -1,34 +0,0 @@
package net.hostsharing.hsadminng.hs.office.scenarios;
import java.lang.invoke.SerializedLambda;
import java.lang.reflect.Method;
import java.util.function.Consumer;
public class MethodReferenceExample {
public static void myMethod(String input) {
System.out.println("Hello from myMethod, input: " + input);
}
public static void main(String[] args) {
// Create a method reference
Consumer<String> methodRef = MethodReferenceExample::myMethod;
// Use reflection to retrieve method reference info
try {
// Step 1: Get the method 'writeReplace' via reflection
Method writeReplace = methodRef.getClass().getDeclaredMethod("writeReplace");
writeReplace.setAccessible(true);
// Step 2: Invoke 'writeReplace' to get a SerializedLambda
SerializedLambda serializedLambda = (SerializedLambda) writeReplace.invoke(methodRef);
// Step 3: Get the method name using the SerializedLambda
String methodName = serializedLambda.getImplMethodName();
System.out.println("Original method name: " + methodName);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -86,7 +86,6 @@ public class TemplateResolver {
throw new IllegalStateException("no more characters. resolved so far: " + resolved); throw new IllegalStateException("no more characters. resolved so far: " + resolved);
} }
final var currentChar = currentChar(); final var currentChar = currentChar();
//System.out.println("fetched #" + position + ": " + currentChar);
++position; ++position;
return currentChar; return currentChar;
} }

View File

@ -6,9 +6,9 @@ import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest;
import static io.restassured.http.ContentType.JSON; import static io.restassured.http.ContentType.JSON;
import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.CREATED;
public class CreateSepaMandataForDebitor extends UseCase<CreateSepaMandataForDebitor> { public class CreateSepaMandateForDebitor extends UseCase<CreateSepaMandateForDebitor> {
public CreateSepaMandataForDebitor(final ScenarioTest testSuite) { public CreateSepaMandateForDebitor(final ScenarioTest testSuite) {
super(testSuite); super(testSuite);
} }

View File

@ -5,9 +5,9 @@ import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
public class DeleteSepaMandataForDebitor extends UseCase<DeleteSepaMandataForDebitor> { public class DeleteSepaMandateForDebitor extends UseCase<DeleteSepaMandateForDebitor> {
public DeleteSepaMandataForDebitor(final ScenarioTest testSuite) { public DeleteSepaMandateForDebitor(final ScenarioTest testSuite) {
super(testSuite); super(testSuite);
} }

View File

@ -25,16 +25,15 @@ public class AddOperationsContactToPartner extends UseCase<AddOperationsContactT
"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."
); );
obtain("Person: %{operationsContactGivenName} %{operationsContactFamilyName}", obtain("Person: %{operationsContactGivenName} %{operationsContactFamilyName}", () ->
() -> httpPost("/api/hs/office/persons", usingJsonBody("""
httpPost("/api/hs/office/persons", usingJsonBody(""" {
{ "personType": "NATURAL_PERSON",
"personType": "NATURAL_PERSON", "familyName": ${operationsContactFamilyName},
"familyName": ${operationsContactFamilyName}, "givenName": ${operationsContactGivenName}
"givenName": ${operationsContactGivenName} }
} """))
""")) .expecting(HttpStatus.CREATED).expecting(ContentType.JSON),
.expecting(HttpStatus.CREATED).expecting(ContentType.JSON),
"Please check first if that person already exists, if so, use it's UUID below.", "Please check first if that person already exists, if so, use it's UUID below.",
"**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."
); );

View File

@ -3,7 +3,9 @@ package net.hostsharing.hsadminng.hs.office.scenarios.subscription;
import net.hostsharing.hsadminng.hs.office.scenarios.UseCase; import net.hostsharing.hsadminng.hs.office.scenarios.UseCase;
import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest; import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest;
import static io.restassured.http.ContentType.JSON;
import static org.springframework.http.HttpStatus.NO_CONTENT; import static org.springframework.http.HttpStatus.NO_CONTENT;
import static org.springframework.http.HttpStatus.OK;
public class UnsubscribeFromMailinglist extends UseCase<UnsubscribeFromMailinglist> { public class UnsubscribeFromMailinglist extends UseCase<UnsubscribeFromMailinglist> {
@ -14,7 +16,16 @@ public class UnsubscribeFromMailinglist extends UseCase<UnsubscribeFromMailingli
@Override @Override
protected HttpResponse run() { protected HttpResponse run() {
return httpDelete("/api/hs/office/relations/" + uuid("subscriptionUuid")) obtain("Subscription: %{subscriberEMailAddress}", () ->
httpGet("/api/hs/office/relations?relationType=SUBSCRIBER" +
"&mark=" + uriEncoded("%{mailingList}") +
"&contactData=" + uriEncoded("%{subscriberEMailAddress}"))
.expecting(OK).expecting(JSON),
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."
);
return httpDelete("/api/hs/office/relations/" + uuid("Subscription: %{subscriberEMailAddress}"))
.expecting(NO_CONTENT); .expecting(NO_CONTENT);
} }
} }