feature/add-scenario-test-for-deceased-partner-with-community-of-heirs #137

Merged
3 changed files with 33 additions and 29 deletions
Showing only changes of commit 83ab12f3e0 - Show all commits

View File

@ -227,7 +227,8 @@ class HsOfficeScenarioTests extends ScenarioTest {
new ReplaceContactData(scenarioTest) new ReplaceContactData(scenarioTest)
.given("partnerName", "Test AG") .given("partnerName", "Test AG")
.given("newContactCaption", "Test AG - China") .given("newContactCaption", "Test AG - China")
.given("newPostalAddress", """ .given(
"newPostalAddress", """
"firm": "Test AG", "firm": "Test AG",
"name": "Fi Zhong-Kha", "name": "Fi Zhong-Kha",
"building": "Thi Chi Koh Building", "building": "Thi Chi Koh Building",
@ -263,6 +264,7 @@ class HsOfficeScenarioTests extends ScenarioTest {
@Order(20) @Order(20)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class DebitorScenarios { class DebitorScenarios {
@Test @Test
@Order(2010) @Order(2010)
@Requires("Partner: P-31010 - Test AG") @Requires("Partner: P-31010 - Test AG")
@ -624,9 +626,7 @@ class HsOfficeScenarioTests extends ScenarioTest {
.given("representativeGivenName", "Lena") .given("representativeGivenName", "Lena")
.given("representativeFamilyName", "Stadland") .given("representativeFamilyName", "Stadland")
.given( .given(
// "name": "Erbengemeinschaft Michelle Matthieu", // FIXME: automatic?
"communityOfHeirsPostalAddress", """ "communityOfHeirsPostalAddress", """
"co": "Lena Stadland", // FIXME: take this form representative...?
"street": "Im Wischer 14", "street": "Im Wischer 14",
"zipcode": "22987", "zipcode": "22987",
"city": "Hamburg", "city": "Hamburg",

View File

@ -48,6 +48,7 @@ public class ReplaceDeceasedPartnerWithCommunityOfHeirs extends UseCase<ReplaceD
"caption": "Erbengemeinschaft %{nameOfDeceasedPerson}", "caption": "Erbengemeinschaft %{nameOfDeceasedPerson}",
"postalAddress": { "postalAddress": {
"name": "Erbengemeinschaft %{nameOfDeceasedPerson}", "name": "Erbengemeinschaft %{nameOfDeceasedPerson}",
"co": "%{representativeGivenName} %{representativeFamilyName}",
%{communityOfHeirsPostalAddress} %{communityOfHeirsPostalAddress}
}, },
"phoneNumbers": { "phoneNumbers": {

View File

@ -80,18 +80,7 @@ public abstract class ScenarioTest extends ContextBasedTest {
@AfterEach @AfterEach
void afterScenario(final TestInfo testInfo) { // final TestInfo testInfo void afterScenario(final TestInfo testInfo) { // final TestInfo testInfo
testInfo.getTestMethod() .ifPresent(currentTestMethod -> { verifyProduceDeclaration(testInfo);
// FIXME: extract to method
final var producesAnnot = currentTestMethod.getAnnotation(Produces.class);
if (producesAnnot != null && producesAnnot.permanent()) {
final var testMethodProduces = producedAliases(producesAnnot);
testMethodProduces.forEach(declaredAlias ->
assertThat(knowVariables().containsKey(declaredAlias))
.as("@Producer method " + currentTestMethod.getName() +
" did declare but not produce \"" + declaredAlias + "\"")
.isTrue() );
}
});
properties.clear(); properties.clear();
testReport.close(); testReport.close();
@ -182,6 +171,20 @@ public abstract class ScenarioTest extends ContextBasedTest {
} }
} }
private static void verifyProduceDeclaration(final TestInfo testInfo) {
testInfo.getTestMethod().ifPresent(currentTestMethod -> {
final var producesAnnot = currentTestMethod.getAnnotation(Produces.class);
if (producesAnnot != null && producesAnnot.permanent()) {
final var testMethodProduces = producedAliases(producesAnnot);
testMethodProduces.forEach(declaredAlias ->
assertThat(knowVariables().containsKey(declaredAlias))
.as("@Producer method " + currentTestMethod.getName() +
" did declare but not produce \"" + declaredAlias + "\"")
.isTrue() );
}
});
}
static boolean containsAlias(final String alias) { static boolean containsAlias(final String alias) {
return aliases.containsKey(alias); return aliases.containsKey(alias);
} }