separate actual import and verification test methods
This commit is contained in:
parent
678c79cf4f
commit
13ddaa2afd
5
.aliases
5
.aliases
@ -56,7 +56,10 @@ function importOfficeData() {
|
||||
source .environment
|
||||
fi
|
||||
|
||||
./gradlew importOfficeData
|
||||
echo "using environment (with ending ';' for use in IntelliJ IDEA):"
|
||||
set | grep ^HSADMINNG_ | sed 's/$/;/'
|
||||
|
||||
./gradlew importOfficeData --rerun
|
||||
}
|
||||
alias gw-importOfficeData=importOfficeData
|
||||
|
||||
|
@ -34,6 +34,7 @@ import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.Commit;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
@ -106,6 +107,7 @@ import static org.assertj.core.api.Fail.fail;
|
||||
"spring.datasource.password=${HSADMINNG_POSTGRES_ADMIN_PASSWORD:password}",
|
||||
"hsadminng.superuser=${HSADMINNG_SUPERUSER:superuser-alex@hostsharing.net}"
|
||||
})
|
||||
@DirtiesContext
|
||||
@Import({ Context.class, JpaAttempt.class })
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@ExtendWith(OrderedDependedTestsExtension.class)
|
||||
@ -113,6 +115,9 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
|
||||
static int relationshipId = 2000000;
|
||||
|
||||
@Value("${spring.datasource.url}")
|
||||
private String jdbcUrl;
|
||||
|
||||
@Value("${spring.datasource.username}")
|
||||
private String postgresAdminUser;
|
||||
|
||||
@ -144,7 +149,7 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
HttpServletRequest request;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
@Order(1010)
|
||||
void importBusinessPartners() {
|
||||
|
||||
try (Reader reader = resourceReader("migration/business-partners.csv")) {
|
||||
@ -153,7 +158,11 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1011)
|
||||
void verifyBusinessPartners() {
|
||||
assumeThat(postgresAdminUser).isEqualTo("admin");
|
||||
|
||||
// no contacts yet => mostly null values
|
||||
@ -181,7 +190,7 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
@Order(1020)
|
||||
void importContacts() {
|
||||
|
||||
try (Reader reader = resourceReader("migration/contacts.csv")) {
|
||||
@ -190,7 +199,11 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1021)
|
||||
void verifyContacts() {
|
||||
assumeThat(postgresAdminUser).isEqualTo("admin");
|
||||
|
||||
assertThat(toFormattedString(partners)).isEqualToIgnoringWhitespace("""
|
||||
@ -249,7 +262,7 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
@Order(1030)
|
||||
void importSepaMandates() {
|
||||
|
||||
try (Reader reader = resourceReader("migration/sepa-mandates.csv")) {
|
||||
@ -258,7 +271,11 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1031)
|
||||
void verifySepaMandates() {
|
||||
assumeThat(postgresAdminUser).isEqualTo("admin");
|
||||
|
||||
assertThat(toFormattedString(bankAccounts)).isEqualToIgnoringWhitespace("""
|
||||
@ -278,8 +295,9 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
@Order(1040)
|
||||
void importCoopShares() {
|
||||
assumeThat(postgresAdminUser).isEqualTo("admin");
|
||||
|
||||
try (Reader reader = resourceReader("migration/share-transactions.csv")) {
|
||||
final var lines = readAllLines(reader);
|
||||
@ -287,7 +305,11 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1041)
|
||||
void verifyCoopShares() {
|
||||
assumeThat(postgresAdminUser).isEqualTo("admin");
|
||||
|
||||
assertThat(coopShares.toString()).isEqualToIgnoringWhitespace("""
|
||||
@ -301,7 +323,7 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
@Order(1050)
|
||||
void importCoopAssets() {
|
||||
|
||||
try (Reader reader = resourceReader("migration/asset-transactions.csv")) {
|
||||
@ -310,7 +332,11 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1051)
|
||||
void verifyCoopAssets() {
|
||||
assumeThat(postgresAdminUser).isEqualTo("admin");
|
||||
|
||||
assertThat(coopAssets.toString()).isEqualToIgnoringWhitespace("""
|
||||
@ -328,10 +354,11 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
@Order(2000)
|
||||
@Commit
|
||||
void persistEntities() {
|
||||
|
||||
System.out.println("PERSISTING to database '" + jdbcUrl + "' as user '" + postgresAdminUser + "'");
|
||||
deleteTestDataFromHsOfficeTables();
|
||||
resetFromHsOfficeSequences();
|
||||
deleteFromTestTables();
|
||||
@ -999,16 +1026,15 @@ class OrderedDependedTestsExtension implements TestWatcher, BeforeEachCallback {
|
||||
|
||||
private static boolean previousTestsPassed = true;
|
||||
|
||||
public void testAborted(ExtensionContext context, Throwable cause) {
|
||||
previousTestsPassed = false;
|
||||
}
|
||||
|
||||
public void testFailed(ExtensionContext context, Throwable cause) {
|
||||
previousTestsPassed = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeEach(final ExtensionContext extensionContext) throws Exception {
|
||||
public void beforeEach(final ExtensionContext extensionContext) {
|
||||
if (!previousTestsPassed) {
|
||||
System.err.println("ignoring because previous fest has failed");
|
||||
}
|
||||
assumeThat(previousTestsPassed).isTrue();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user