import-legacy-ids-of-booking-items-and-hosting-assets #101
@ -45,7 +45,6 @@ import static java.lang.Boolean.parseBoolean;
|
|||||||
import static java.util.Arrays.stream;
|
import static java.util.Arrays.stream;
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.Optional.ofNullable;
|
import static java.util.Optional.ofNullable;
|
||||||
import static java.util.stream.Collectors.joining;
|
|
||||||
import static net.hostsharing.hsadminng.mapper.Array.emptyArray;
|
import static net.hostsharing.hsadminng.mapper.Array.emptyArray;
|
||||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@ -353,12 +352,6 @@ public class CsvDataImport extends ContextBasedTest {
|
|||||||
.executeUpdate()
|
.executeUpdate()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String fetchFirstLegacyIds(final String table) {
|
|
||||||
return ((List<List<?>>) em.createNativeQuery(
|
|
||||||
"SELECT * FROM " + table + "_legacy_id WHERE legacy_id is not null ORDER BY legacy_id LIMIT 10",
|
|
||||||
List.class).getResultList()).stream().map(row -> row.get(1).toString()).collect(joining("\n"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Columns {
|
class Columns {
|
||||||
|
@ -766,7 +766,7 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
|||||||
@Order(19019)
|
@Order(19019)
|
||||||
void verifyBookingItemLegacyIds() {
|
void verifyBookingItemLegacyIds() {
|
||||||
assumeThatWeAreImportingControlledTestData();
|
assumeThatWeAreImportingControlledTestData();
|
||||||
assertThat(fetchFirstLegacyIds("hs_booking_item")).isEqualTo("""
|
assertThat(fetchBookingItemLegacyIds()).isEqualTo("""
|
||||||
1000000021
|
1000000021
|
||||||
1000000022
|
1000000022
|
||||||
1000000023
|
1000000023
|
||||||
@ -777,6 +777,14 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
|||||||
1000000028
|
1000000028
|
||||||
1000000029
|
1000000029
|
||||||
1000000030
|
1000000030
|
||||||
|
1000000031
|
||||||
|
1000000032
|
||||||
|
1000000033
|
||||||
|
1000000034
|
||||||
|
1000000035
|
||||||
|
1000000036
|
||||||
|
1000000037
|
||||||
|
1000000038
|
||||||
""".trim());
|
""".trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -957,6 +965,132 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(19930)
|
@Order(19930)
|
||||||
|
void verifyCloudServerLegacyIds() {
|
||||||
|
assumeThatWeAreImportingControlledTestData();
|
||||||
|
assertThat(fetchHosingAsetLegacyIds(CLOUD_SERVER)).isEqualTo("""
|
||||||
|
23611
|
||||||
|
""".trim());
|
||||||
|
assertThat(missingHostingAsstLegacyIds(CLOUD_SERVER)).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(19931)
|
||||||
|
void verifyManagedServerLegacyIds() {
|
||||||
|
assumeThatWeAreImportingControlledTestData();
|
||||||
|
assertThat(fetchHosingAsetLegacyIds(MANAGED_SERVER)).isEqualTo("""
|
||||||
|
10968
|
||||||
|
10978
|
||||||
|
11061
|
||||||
|
11447
|
||||||
|
""".trim());
|
||||||
|
assertThat(missingHostingAsstLegacyIds(MANAGED_SERVER)).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(19932)
|
||||||
|
void verifyManagedWebspaceLegacyIds() {
|
||||||
|
assumeThatWeAreImportingControlledTestData();
|
||||||
|
assertThat(fetchHosingAsetLegacyIds(MANAGED_WEBSPACE)).isEqualTo("""
|
||||||
|
10630
|
||||||
|
11094
|
||||||
|
11111
|
||||||
|
11112
|
||||||
|
19959
|
||||||
|
""".trim());
|
||||||
|
assertThat(missingHostingAsstLegacyIds(MANAGED_WEBSPACE)).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(19933)
|
||||||
|
void verifyUnixUserLegacyIds() {
|
||||||
|
assumeThatWeAreImportingControlledTestData();
|
||||||
|
assertThat(fetchHosingAsetLegacyIds(UNIX_USER)).isEqualTo("""
|
||||||
|
5803
|
||||||
|
5805
|
||||||
|
5809
|
||||||
|
5811
|
||||||
|
5813
|
||||||
|
5835
|
||||||
|
5961
|
||||||
|
5964
|
||||||
|
5966
|
||||||
|
5990
|
||||||
|
6705
|
||||||
|
6824
|
||||||
|
7846
|
||||||
|
9546
|
||||||
|
9596
|
||||||
|
""".trim());
|
||||||
|
assertThat(missingHostingAsstLegacyIds(UNIX_USER)).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(19934)
|
||||||
|
void verifyPgSqlDbLegacyIds() {
|
||||||
|
assumeThatWeAreImportingControlledTestData();
|
||||||
|
assertThat(fetchHosingAsetLegacyIds(PGSQL_DATABASE)).isEqualTo("""
|
||||||
|
1077
|
||||||
|
1858
|
||||||
|
1860
|
||||||
|
4931
|
||||||
|
4932
|
||||||
|
7522
|
||||||
|
7523
|
||||||
|
7605
|
||||||
|
""".trim());
|
||||||
|
assertThat(missingHostingAsstLegacyIds(PGSQL_DATABASE)).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(19934)
|
||||||
|
void verifyPgSqlUserLegacyIds() {
|
||||||
|
assumeThatWeAreImportingControlledTestData();
|
||||||
|
assertThat(fetchHosingAsetLegacyIds(PGSQL_USER)).isEqualTo("""
|
||||||
|
1857
|
||||||
|
1859
|
||||||
|
1860
|
||||||
|
1861
|
||||||
|
4931
|
||||||
|
7522
|
||||||
|
7605
|
||||||
|
""".trim());
|
||||||
|
assertThat(missingHostingAsstLegacyIds(PGSQL_USER)).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(19935)
|
||||||
|
void verifyMariaDbLegacyIds() {
|
||||||
|
assumeThatWeAreImportingControlledTestData();
|
||||||
|
assertThat(fetchHosingAsetLegacyIds(MARIADB_DATABASE)).isEqualTo("""
|
||||||
|
1786
|
||||||
|
1805
|
||||||
|
4908
|
||||||
|
4941
|
||||||
|
4942
|
||||||
|
7520
|
||||||
|
7521
|
||||||
|
7604
|
||||||
|
""".trim());
|
||||||
|
assertThat(missingHostingAsstLegacyIds(MARIADB_DATABASE)).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(19936)
|
||||||
|
void verifyMariaDbUserLegacyIds() {
|
||||||
|
assumeThatWeAreImportingControlledTestData();
|
||||||
|
assertThat(fetchHosingAsetLegacyIds(MARIADB_USER)).isEqualTo("""
|
||||||
|
1858
|
||||||
|
4908
|
||||||
|
4909
|
||||||
|
4932
|
||||||
|
7520
|
||||||
|
7604
|
||||||
|
""".trim());
|
||||||
|
assertThat(missingHostingAsstLegacyIds(MARIADB_USER)).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(19940)
|
||||||
void verifyProjectAgentsCanViewEmailAddresses() {
|
void verifyProjectAgentsCanViewEmailAddresses() {
|
||||||
assumeThatWeAreImportingControlledTestData();
|
assumeThatWeAreImportingControlledTestData();
|
||||||
|
|
||||||
@ -971,24 +1105,6 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
|||||||
|
|
||||||
// ============================================================================================
|
// ============================================================================================
|
||||||
|
|
||||||
@Test
|
|
||||||
@Order(19998)
|
|
||||||
void verifyHostingAssetLegacyIds() {
|
|
||||||
assumeThatWeAreImportingControlledTestData();
|
|
||||||
assertThat(fetchFirstLegacyIds("hs_hosting_asset")).isEqualTo("""
|
|
||||||
0
|
|
||||||
1
|
|
||||||
2
|
|
||||||
3
|
|
||||||
4
|
|
||||||
5
|
|
||||||
6
|
|
||||||
7
|
|
||||||
363
|
|
||||||
381
|
|
||||||
""".trim());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(19999)
|
@Order(19999)
|
||||||
void logErrorsAfterPersistingHostingAssets() {
|
void logErrorsAfterPersistingHostingAssets() {
|
||||||
@ -1801,4 +1917,45 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
|||||||
protected static void assumeThatWeAreImportingControlledTestData() {
|
protected static void assumeThatWeAreImportingControlledTestData() {
|
||||||
assumeThat(isImportingControlledTestData()).isTrue();
|
assumeThat(isImportingControlledTestData()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String fetchBookingItemLegacyIds() {
|
||||||
|
return ((List<List<?>>) em.createNativeQuery(
|
||||||
|
"""
|
||||||
|
SELECT * FROM hs_booking_item_legacy_id
|
||||||
|
WHERE legacy_id IS NOT NULL
|
||||||
|
ORDER BY legacy_id
|
||||||
|
""",
|
||||||
|
List.class).getResultList()).stream().map(row -> row.get(1).toString()).collect(joining("\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String fetchHosingAsetLegacyIds(final HsHostingAssetType type) {
|
||||||
|
//noinspection unchecked
|
||||||
|
return ((List<List<?>>) em.createNativeQuery(
|
||||||
|
"""
|
||||||
|
SELECT li.* FROM hs_hosting_asset_legacy_id li
|
||||||
|
JOIN hs_hosting_asset ha ON ha.uuid=li.uuid
|
||||||
|
WHERE CAST(ha.type AS text)=:type
|
||||||
|
ORDER BY legacy_id
|
||||||
|
""",
|
||||||
|
List.class)
|
||||||
|
.setParameter("type", type.name())
|
||||||
|
.getResultList()
|
||||||
|
).stream().map(row -> row.get(1).toString()).collect(joining("\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String missingHostingAsstLegacyIds(final HsHostingAssetType type) {
|
||||||
|
//noinspection unchecked
|
||||||
|
return ((List<List<?>>) em.createNativeQuery(
|
||||||
|
"""
|
||||||
|
SELECT ha.uuid, ha.type, ha.identifier FROM hs_hosting_asset ha
|
||||||
|
JOIN hs_hosting_asset_legacy_id li ON li.uuid=ha.uuid
|
||||||
|
WHERE li.legacy_id is null AND CAST(ha.type AS text)=:type
|
||||||
|
ORDER BY li.legacy_id
|
||||||
|
""",
|
||||||
|
List.class)
|
||||||
|
.setParameter("type", type.name())
|
||||||
|
.getResultList()).stream()
|
||||||
|
.map(row -> row.stream().map(Object::toString).collect(joining(", ")))
|
||||||
|
.collect(joining("\n"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user