Compare commits
5 Commits
731fa369ad
...
2c24a2f593
Author | SHA1 | Date | |
---|---|---|---|
|
2c24a2f593 | ||
|
a28d1b9a1e | ||
|
2c34b577fb | ||
|
eefde7443c | ||
|
ce26f4665f |
@ -11,11 +11,12 @@ class HsCloudServerBookingItemValidator extends HsBookingItemEntityValidator {
|
|||||||
// @formatter:off
|
// @formatter:off
|
||||||
booleanProperty("active") .withDefault(true),
|
booleanProperty("active") .withDefault(true),
|
||||||
|
|
||||||
integerProperty("CPUs") .min( 1) .max( 32) .required(),
|
integerProperty("CPU") .min( 1) .max( 32) .required(),
|
||||||
integerProperty("RAM").unit("GB") .min( 1) .max( 128) .required(),
|
integerProperty("RAM").unit("GB") .min( 1) .max( 8192) .required(),
|
||||||
integerProperty("SSD").unit("GB") .min( 0) .max( 1000) .step(25).required(), // (1)
|
integerProperty("SSD").unit("GB") .min( 0) .max( 1000) .step(25).optional(), // (1) // FIXME: required()vvv
|
||||||
integerProperty("HDD").unit("GB") .min( 0) .max( 4000) .step(250).withDefault(0),
|
integerProperty("HDD").unit("GB") .min( 0) .max( 4000) .step(250).withDefault(0),
|
||||||
integerProperty("Traffic").unit("GB") .min(250) .max(10000) .step(250).required(),
|
integerProperty("Traffic").unit("GB") .min(250) .max(10000) .step(250).optional(), // FIXME: required()
|
||||||
|
integerProperty("Bandwidth").unit("GB") .min(250) .max(10000) .step(250).optional(), // TODO.spec
|
||||||
|
|
||||||
enumerationProperty("SLA-Infrastructure").values("BASIC", "EXT8H", "EXT4H", "EXT2H").optional()
|
enumerationProperty("SLA-Infrastructure").values("BASIC", "EXT8H", "EXT4H", "EXT2H").optional()
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
@ -10,11 +10,12 @@ class HsManagedServerBookingItemValidator extends HsBookingItemEntityValidator {
|
|||||||
|
|
||||||
HsManagedServerBookingItemValidator() {
|
HsManagedServerBookingItemValidator() {
|
||||||
super(
|
super(
|
||||||
integerProperty("CPUs").min(1).max(32).required(),
|
integerProperty("CPU").min(1).max(32).required(),
|
||||||
integerProperty("RAM").unit("GB").min(1).max(128).required(),
|
integerProperty("RAM").unit("GB").min(1).max(128).required(),
|
||||||
integerProperty("SSD").unit("GB").min(25).max(1000).step(25).required().asTotalLimit().withThreshold(200),
|
integerProperty("SSD").unit("GB").min(25).max(2000).step(25).optional().asTotalLimit().withThreshold(200), // FIXME: required()
|
||||||
integerProperty("HDD").unit("GB").min(0).max(4000).step(250).withDefault(0).asTotalLimit().withThreshold(200),
|
integerProperty("HDD").unit("GB").min(0).max(10000).step(250).withDefault(0).asTotalLimit().withThreshold(200),
|
||||||
integerProperty("Traffic").unit("GB").min(250).max(10000).step(250).required().asTotalLimit().withThreshold(200),
|
integerProperty("Traffic").unit("GB").min(250).max(64000).step(250).required().asTotalLimit().withThreshold(200),
|
||||||
|
integerProperty("Bandwidth").unit("GB").min(250).max(64000).step(250).optional().asTotalLimit().withThreshold(200), // TODO.spec
|
||||||
enumerationProperty("SLA-Platform").values("BASIC", "EXT8H", "EXT4H", "EXT2H").withDefault("BASIC"),
|
enumerationProperty("SLA-Platform").values("BASIC", "EXT8H", "EXT4H", "EXT2H").withDefault("BASIC"),
|
||||||
booleanProperty("SLA-EMail").falseIf("SLA-Platform", "BASIC").withDefault(false),
|
booleanProperty("SLA-EMail").falseIf("SLA-Platform", "BASIC").withDefault(false),
|
||||||
booleanProperty("SLA-Maria").falseIf("SLA-Platform", "BASIC").optional(),
|
booleanProperty("SLA-Maria").falseIf("SLA-Platform", "BASIC").optional(),
|
||||||
|
@ -23,15 +23,16 @@ class HsManagedWebspaceBookingItemValidator extends HsBookingItemEntityValidator
|
|||||||
|
|
||||||
public HsManagedWebspaceBookingItemValidator() {
|
public HsManagedWebspaceBookingItemValidator() {
|
||||||
super(
|
super(
|
||||||
integerProperty("SSD").unit("GB").min(1).max(100).step(1).required(),
|
integerProperty("SSD").unit("GB").min(1).max(2000).step(1).required(),
|
||||||
integerProperty("HDD").unit("GB").min(0).max(250).step(10).optional(),
|
integerProperty("HDD").unit("GB").min(0).max(10000).step(10).optional(),
|
||||||
integerProperty("Traffic").unit("GB").min(10).max(1000).step(10).required(),
|
integerProperty("Traffic").unit("GB").min(10).max(64000).step(10).required(),
|
||||||
|
integerProperty("Bandwidth").unit("GB").min(10).max(1000).step(10).optional(), // TODO.spec
|
||||||
integerProperty("Multi").min(1).max(100).step(1).withDefault(1)
|
integerProperty("Multi").min(1).max(100).step(1).withDefault(1)
|
||||||
.eachComprising( 25, unixUsers())
|
.eachComprising( 25, unixUsers())
|
||||||
.eachComprising( 5, databaseUsers())
|
.eachComprising( 5, databaseUsers())
|
||||||
.eachComprising( 5, databases())
|
.eachComprising( 5, databases())
|
||||||
.eachComprising(250, eMailAddresses()),
|
.eachComprising(250, eMailAddresses()),
|
||||||
integerProperty("Daemons").min(0).max(10).withDefault(0),
|
integerProperty("Daemons").min(0).max(16).withDefault(0),
|
||||||
booleanProperty("Online Office Server").optional(),
|
booleanProperty("Online Office Server").optional(),
|
||||||
enumerationProperty("SLA-Platform").values("BASIC", "EXT24H").withDefault("BASIC")
|
enumerationProperty("SLA-Platform").values("BASIC", "EXT24H").withDefault("BASIC")
|
||||||
);
|
);
|
||||||
|
@ -7,15 +7,16 @@ class HsPrivateCloudBookingItemValidator extends HsBookingItemEntityValidator {
|
|||||||
HsPrivateCloudBookingItemValidator() {
|
HsPrivateCloudBookingItemValidator() {
|
||||||
super(
|
super(
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
integerProperty("CPUs") .min( 1).max( 128).required().asTotalLimit(),
|
integerProperty("CPU") .min( 1).max( 128).required().asTotalLimit(),
|
||||||
integerProperty("RAM").unit("GB") .min( 1).max( 512).required().asTotalLimit(),
|
integerProperty("RAM").unit("GB") .min( 1).max( 512).required().asTotalLimit(),
|
||||||
integerProperty("SSD").unit("GB") .min( 25).max( 4000).step(25).required().asTotalLimit(),
|
integerProperty("SSD").unit("GB") .min( 25).max( 4000).step(25).required().asTotalLimit(),
|
||||||
integerProperty("HDD").unit("GB") .min( 0).max(16000).step(250).withDefault(0).asTotalLimit(),
|
integerProperty("HDD").unit("GB") .min( 0).max(16000).step(250).withDefault(0).asTotalLimit(),
|
||||||
integerProperty("Traffic").unit("GB") .min(250).max(40000).step(250).required().asTotalLimit(),
|
integerProperty("Traffic").unit("GB") .min(250).max(64000).step(250).required().asTotalLimit(),
|
||||||
|
integerProperty("Bandwidth").unit("GB") .min(250).max(64000).step(250).optional().asTotalLimit(), // TODO.spec
|
||||||
|
|
||||||
// Alternatively we could specify it similarly to "Multi" option but exclusively counting:
|
// Alternatively we could specify it similarly to "Multi" option but exclusively counting:
|
||||||
// integerProperty("Resource-Points") .min(4).max(100).required()
|
// integerProperty("Resource-Points") .min(4).max(100).required()
|
||||||
// .each("CPUs").countsAs(64)
|
// .each("CPU").countsAs(64)
|
||||||
// .each("RAM").countsAs(64)
|
// .each("RAM").countsAs(64)
|
||||||
// .each("SSD").countsAs(18)
|
// .each("SSD").countsAs(18)
|
||||||
// .each("HDD").countsAs(2)
|
// .each("HDD").countsAs(2)
|
||||||
|
@ -33,11 +33,11 @@ begin
|
|||||||
managedServerUuid := uuid_generate_v4();
|
managedServerUuid := uuid_generate_v4();
|
||||||
insert
|
insert
|
||||||
into hs_booking_item (uuid, projectuuid, type, parentitemuuid, caption, validity, resources)
|
into hs_booking_item (uuid, projectuuid, type, parentitemuuid, caption, validity, resources)
|
||||||
values (privateCloudUuid, relatedProject.uuid, 'PRIVATE_CLOUD', null, 'some PrivateCloud', daterange('20240401', null, '[]'), '{ "CPUs": 10, "RAM": 32, "SSD": 4000, "HDD": 10000, "Traffic": 2000 }'::jsonb),
|
values (privateCloudUuid, relatedProject.uuid, 'PRIVATE_CLOUD', null, 'some PrivateCloud', daterange('20240401', null, '[]'), '{ "CPU": 10, "RAM": 32, "SSD": 4000, "HDD": 10000, "Traffic": 2000 }'::jsonb),
|
||||||
(uuid_generate_v4(), null, 'MANAGED_SERVER', privateCloudUuid, 'some ManagedServer', daterange('20230115', '20240415', '[)'), '{ "CPUs": 2, "RAM": 4, "SSD": 500, "Traffic": 500 }'::jsonb),
|
(uuid_generate_v4(), null, 'MANAGED_SERVER', privateCloudUuid, 'some ManagedServer', daterange('20230115', '20240415', '[)'), '{ "CPU": 2, "RAM": 4, "SSD": 500, "Traffic": 500 }'::jsonb),
|
||||||
(uuid_generate_v4(), null, 'CLOUD_SERVER', privateCloudUuid, 'test CloudServer', daterange('20230115', '20240415', '[)'), '{ "CPUs": 2, "RAM": 4, "SSD": 750, "Traffic": 500 }'::jsonb),
|
(uuid_generate_v4(), null, 'CLOUD_SERVER', privateCloudUuid, 'test CloudServer', daterange('20230115', '20240415', '[)'), '{ "CPU": 2, "RAM": 4, "SSD": 750, "Traffic": 500 }'::jsonb),
|
||||||
(uuid_generate_v4(), null, 'CLOUD_SERVER', privateCloudUuid, 'prod CloudServer', daterange('20230115', '20240415', '[)'), '{ "CPUs": 4, "RAM": 16, "SSD": 1000, "Traffic": 500 }'::jsonb),
|
(uuid_generate_v4(), null, 'CLOUD_SERVER', privateCloudUuid, 'prod CloudServer', daterange('20230115', '20240415', '[)'), '{ "CPU": 4, "RAM": 16, "SSD": 1000, "Traffic": 500 }'::jsonb),
|
||||||
(managedServerUuid, relatedProject.uuid, 'MANAGED_SERVER', null, 'separate ManagedServer', daterange('20221001', null, '[]'), '{ "CPUs": 2, "RAM": 8, "SSD": 500, "Traffic": 500 }'::jsonb),
|
(managedServerUuid, relatedProject.uuid, 'MANAGED_SERVER', null, 'separate ManagedServer', daterange('20221001', null, '[]'), '{ "CPU": 2, "RAM": 8, "SSD": 500, "Traffic": 500 }'::jsonb),
|
||||||
(uuid_generate_v4(), null, 'MANAGED_WEBSPACE', managedServerUuid, 'some ManagedWebspace', daterange('20221001', null, '[]'), '{ "SSD": 50, "Traffic": 20, "Daemons": 2, "Multi": 4 }'::jsonb),
|
(uuid_generate_v4(), null, 'MANAGED_WEBSPACE', managedServerUuid, 'some ManagedWebspace', daterange('20221001', null, '[]'), '{ "SSD": 50, "Traffic": 20, "Daemons": 2, "Multi": 4 }'::jsonb),
|
||||||
(uuid_generate_v4(), relatedProject.uuid, 'MANAGED_WEBSPACE', null, 'separate ManagedWebspace', daterange('20221001', null, '[]'), '{ "SSD": 100, "Traffic": 50, "Daemons": 0, "Multi": 1 }'::jsonb);
|
(uuid_generate_v4(), relatedProject.uuid, 'MANAGED_WEBSPACE', null, 'separate ManagedWebspace', daterange('20221001', null, '[]'), '{ "SSD": 100, "Traffic": 50, "Daemons": 0, "Multi": 1 }'::jsonb);
|
||||||
end; $$;
|
end; $$;
|
||||||
|
@ -101,7 +101,7 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
|||||||
"resources": {
|
"resources": {
|
||||||
"RAM": 8,
|
"RAM": 8,
|
||||||
"SSD": 500,
|
"SSD": 500,
|
||||||
"CPUs": 2,
|
"CPU": 2,
|
||||||
"Traffic": 500
|
"Traffic": 500
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -114,7 +114,7 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
|||||||
"HDD": 10000,
|
"HDD": 10000,
|
||||||
"RAM": 32,
|
"RAM": 32,
|
||||||
"SSD": 4000,
|
"SSD": 4000,
|
||||||
"CPUs": 10,
|
"CPU": 10,
|
||||||
"Traffic": 2000
|
"Traffic": 2000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
|||||||
"type": "MANAGED_SERVER",
|
"type": "MANAGED_SERVER",
|
||||||
"caption": "some new booking",
|
"caption": "some new booking",
|
||||||
"validTo": "{validTo}",
|
"validTo": "{validTo}",
|
||||||
"resources": { "CPUs": 12, "RAM": 4, "SSD": 100, "Traffic": 250 }
|
"resources": { "CPU": 12, "RAM": 4, "SSD": 100, "Traffic": 250 }
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
.replace("{projectUuid}", givenProject.getUuid().toString())
|
.replace("{projectUuid}", givenProject.getUuid().toString())
|
||||||
@ -166,7 +166,7 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
|||||||
"caption": "some new booking",
|
"caption": "some new booking",
|
||||||
"validFrom": "{today}",
|
"validFrom": "{today}",
|
||||||
"validTo": "{todayPlus1Month}",
|
"validTo": "{todayPlus1Month}",
|
||||||
"resources": { "CPUs": 12, "SSD": 100, "Traffic": 250 }
|
"resources": { "CPU": 12, "SSD": 100, "Traffic": 250 }
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
.replace("{today}", LocalDate.now().toString())
|
.replace("{today}", LocalDate.now().toString())
|
||||||
@ -267,7 +267,7 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
|||||||
"resources": {
|
"resources": {
|
||||||
"RAM": 8,
|
"RAM": 8,
|
||||||
"SSD": 500,
|
"SSD": 500,
|
||||||
"CPUs": 2,
|
"CPU": 2,
|
||||||
"Traffic": 500
|
"Traffic": 500
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ class HsBookingItemControllerRestTest {
|
|||||||
"caption": "some new booking",
|
"caption": "some new booking",
|
||||||
"validTo": "{validTo}",
|
"validTo": "{validTo}",
|
||||||
"garbage": "should not be accepted",
|
"garbage": "should not be accepted",
|
||||||
"resources": { "CPUs": 12, "RAM": 4, "SSD": 100, "Traffic": 250 }
|
"resources": { "CPU": 12, "RAM": 4, "SSD": 100, "Traffic": 250 }
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
.replace("{projectUuid}", givenProjectUuid.toString())
|
.replace("{projectUuid}", givenProjectUuid.toString())
|
||||||
@ -108,7 +108,7 @@ class HsBookingItemControllerRestTest {
|
|||||||
"caption": "some new booking",
|
"caption": "some new booking",
|
||||||
"validFrom": "{today}",
|
"validFrom": "{today}",
|
||||||
"validTo": "{todayPlus1Month}",
|
"validTo": "{todayPlus1Month}",
|
||||||
"resources": { "CPUs": 12, "SSD": 100, "Traffic": 250 }
|
"resources": { "CPU": 12, "SSD": 100, "Traffic": 250 }
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
.replace("{today}", LocalDate.now().toString())
|
.replace("{today}", LocalDate.now().toString())
|
||||||
@ -141,7 +141,7 @@ class HsBookingItemControllerRestTest {
|
|||||||
"type": "MANAGED_SERVER",
|
"type": "MANAGED_SERVER",
|
||||||
"caption": "some new booking",
|
"caption": "some new booking",
|
||||||
"validFrom": "{validFrom}",
|
"validFrom": "{validFrom}",
|
||||||
"resources": { "CPUs": 12, "RAM": 4, "SSD": 100, "Traffic": 250 }
|
"resources": { "CPU": 12, "RAM": 4, "SSD": 100, "Traffic": 250 }
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
.replace("{projectUuid}", givenProjectUuid.toString())
|
.replace("{projectUuid}", givenProjectUuid.toString())
|
||||||
@ -159,7 +159,7 @@ class HsBookingItemControllerRestTest {
|
|||||||
"caption": "some new booking",
|
"caption": "some new booking",
|
||||||
"validFrom": "{today}",
|
"validFrom": "{today}",
|
||||||
"validTo": null,
|
"validTo": null,
|
||||||
"resources": { "CPUs": 12, "SSD": 100, "Traffic": 250 }
|
"resources": { "CPU": 12, "SSD": 100, "Traffic": 250 }
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
.replace("{today}", LocalDate.now().toString())
|
.replace("{today}", LocalDate.now().toString())
|
||||||
|
@ -25,7 +25,7 @@ class HsBookingItemEntityUnitTest {
|
|||||||
.type(HsBookingItemType.CLOUD_SERVER)
|
.type(HsBookingItemType.CLOUD_SERVER)
|
||||||
.caption("some caption")
|
.caption("some caption")
|
||||||
.resources(Map.ofEntries(
|
.resources(Map.ofEntries(
|
||||||
entry("CPUs", 2),
|
entry("CPU", 2),
|
||||||
entry("SSD-storage", 512),
|
entry("SSD-storage", 512),
|
||||||
entry("HDD-storage", 2048)))
|
entry("HDD-storage", 2048)))
|
||||||
.validity(toPostgresDateRange(GIVEN_VALID_FROM, GIVEN_VALID_TO))
|
.validity(toPostgresDateRange(GIVEN_VALID_FROM, GIVEN_VALID_TO))
|
||||||
|
@ -211,7 +211,7 @@ class HsBookingItemRepositoryIntegrationTest extends ContextBasedTestWithCleanup
|
|||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var foundBookingItem = em.find(HsBookingItemEntity.class, givenBookingItemUuid);
|
final var foundBookingItem = em.find(HsBookingItemEntity.class, givenBookingItemUuid);
|
||||||
foundBookingItem.getResources().put("CPUs", 2);
|
foundBookingItem.getResources().put("CPU", 2);
|
||||||
foundBookingItem.getResources().remove("SSD-storage");
|
foundBookingItem.getResources().remove("SSD-storage");
|
||||||
foundBookingItem.getResources().put("HSD-storage", 2048);
|
foundBookingItem.getResources().put("HSD-storage", 2048);
|
||||||
foundBookingItem.setValidity(Range.closedOpen(
|
foundBookingItem.setValidity(Range.closedOpen(
|
||||||
@ -336,7 +336,7 @@ class HsBookingItemRepositoryIntegrationTest extends ContextBasedTestWithCleanup
|
|||||||
.validity(Range.closedOpen(
|
.validity(Range.closedOpen(
|
||||||
LocalDate.parse("2020-01-01"), LocalDate.parse("2023-01-01")))
|
LocalDate.parse("2020-01-01"), LocalDate.parse("2023-01-01")))
|
||||||
.resources(Map.ofEntries(
|
.resources(Map.ofEntries(
|
||||||
entry("CPUs", 1),
|
entry("CPU", 1),
|
||||||
entry("SSD-storage", 256)))
|
entry("SSD-storage", 256)))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ public class TestHsBookingItem {
|
|||||||
.type(HsBookingItemType.CLOUD_SERVER)
|
.type(HsBookingItemType.CLOUD_SERVER)
|
||||||
.caption("test cloud server booking item")
|
.caption("test cloud server booking item")
|
||||||
.resources(Map.ofEntries(
|
.resources(Map.ofEntries(
|
||||||
entry("CPUs", 2),
|
entry("CPU", 2),
|
||||||
entry("RAM", 4),
|
entry("RAM", 4),
|
||||||
entry("SSD", 50),
|
entry("SSD", 50),
|
||||||
entry("Traffic", 250)
|
entry("Traffic", 250)
|
||||||
@ -30,7 +30,7 @@ public class TestHsBookingItem {
|
|||||||
.type(HsBookingItemType.MANAGED_SERVER)
|
.type(HsBookingItemType.MANAGED_SERVER)
|
||||||
.caption("test project booking item")
|
.caption("test project booking item")
|
||||||
.resources(Map.ofEntries(
|
.resources(Map.ofEntries(
|
||||||
entry("CPUs", 2),
|
entry("CPU", 2),
|
||||||
entry("RAM", 4),
|
entry("RAM", 4),
|
||||||
entry("SSD", 50),
|
entry("SSD", 50),
|
||||||
entry("Traffic", 250)
|
entry("Traffic", 250)
|
||||||
|
@ -33,7 +33,7 @@ class HsCloudServerBookingItemValidatorUnitTest {
|
|||||||
.project(project)
|
.project(project)
|
||||||
.caption("Test-Server")
|
.caption("Test-Server")
|
||||||
.resources(Map.ofEntries(
|
.resources(Map.ofEntries(
|
||||||
entry("CPUs", 2),
|
entry("CPU", 2),
|
||||||
entry("RAM", 25),
|
entry("RAM", 25),
|
||||||
entry("SSD", 25),
|
entry("SSD", 25),
|
||||||
entry("Traffic", 250),
|
entry("Traffic", 250),
|
||||||
@ -71,7 +71,7 @@ class HsCloudServerBookingItemValidatorUnitTest {
|
|||||||
.type(CLOUD_SERVER)
|
.type(CLOUD_SERVER)
|
||||||
.caption("Test Cloud-Server")
|
.caption("Test Cloud-Server")
|
||||||
.resources(ofEntries(
|
.resources(ofEntries(
|
||||||
entry("CPUs", 2),
|
entry("CPU", 2),
|
||||||
entry("RAM", 10),
|
entry("RAM", 10),
|
||||||
entry("SSD", 50),
|
entry("SSD", 50),
|
||||||
entry("Traffic", 2500)
|
entry("Traffic", 2500)
|
||||||
@ -81,7 +81,7 @@ class HsCloudServerBookingItemValidatorUnitTest {
|
|||||||
.type(MANAGED_SERVER)
|
.type(MANAGED_SERVER)
|
||||||
.caption("Test Managed-Server")
|
.caption("Test Managed-Server")
|
||||||
.resources(ofEntries(
|
.resources(ofEntries(
|
||||||
entry("CPUs", 3),
|
entry("CPU", 3),
|
||||||
entry("RAM", 20),
|
entry("RAM", 20),
|
||||||
entry("SSD", 100),
|
entry("SSD", 100),
|
||||||
entry("Traffic", 3000)
|
entry("Traffic", 3000)
|
||||||
@ -92,7 +92,7 @@ class HsCloudServerBookingItemValidatorUnitTest {
|
|||||||
.project(project)
|
.project(project)
|
||||||
.caption("Test Cloud")
|
.caption("Test Cloud")
|
||||||
.resources(ofEntries(
|
.resources(ofEntries(
|
||||||
entry("CPUs", 4),
|
entry("CPU", 4),
|
||||||
entry("RAM", 20),
|
entry("RAM", 20),
|
||||||
entry("SSD", 100),
|
entry("SSD", 100),
|
||||||
entry("Traffic", 5000)
|
entry("Traffic", 5000)
|
||||||
|
@ -40,7 +40,7 @@ class HsManagedServerBookingItemValidatorUnitTest {
|
|||||||
.type(MANAGED_SERVER)
|
.type(MANAGED_SERVER)
|
||||||
.project(project)
|
.project(project)
|
||||||
.resources(Map.ofEntries(
|
.resources(Map.ofEntries(
|
||||||
entry("CPUs", 2),
|
entry("CPU", 2),
|
||||||
entry("RAM", 25),
|
entry("RAM", 25),
|
||||||
entry("SSD", 25),
|
entry("SSD", 25),
|
||||||
entry("Traffic", 250),
|
entry("Traffic", 250),
|
||||||
@ -82,7 +82,7 @@ class HsManagedServerBookingItemValidatorUnitTest {
|
|||||||
final var subCloudServerBookingItemEntity = HsBookingItemEntity.builder()
|
final var subCloudServerBookingItemEntity = HsBookingItemEntity.builder()
|
||||||
.type(CLOUD_SERVER)
|
.type(CLOUD_SERVER)
|
||||||
.resources(ofEntries(
|
.resources(ofEntries(
|
||||||
entry("CPUs", 2),
|
entry("CPU", 2),
|
||||||
entry("RAM", 10),
|
entry("RAM", 10),
|
||||||
entry("SSD", 50),
|
entry("SSD", 50),
|
||||||
entry("Traffic", 2500)
|
entry("Traffic", 2500)
|
||||||
@ -91,7 +91,7 @@ class HsManagedServerBookingItemValidatorUnitTest {
|
|||||||
final HsBookingItemEntity subManagedServerBookingItemEntity = HsBookingItemEntity.builder()
|
final HsBookingItemEntity subManagedServerBookingItemEntity = HsBookingItemEntity.builder()
|
||||||
.type(MANAGED_SERVER)
|
.type(MANAGED_SERVER)
|
||||||
.resources(ofEntries(
|
.resources(ofEntries(
|
||||||
entry("CPUs", 3),
|
entry("CPU", 3),
|
||||||
entry("RAM", 20),
|
entry("RAM", 20),
|
||||||
entry("SSD", 100),
|
entry("SSD", 100),
|
||||||
entry("Traffic", 3000)
|
entry("Traffic", 3000)
|
||||||
@ -101,7 +101,7 @@ class HsManagedServerBookingItemValidatorUnitTest {
|
|||||||
.type(PRIVATE_CLOUD)
|
.type(PRIVATE_CLOUD)
|
||||||
.project(project)
|
.project(project)
|
||||||
.resources(ofEntries(
|
.resources(ofEntries(
|
||||||
entry("CPUs", 4),
|
entry("CPU", 4),
|
||||||
entry("RAM", 20),
|
entry("RAM", 20),
|
||||||
entry("SSD", 100),
|
entry("SSD", 100),
|
||||||
entry("Traffic", 5000)
|
entry("Traffic", 5000)
|
||||||
|
@ -29,7 +29,7 @@ class HsManagedWebspaceBookingItemValidatorUnitTest {
|
|||||||
.project(project)
|
.project(project)
|
||||||
.caption("Test Managed-Webspace")
|
.caption("Test Managed-Webspace")
|
||||||
.resources(Map.ofEntries(
|
.resources(Map.ofEntries(
|
||||||
entry("CPUs", 2),
|
entry("CPU", 2),
|
||||||
entry("RAM", 25),
|
entry("RAM", 25),
|
||||||
entry("Traffic", 250),
|
entry("Traffic", 250),
|
||||||
entry("SLA-EMail", true)
|
entry("SLA-EMail", true)
|
||||||
|
@ -30,7 +30,7 @@ class HsPrivateCloudBookingItemValidatorUnitTest {
|
|||||||
.type(PRIVATE_CLOUD)
|
.type(PRIVATE_CLOUD)
|
||||||
.caption("myPC")
|
.caption("myPC")
|
||||||
.resources(ofEntries(
|
.resources(ofEntries(
|
||||||
entry("CPUs", 4),
|
entry("CPU", 4),
|
||||||
entry("RAM", 20),
|
entry("RAM", 20),
|
||||||
entry("SSD", 100),
|
entry("SSD", 100),
|
||||||
entry("Traffic", 5000),
|
entry("Traffic", 5000),
|
||||||
@ -42,7 +42,7 @@ class HsPrivateCloudBookingItemValidatorUnitTest {
|
|||||||
.type(MANAGED_SERVER)
|
.type(MANAGED_SERVER)
|
||||||
.caption("myMS-1")
|
.caption("myMS-1")
|
||||||
.resources(ofEntries(
|
.resources(ofEntries(
|
||||||
entry("CPUs", 2),
|
entry("CPU", 2),
|
||||||
entry("RAM", 10),
|
entry("RAM", 10),
|
||||||
entry("SSD", 50),
|
entry("SSD", 50),
|
||||||
entry("Traffic", 2500),
|
entry("Traffic", 2500),
|
||||||
@ -54,7 +54,7 @@ class HsPrivateCloudBookingItemValidatorUnitTest {
|
|||||||
.type(CLOUD_SERVER)
|
.type(CLOUD_SERVER)
|
||||||
.caption("myMS-2")
|
.caption("myMS-2")
|
||||||
.resources(ofEntries(
|
.resources(ofEntries(
|
||||||
entry("CPUs", 2),
|
entry("CPU", 2),
|
||||||
entry("RAM", 10),
|
entry("RAM", 10),
|
||||||
entry("SSD", 50),
|
entry("SSD", 50),
|
||||||
entry("Traffic", 2500),
|
entry("Traffic", 2500),
|
||||||
@ -80,7 +80,7 @@ class HsPrivateCloudBookingItemValidatorUnitTest {
|
|||||||
.type(PRIVATE_CLOUD)
|
.type(PRIVATE_CLOUD)
|
||||||
.caption("myPC")
|
.caption("myPC")
|
||||||
.resources(ofEntries(
|
.resources(ofEntries(
|
||||||
entry("CPUs", 4),
|
entry("CPU", 4),
|
||||||
entry("RAM", 20),
|
entry("RAM", 20),
|
||||||
entry("SSD", 100),
|
entry("SSD", 100),
|
||||||
entry("Traffic", 5000),
|
entry("Traffic", 5000),
|
||||||
@ -92,7 +92,7 @@ class HsPrivateCloudBookingItemValidatorUnitTest {
|
|||||||
.type(MANAGED_SERVER)
|
.type(MANAGED_SERVER)
|
||||||
.caption("myMS-1")
|
.caption("myMS-1")
|
||||||
.resources(ofEntries(
|
.resources(ofEntries(
|
||||||
entry("CPUs", 3),
|
entry("CPU", 3),
|
||||||
entry("RAM", 20),
|
entry("RAM", 20),
|
||||||
entry("SSD", 100),
|
entry("SSD", 100),
|
||||||
entry("Traffic", 3000),
|
entry("Traffic", 3000),
|
||||||
@ -104,7 +104,7 @@ class HsPrivateCloudBookingItemValidatorUnitTest {
|
|||||||
.type(CLOUD_SERVER)
|
.type(CLOUD_SERVER)
|
||||||
.caption("myMS-2")
|
.caption("myMS-2")
|
||||||
.resources(ofEntries(
|
.resources(ofEntries(
|
||||||
entry("CPUs", 2),
|
entry("CPU", 2),
|
||||||
entry("RAM", 10),
|
entry("RAM", 10),
|
||||||
entry("SSD", 50),
|
entry("SSD", 50),
|
||||||
entry("Traffic", 2500),
|
entry("Traffic", 2500),
|
||||||
|
@ -702,7 +702,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
|||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var project = projectRepo.findByCaption(projectCaption).getFirst();
|
final var project = projectRepo.findByCaption(projectCaption).getFirst();
|
||||||
final var resources = switch (bookingItemType) {
|
final var resources = switch (bookingItemType) {
|
||||||
case MANAGED_SERVER -> Map.<String, Object>ofEntries(entry("CPUs", 1),
|
case MANAGED_SERVER -> Map.<String, Object>ofEntries(entry("CPU", 1),
|
||||||
entry("RAM", 20),
|
entry("RAM", 20),
|
||||||
entry("SSD", 25),
|
entry("SSD", 25),
|
||||||
entry("Traffic", 250));
|
entry("Traffic", 250));
|
||||||
|
@ -16,7 +16,7 @@ class HsHostingAssetEntityUnitTest {
|
|||||||
.identifier("vm1234")
|
.identifier("vm1234")
|
||||||
.caption("some managed asset")
|
.caption("some managed asset")
|
||||||
.config(Map.ofEntries(
|
.config(Map.ofEntries(
|
||||||
entry("CPUs", 2),
|
entry("CPU", 2),
|
||||||
entry("SSD-storage", 512),
|
entry("SSD-storage", 512),
|
||||||
entry("HDD-storage", 2048)))
|
entry("HDD-storage", 2048)))
|
||||||
.build();
|
.build();
|
||||||
@ -27,7 +27,7 @@ class HsHostingAssetEntityUnitTest {
|
|||||||
.identifier("xyz00")
|
.identifier("xyz00")
|
||||||
.caption("some managed webspace")
|
.caption("some managed webspace")
|
||||||
.config(Map.ofEntries(
|
.config(Map.ofEntries(
|
||||||
entry("CPUs", 2),
|
entry("CPU", 2),
|
||||||
entry("SSD-storage", 512),
|
entry("SSD-storage", 512),
|
||||||
entry("HDD-storage", 2048)))
|
entry("HDD-storage", 2048)))
|
||||||
.build();
|
.build();
|
||||||
|
@ -263,7 +263,7 @@ class HsHostingAssetRepositoryIntegrationTest extends ContextBasedTestWithCleanu
|
|||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var foundAsset = em.find(HsHostingAssetEntity.class, givenAssetUuid);
|
final var foundAsset = em.find(HsHostingAssetEntity.class, givenAssetUuid);
|
||||||
foundAsset.getConfig().put("CPUs", 2);
|
foundAsset.getConfig().put("CPU", 2);
|
||||||
foundAsset.getConfig().remove("SSD-storage");
|
foundAsset.getConfig().remove("SSD-storage");
|
||||||
foundAsset.getConfig().put("HSD-storage", 2048);
|
foundAsset.getConfig().put("HSD-storage", 2048);
|
||||||
return toCleanup(assetRepo.save(foundAsset));
|
return toCleanup(assetRepo.save(foundAsset));
|
||||||
@ -404,7 +404,7 @@ class HsHostingAssetRepositoryIntegrationTest extends ContextBasedTestWithCleanu
|
|||||||
.identifier(identifier)
|
.identifier(identifier)
|
||||||
.caption("some temp cloud asset")
|
.caption("some temp cloud asset")
|
||||||
.config(Map.ofEntries(
|
.config(Map.ofEntries(
|
||||||
entry("CPUs", 1),
|
entry("CPU", 1),
|
||||||
entry("SSD-storage", 256)))
|
entry("SSD-storage", 256)))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class HsManagedWebspaceHostingAssetValidatorUnitTest {
|
|||||||
.type(HsBookingItemType.MANAGED_SERVER)
|
.type(HsBookingItemType.MANAGED_SERVER)
|
||||||
.caption("Test Managed-Server")
|
.caption("Test Managed-Server")
|
||||||
.resources(Map.ofEntries(
|
.resources(Map.ofEntries(
|
||||||
entry("CPUs", 2),
|
entry("CPU", 2),
|
||||||
entry("RAM", 25),
|
entry("RAM", 25),
|
||||||
entry("SSD", 25),
|
entry("SSD", 25),
|
||||||
entry("Traffic", 250),
|
entry("Traffic", 250),
|
||||||
|
@ -119,10 +119,14 @@ public class CsvDataImport extends ContextBasedTest {
|
|||||||
|
|
||||||
protected void persist(final Integer id, final RbacObject entity) {
|
protected void persist(final Integer id, final RbacObject entity) {
|
||||||
try {
|
try {
|
||||||
|
final var asString = entity.toString();
|
||||||
|
if ( asString.contains("'null null, null'") || asString.equals("person()")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
//System.out.println("persisting #" + entity.hashCode() + ": " + entity);
|
//System.out.println("persisting #" + entity.hashCode() + ": " + entity);
|
||||||
em.persist(entity);
|
em.persist(entity);
|
||||||
// uncomment for debugging purposes
|
// uncomment for debugging purposes
|
||||||
// em.flush();
|
em.flush();
|
||||||
// System.out.println("persisted #" + entity.hashCode() + " as " + entity.getUuid());
|
// System.out.println("persisted #" + entity.hashCode() + " as " + entity.getUuid());
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
System.err.println("failed to persist #" + entity.hashCode() + ": " + entity);
|
System.err.println("failed to persist #" + entity.hashCode() + ": " + entity);
|
||||||
@ -143,6 +147,62 @@ public class CsvDataImport extends ContextBasedTest {
|
|||||||
.collect(Collectors.joining(",\n")) +
|
.collect(Collectors.joining(",\n")) +
|
||||||
"\n}\n";
|
"\n}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void deleteTestDataFromHsOfficeTables() {
|
||||||
|
jpaAttempt.transacted(() -> {
|
||||||
|
context(rbacSuperuser);
|
||||||
|
em.createNativeQuery("delete from hs_hosting_asset where true").executeUpdate();
|
||||||
|
em.createNativeQuery("delete from hs_booking_item where true").executeUpdate();
|
||||||
|
em.createNativeQuery("delete from hs_booking_project where true").executeUpdate();
|
||||||
|
em.createNativeQuery("delete from hs_office_coopassetstransaction where true").executeUpdate();
|
||||||
|
em.createNativeQuery("delete from hs_office_coopassetstransaction_legacy_id where true").executeUpdate();
|
||||||
|
em.createNativeQuery("delete from hs_office_coopsharestransaction where true").executeUpdate();
|
||||||
|
em.createNativeQuery("delete from hs_office_coopsharestransaction_legacy_id where true").executeUpdate();
|
||||||
|
em.createNativeQuery("delete from hs_office_membership where true").executeUpdate();
|
||||||
|
em.createNativeQuery("delete from hs_office_sepamandate where true").executeUpdate();
|
||||||
|
em.createNativeQuery("delete from hs_office_sepamandate_legacy_id where true").executeUpdate();
|
||||||
|
em.createNativeQuery("delete from hs_office_debitor where true").executeUpdate();
|
||||||
|
em.createNativeQuery("delete from hs_office_bankaccount where true").executeUpdate();
|
||||||
|
em.createNativeQuery("delete from hs_office_partner where true").executeUpdate();
|
||||||
|
em.createNativeQuery("delete from hs_office_partner_details where true").executeUpdate();
|
||||||
|
em.createNativeQuery("delete from hs_office_relation where true").executeUpdate();
|
||||||
|
em.createNativeQuery("delete from hs_office_contact where true").executeUpdate();
|
||||||
|
em.createNativeQuery("delete from hs_office_person where true").executeUpdate();
|
||||||
|
}).assertSuccessful();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void resetHsOfficeSequences() {
|
||||||
|
jpaAttempt.transacted(() -> {
|
||||||
|
context(rbacSuperuser);
|
||||||
|
em.createNativeQuery("alter sequence hs_office_contact_legacy_id_seq restart with 1000000000;").executeUpdate();
|
||||||
|
em.createNativeQuery("alter sequence hs_office_coopassetstransaction_legacy_id_seq restart with 1000000000;")
|
||||||
|
.executeUpdate();
|
||||||
|
em.createNativeQuery("alter sequence public.hs_office_coopsharestransaction_legacy_id_seq restart with 1000000000;")
|
||||||
|
.executeUpdate();
|
||||||
|
em.createNativeQuery("alter sequence public.hs_office_partner_legacy_id_seq restart with 1000000000;")
|
||||||
|
.executeUpdate();
|
||||||
|
em.createNativeQuery("alter sequence public.hs_office_sepamandate_legacy_id_seq restart with 1000000000;")
|
||||||
|
.executeUpdate();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void deleteFromTestTables() {
|
||||||
|
jpaAttempt.transacted(() -> {
|
||||||
|
context(rbacSuperuser);
|
||||||
|
em.createNativeQuery("delete from test_domain where true").executeUpdate();
|
||||||
|
em.createNativeQuery("delete from test_package where true").executeUpdate();
|
||||||
|
em.createNativeQuery("delete from test_customer where true").executeUpdate();
|
||||||
|
}).assertSuccessful();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void deleteFromRbacTables() {
|
||||||
|
jpaAttempt.transacted(() -> {
|
||||||
|
context(rbacSuperuser);
|
||||||
|
em.createNativeQuery("delete from rbacuser_rv where name not like 'superuser-%'").executeUpdate();
|
||||||
|
em.createNativeQuery("delete from tx_journal where true").executeUpdate();
|
||||||
|
em.createNativeQuery("delete from tx_context where true").executeUpdate();
|
||||||
|
}).assertSuccessful();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Columns {
|
class Columns {
|
||||||
|
@ -3,9 +3,13 @@ package net.hostsharing.hsadminng.hs.office.migration;
|
|||||||
import net.hostsharing.hsadminng.context.Context;
|
import net.hostsharing.hsadminng.context.Context;
|
||||||
import net.hostsharing.hsadminng.hs.booking.item.HsBookingItemEntity;
|
import net.hostsharing.hsadminng.hs.booking.item.HsBookingItemEntity;
|
||||||
import net.hostsharing.hsadminng.hs.booking.item.HsBookingItemType;
|
import net.hostsharing.hsadminng.hs.booking.item.HsBookingItemType;
|
||||||
|
import net.hostsharing.hsadminng.hs.booking.item.validators.HsBookingItemEntityValidatorRegistry;
|
||||||
import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetEntity;
|
import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetEntity;
|
||||||
import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType;
|
import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType;
|
||||||
|
import net.hostsharing.hsadminng.hs.hosting.asset.validators.HostingAssetEntitySaveProcessor;
|
||||||
|
import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity;
|
||||||
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
|
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.junit.jupiter.api.MethodOrderer;
|
import org.junit.jupiter.api.MethodOrderer;
|
||||||
import org.junit.jupiter.api.Order;
|
import org.junit.jupiter.api.Order;
|
||||||
import org.junit.jupiter.api.Tag;
|
import org.junit.jupiter.api.Tag;
|
||||||
@ -14,19 +18,25 @@ import org.junit.jupiter.api.TestMethodOrder;
|
|||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
import org.springframework.test.annotation.Commit;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
|
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
import static java.util.Arrays.stream;
|
import static java.util.Arrays.stream;
|
||||||
|
import static java.util.Optional.ofNullable;
|
||||||
import static java.util.stream.Collectors.toMap;
|
import static java.util.stream.Collectors.toMap;
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.CLOUD_SERVER;
|
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.CLOUD_SERVER;
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.IPV4_NUMBER;
|
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.IPV4_NUMBER;
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.MANAGED_SERVER;
|
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.MANAGED_SERVER;
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.MANAGED_WEBSPACE;
|
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.MANAGED_WEBSPACE;
|
||||||
|
import static net.hostsharing.hsadminng.mapper.PostgresDateRange.toPostgresDateRange;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.assertj.core.api.Assumptions.assumeThat;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This 'test' includes the complete legacy 'office' data import.
|
* This 'test' includes the complete legacy 'office' data import.
|
||||||
@ -75,22 +85,20 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
@Import({ Context.class, JpaAttempt.class })
|
@Import({ Context.class, JpaAttempt.class })
|
||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||||
@ExtendWith(OrderedDependedTestsExtension.class)
|
@ExtendWith(OrderedDependedTestsExtension.class)
|
||||||
public class ImportHostingAssets extends CsvDataImport {
|
public class ImportHostingAssets extends ImportOfficeData {
|
||||||
|
|
||||||
private static final Integer IP_NUMBER_ID_OFFSET = 1000000;
|
private static final Integer IP_NUMBER_ID_OFFSET = 1000000;
|
||||||
private static final Integer HIVE_ID_OFFSET = 2000000;
|
private static final Integer HIVE_ID_OFFSET = 2000000;
|
||||||
private static final Integer PACKET_ID_OFFSET = 3000000;
|
private static final Integer PACKET_ID_OFFSET = 3000000;
|
||||||
|
|
||||||
record Hive(int hive_id, String hive_name, int inet_addr_id) {}
|
record Hive(int hive_id, String hive_name, int inet_addr_id, AtomicReference<HsHostingAssetEntity> serverRef) {}
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
private static Map<Integer, HsBookingItemEntity> bookingItems = new WriteOnceMap<>();
|
private static Map<Integer, HsBookingItemEntity> bookingItems = new WriteOnceMap<>();
|
||||||
private static Map<Integer, Hive> hives = new WriteOnceMap<>();
|
private static Map<Integer, Hive> hives = new WriteOnceMap<>();
|
||||||
private static Map<Integer, HsHostingAssetEntity> hostingAssets = new WriteOnceMap<>();
|
private static Map<Integer, HsHostingAssetEntity> hostingAssets = new WriteOnceMap<>();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1010)
|
@Order(2010)
|
||||||
void importIpNumbers() {
|
void importIpNumbers() {
|
||||||
try (Reader reader = resourceReader(MIGRATION_DATA_PATH + "inet_addr.csv")) {
|
try (Reader reader = resourceReader(MIGRATION_DATA_PATH + "inet_addr.csv")) {
|
||||||
final var lines = readAllLines(reader);
|
final var lines = readAllLines(reader);
|
||||||
@ -101,7 +109,7 @@ public class ImportHostingAssets extends CsvDataImport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1019)
|
@Order(2019)
|
||||||
void verifyIpNumbers() {
|
void verifyIpNumbers() {
|
||||||
assumeThatWeAreImportingControlledTestData();
|
assumeThatWeAreImportingControlledTestData();
|
||||||
|
|
||||||
@ -118,7 +126,7 @@ public class ImportHostingAssets extends CsvDataImport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1030)
|
@Order(2030)
|
||||||
void importHives() {
|
void importHives() {
|
||||||
try (Reader reader = resourceReader(MIGRATION_DATA_PATH + "hive.csv")) {
|
try (Reader reader = resourceReader(MIGRATION_DATA_PATH + "hive.csv")) {
|
||||||
final var lines = readAllLines(reader);
|
final var lines = readAllLines(reader);
|
||||||
@ -129,24 +137,24 @@ public class ImportHostingAssets extends CsvDataImport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1039)
|
@Order(2039)
|
||||||
void verifyHives() {
|
void verifyHives() {
|
||||||
assumeThatWeAreImportingControlledTestData();
|
assumeThatWeAreImportingControlledTestData();
|
||||||
|
|
||||||
// no contacts yet => mostly null values
|
// no contacts yet => mostly null values
|
||||||
assertThat(toFormattedString(first(5, hives))).isEqualToIgnoringWhitespace("""
|
assertThat(toFormattedString(first(5, hives))).isEqualToIgnoringWhitespace("""
|
||||||
{
|
{
|
||||||
2000001=Hive[hive_id=1, hive_name=h01, inet_addr_id=358],
|
2000001=Hive[hive_id=1, hive_name=h01, inet_addr_id=358, serverRef=null],
|
||||||
2000002=Hive[hive_id=2, hive_name=h02, inet_addr_id=359],
|
2000002=Hive[hive_id=2, hive_name=h02, inet_addr_id=359, serverRef=null],
|
||||||
2000004=Hive[hive_id=4, hive_name=h03, inet_addr_id=360],
|
2000004=Hive[hive_id=4, hive_name=h03, inet_addr_id=360, serverRef=null],
|
||||||
2000007=Hive[hive_id=7, hive_name=h04, inet_addr_id=361],
|
2000007=Hive[hive_id=7, hive_name=h04, inet_addr_id=361, serverRef=null],
|
||||||
2000013=Hive[hive_id=13, hive_name=h05, inet_addr_id=430]
|
2000013=Hive[hive_id=13, hive_name=h05, inet_addr_id=430, serverRef=null]
|
||||||
}
|
}
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(2000)
|
@Order(3000)
|
||||||
void importPackets() {
|
void importPackets() {
|
||||||
try (Reader reader = resourceReader(MIGRATION_DATA_PATH + "packet.csv")) {
|
try (Reader reader = resourceReader(MIGRATION_DATA_PATH + "packet.csv")) {
|
||||||
final var lines = readAllLines(reader);
|
final var lines = readAllLines(reader);
|
||||||
@ -157,21 +165,21 @@ public class ImportHostingAssets extends CsvDataImport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(2009)
|
@Order(3009)
|
||||||
void verifyPackets() {
|
void verifyPackets() {
|
||||||
assumeThatWeAreImportingControlledTestData();
|
assumeThatWeAreImportingControlledTestData();
|
||||||
|
|
||||||
assertThat(firstOfEachType(3, CLOUD_SERVER, MANAGED_SERVER, MANAGED_WEBSPACE)).isEqualToIgnoringWhitespace("""
|
assertThat(firstOfEachType(3, CLOUD_SERVER, MANAGED_SERVER, MANAGED_WEBSPACE)).isEqualToIgnoringWhitespace("""
|
||||||
{
|
{
|
||||||
3000003=HsHostingAssetEntity(MANAGED_WEBSPACE, agu00, D-???????-?:agu00),
|
3000003=HsHostingAssetEntity(MANAGED_WEBSPACE, agu00, HA agu00, MANAGED_SERVER:vm1001, D-???????-?:BI agu00),
|
||||||
3000007=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr00, D-???????-?:ahr00),
|
3000007=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr00, HA ahr00, MANAGED_SERVER:vm1005, D-???????-?:BI ahr00),
|
||||||
3000008=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr01, D-???????-?:ahr01),
|
3000008=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr01, HA ahr01, MANAGED_SERVER:vm1003, D-???????-?:BI ahr01),
|
||||||
3000964=HsHostingAssetEntity(MANAGED_SERVER, vm1064, D-???????-?:vm1064),
|
3000964=HsHostingAssetEntity(MANAGED_SERVER, vm1064, HA vm1064, D-???????-?:BI vm1064),
|
||||||
3000966=HsHostingAssetEntity(MANAGED_SERVER, vm1063, D-???????-?:vm1063),
|
3000966=HsHostingAssetEntity(MANAGED_SERVER, vm1063, HA vm1063, D-???????-?:BI vm1063),
|
||||||
3000967=HsHostingAssetEntity(MANAGED_SERVER, vm1062, D-???????-?:vm1062),
|
3000967=HsHostingAssetEntity(MANAGED_SERVER, vm1062, HA vm1062, D-???????-?:BI vm1062),
|
||||||
3023611=HsHostingAssetEntity(CLOUD_SERVER, vm2097, D-???????-?:vm2097),
|
3023611=HsHostingAssetEntity(CLOUD_SERVER, vm2097, HA vm2097, D-???????-?:BI vm2097),
|
||||||
3023612=HsHostingAssetEntity(CLOUD_SERVER, vm2062, D-???????-?:vm2062),
|
3023612=HsHostingAssetEntity(CLOUD_SERVER, vm2062, HA vm2062, D-???????-?:BI vm2062),
|
||||||
3023613=HsHostingAssetEntity(CLOUD_SERVER, vm2058, D-???????-?:vm2058)
|
3023613=HsHostingAssetEntity(CLOUD_SERVER, vm2058, HA vm2058, D-???????-?:BI vm2058)
|
||||||
}
|
}
|
||||||
""");
|
""");
|
||||||
assertThat(firstOfEachType(
|
assertThat(firstOfEachType(
|
||||||
@ -180,21 +188,21 @@ public class ImportHostingAssets extends CsvDataImport {
|
|||||||
HsBookingItemType.MANAGED_SERVER,
|
HsBookingItemType.MANAGED_SERVER,
|
||||||
HsBookingItemType.MANAGED_WEBSPACE)).isEqualToIgnoringWhitespace("""
|
HsBookingItemType.MANAGED_WEBSPACE)).isEqualToIgnoringWhitespace("""
|
||||||
{
|
{
|
||||||
3000003=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), agu00),
|
3000003=HsBookingItemEntity(MANAGED_WEBSPACE, [2003-07-07,), BI agu00),
|
||||||
3000007=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), ahr00),
|
3000007=HsBookingItemEntity(MANAGED_WEBSPACE, [2001-12-17,), BI ahr00),
|
||||||
3000008=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), ahr01),
|
3000008=HsBookingItemEntity(MANAGED_WEBSPACE, [2003-03-12,), BI ahr01),
|
||||||
3000964=HsBookingItemEntity(MANAGED_SERVER, [2024-07-17,), vm1064),
|
3000964=HsBookingItemEntity(MANAGED_SERVER, [2013-04-01,), BI vm1064),
|
||||||
3000966=HsBookingItemEntity(MANAGED_SERVER, [2024-07-17,), vm1063),
|
3000966=HsBookingItemEntity(MANAGED_SERVER, [2013-04-01,), BI vm1063),
|
||||||
3000967=HsBookingItemEntity(MANAGED_SERVER, [2024-07-17,), vm1062),
|
3000967=HsBookingItemEntity(MANAGED_SERVER, [2013-04-01,), BI vm1062),
|
||||||
3023611=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2097),
|
3023611=HsBookingItemEntity(CLOUD_SERVER, [2022-08-10,), BI vm2097),
|
||||||
3023612=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2062),
|
3023612=HsBookingItemEntity(CLOUD_SERVER, [2022-08-10,), BI vm2062),
|
||||||
3023613=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2058)
|
3023613=HsBookingItemEntity(CLOUD_SERVER, [2022-08-10,), BI vm2058)
|
||||||
}
|
}
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(2010)
|
@Order(3010)
|
||||||
void importPacketComponents() {
|
void importPacketComponents() {
|
||||||
try (Reader reader = resourceReader(MIGRATION_DATA_PATH + "packet_component.csv")) {
|
try (Reader reader = resourceReader(MIGRATION_DATA_PATH + "packet_component.csv")) {
|
||||||
final var lines = readAllLines(reader);
|
final var lines = readAllLines(reader);
|
||||||
@ -205,7 +213,7 @@ public class ImportHostingAssets extends CsvDataImport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(2019)
|
@Order(3019)
|
||||||
void verifyPacketComponents() {
|
void verifyPacketComponents() {
|
||||||
assumeThatWeAreImportingControlledTestData();
|
assumeThatWeAreImportingControlledTestData();
|
||||||
|
|
||||||
@ -213,21 +221,21 @@ public class ImportHostingAssets extends CsvDataImport {
|
|||||||
assertThat(firstOfEachType(5, CLOUD_SERVER, MANAGED_SERVER, MANAGED_WEBSPACE))
|
assertThat(firstOfEachType(5, CLOUD_SERVER, MANAGED_SERVER, MANAGED_WEBSPACE))
|
||||||
.isEqualToIgnoringWhitespace("""
|
.isEqualToIgnoringWhitespace("""
|
||||||
{
|
{
|
||||||
3000003=HsHostingAssetEntity(MANAGED_WEBSPACE, agu00, D-???????-?:agu00),
|
3000003=HsHostingAssetEntity(MANAGED_WEBSPACE, agu00, HA agu00, MANAGED_SERVER:vm1001, D-???????-?:BI agu00),
|
||||||
3000007=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr00, D-???????-?:ahr00),
|
3000007=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr00, HA ahr00, MANAGED_SERVER:vm1005, D-???????-?:BI ahr00),
|
||||||
3000008=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr01, D-???????-?:ahr01),
|
3000008=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr01, HA ahr01, MANAGED_SERVER:vm1003, D-???????-?:BI ahr01),
|
||||||
3000009=HsHostingAssetEntity(MANAGED_WEBSPACE, aih00, D-???????-?:aih00),
|
3000009=HsHostingAssetEntity(MANAGED_WEBSPACE, aih00, HA aih00, MANAGED_SERVER:vm1001, D-???????-?:BI aih00),
|
||||||
3000012=HsHostingAssetEntity(MANAGED_WEBSPACE, al000, D-???????-?:al000),
|
3000012=HsHostingAssetEntity(MANAGED_WEBSPACE, al000, HA al000, MANAGED_SERVER:vm1001, D-???????-?:BI al000),
|
||||||
3000964=HsHostingAssetEntity(MANAGED_SERVER, vm1064, D-???????-?:vm1064),
|
3000964=HsHostingAssetEntity(MANAGED_SERVER, vm1064, HA vm1064, D-???????-?:BI vm1064),
|
||||||
3000966=HsHostingAssetEntity(MANAGED_SERVER, vm1063, D-???????-?:vm1063),
|
3000966=HsHostingAssetEntity(MANAGED_SERVER, vm1063, HA vm1063, D-???????-?:BI vm1063),
|
||||||
3000967=HsHostingAssetEntity(MANAGED_SERVER, vm1062, D-???????-?:vm1062),
|
3000967=HsHostingAssetEntity(MANAGED_SERVER, vm1062, HA vm1062, D-???????-?:BI vm1062),
|
||||||
3000968=HsHostingAssetEntity(MANAGED_SERVER, vm1061, D-???????-?:vm1061),
|
3000968=HsHostingAssetEntity(MANAGED_SERVER, vm1061, HA vm1061, D-???????-?:BI vm1061),
|
||||||
3000969=HsHostingAssetEntity(MANAGED_SERVER, vm1060, D-???????-?:vm1060),
|
3000969=HsHostingAssetEntity(MANAGED_SERVER, vm1060, HA vm1060, D-???????-?:BI vm1060),
|
||||||
3023611=HsHostingAssetEntity(CLOUD_SERVER, vm2097, D-???????-?:vm2097),
|
3023611=HsHostingAssetEntity(CLOUD_SERVER, vm2097, HA vm2097, D-???????-?:BI vm2097),
|
||||||
3023612=HsHostingAssetEntity(CLOUD_SERVER, vm2062, D-???????-?:vm2062),
|
3023612=HsHostingAssetEntity(CLOUD_SERVER, vm2062, HA vm2062, D-???????-?:BI vm2062),
|
||||||
3023613=HsHostingAssetEntity(CLOUD_SERVER, vm2058, D-???????-?:vm2058),
|
3023613=HsHostingAssetEntity(CLOUD_SERVER, vm2058, HA vm2058, D-???????-?:BI vm2058),
|
||||||
3023614=HsHostingAssetEntity(CLOUD_SERVER, vm2055, D-???????-?:vm2055),
|
3023614=HsHostingAssetEntity(CLOUD_SERVER, vm2055, HA vm2055, D-???????-?:BI vm2055),
|
||||||
3023615=HsHostingAssetEntity(CLOUD_SERVER, vm2010, D-???????-?:vm2010)
|
3023615=HsHostingAssetEntity(CLOUD_SERVER, vm2010, HA vm2010, D-???????-?:BI vm2010)
|
||||||
}
|
}
|
||||||
""");
|
""");
|
||||||
assertThat(firstOfEachType(
|
assertThat(firstOfEachType(
|
||||||
@ -237,25 +245,57 @@ public class ImportHostingAssets extends CsvDataImport {
|
|||||||
HsBookingItemType.MANAGED_WEBSPACE))
|
HsBookingItemType.MANAGED_WEBSPACE))
|
||||||
.isEqualToIgnoringWhitespace("""
|
.isEqualToIgnoringWhitespace("""
|
||||||
{
|
{
|
||||||
3000003=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), agu00, { "Multi": 3, "SLA-Platform": "EXT24H", "SSD": 8192, "Traffic": 20}),
|
3000003=HsBookingItemEntity(MANAGED_WEBSPACE, [2003-07-07,), BI agu00, { "Multi": 3, "SLA-Platform": "EXT24H", "SSD": 8, "Traffic": 20}),
|
||||||
3000007=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), ahr00, { "Multi": 6, "SLA-Platform": "EXT24H", "SSD": 25600, "Traffic": 10}),
|
3000007=HsBookingItemEntity(MANAGED_WEBSPACE, [2001-12-17,), BI ahr00, { "Multi": 6, "SLA-Platform": "EXT24H", "SSD": 25, "Traffic": 10}),
|
||||||
3000008=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), ahr01, { "Multi": 3, "SLA-Platform": "EXT24H", "SSD": 5120, "Traffic": 10}),
|
3000008=HsBookingItemEntity(MANAGED_WEBSPACE, [2003-03-12,), BI ahr01, { "Multi": 3, "SLA-Platform": "EXT24H", "SSD": 5, "Traffic": 10}),
|
||||||
3000009=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), aih00, { "HDD": 20480, "Multi": 2, "SLA-Platform": "BASIC", "SSD": 3072, "Traffic": 10}),
|
3000009=HsBookingItemEntity(MANAGED_WEBSPACE, [2002-07-03,), BI aih00, { "HDD": 20, "Multi": 2, "SLA-Platform": "EXT24H", "SSD": 3, "Traffic": 10}),
|
||||||
3000012=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), al000, { "HDD": 10240, "Multi": 3, "SLA-Platform": "BASIC", "SSD": 6144, "Traffic": 40}),
|
3000012=HsBookingItemEntity(MANAGED_WEBSPACE, [2003-10-17,), BI al000, { "HDD": 10, "Multi": 3, "SLA-Platform": "EXT24H", "SSD": 6, "Traffic": 40}),
|
||||||
3000964=HsBookingItemEntity(MANAGED_SERVER, [2024-07-17,), vm1064, { "CPU": 2, "RAM": 4096, "SLA-EMail": true, "SLA-Maria": true, "SLA-Office": true, "SLA-PgSQL": true, "SLA-Platform": "EXT4H", "SLA-Web": true, "SSD": 76800, "Traffic": 500}),
|
3000964=HsBookingItemEntity(MANAGED_SERVER, [2013-04-01,), BI vm1064, { "CPU": 2, "RAM": 4, "SLA-EMail": true, "SLA-Maria": true, "SLA-Office": true, "SLA-PgSQL": true, "SLA-Platform": "EXT2H", "SLA-Web": true, "SSD": 75, "Traffic": 500}),
|
||||||
3000966=HsBookingItemEntity(MANAGED_SERVER, [2024-07-17,), vm1063, { "CPU": 2, "HDD": 256000, "RAM": 8192, "SLA-EMail": true, "SLA-Maria": true, "SLA-Office": true, "SLA-PgSQL": true, "SLA-Platform": "EXT4H", "SLA-Web": true, "SSD": 51200, "Traffic": 250}),
|
3000966=HsBookingItemEntity(MANAGED_SERVER, [2013-04-01,), BI vm1063, { "CPU": 2, "HDD": 250, "RAM": 8, "SLA-EMail": true, "SLA-Maria": true, "SLA-Office": true, "SLA-PgSQL": true, "SLA-Platform": "EXT8H", "SLA-Web": true, "SSD": 50, "Traffic": 250}),
|
||||||
3000967=HsBookingItemEntity(MANAGED_SERVER, [2024-07-17,), vm1062, { "CPU": 2, "HDD": 256000, "RAM": 12288, "SLA-EMail": true, "SLA-Maria": true, "SLA-Office": true, "SLA-PgSQL": true, "SLA-Platform": "EXT2H", "SLA-Web": true, "SSD": 102400, "Traffic": 250}),
|
3000967=HsBookingItemEntity(MANAGED_SERVER, [2013-04-01,), BI vm1062, { "CPU": 2, "HDD": 250, "RAM": 12, "SLA-EMail": true, "SLA-Maria": true, "SLA-Office": true, "SLA-PgSQL": true, "SLA-Platform": "EXT4H", "SLA-Web": true, "SSD": 100, "Traffic": 250}),
|
||||||
3000968=HsBookingItemEntity(MANAGED_SERVER, [2024-07-17,), vm1061, { "CPU": 6, "HDD": 256000, "RAM": 14336, "SLA-EMail": true, "SLA-Maria": true, "SLA-Office": true, "SLA-PgSQL": true, "SLA-Platform": "BASIC", "SLA-Web": true, "SSD": 384000, "Traffic": 250}),
|
3000968=HsBookingItemEntity(MANAGED_SERVER, [2013-04-01,), BI vm1061, { "CPU": 6, "HDD": 250, "RAM": 14, "SLA-EMail": true, "SLA-Maria": true, "SLA-Office": true, "SLA-PgSQL": true, "SLA-Platform": "EXT4H", "SLA-Web": true, "SSD": 375, "Traffic": 250}),
|
||||||
3000969=HsBookingItemEntity(MANAGED_SERVER, [2024-07-17,), vm1060, { "CPU": 2, "RAM": 4096, "SLA-EMail": true, "SLA-Maria": true, "SLA-Office": true, "SLA-PgSQL": true, "SLA-Platform": "EXT2H", "SLA-Web": true, "SSD": 76800, "Traffic": 250}),
|
3000969=HsBookingItemEntity(MANAGED_SERVER, [2013-04-01,), BI vm1060, { "CPU": 2, "RAM": 4, "SLA-EMail": true, "SLA-Maria": true, "SLA-Office": true, "SLA-PgSQL": true, "SLA-Platform": "EXT8H", "SLA-Web": true, "SSD": 75, "Traffic": 250}),
|
||||||
3023611=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2097, { "CPU": 8, "RAM": 12288, "SLA-Infrastructure": "EXT4H", "SLA-Platform": "BASIC", "SSD": 25600, "Traffic": 250}),
|
3023611=HsBookingItemEntity(CLOUD_SERVER, [2022-08-10,), BI vm2097, { "CPU": 8, "RAM": 12, "SLA-Infrastructure": "EXT4H", "SSD": 25, "Traffic": 250}),
|
||||||
3023612=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2062, { "CPU": 10, "RAM": 65536, "SLA-Infrastructure": "EXT4H", "SLA-Platform": "BASIC", "SSD": 25600, "Traffic": 250}),
|
3023612=HsBookingItemEntity(CLOUD_SERVER, [2022-08-10,), BI vm2062, { "CPU": 10, "RAM": 64, "SLA-Infrastructure": "EXT8H", "SSD": 25, "Traffic": 250}),
|
||||||
3023613=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2058, { "CPU": 1, "RAM": 8192, "SLA-Infrastructure": "EXT4H", "SLA-Platform": "BASIC", "SSD": 25600, "Traffic": 250}),
|
3023613=HsBookingItemEntity(CLOUD_SERVER, [2022-08-10,), BI vm2058, { "CPU": 1, "RAM": 8, "SLA-Infrastructure": "EXT4H", "SSD": 25, "Traffic": 250}),
|
||||||
3023614=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2055, { "CPU": 8, "HDD": 256000, "RAM": 16384, "SLA-Infrastructure": "EXT4H", "SLA-Platform": "BASIC", "SSD": 25600, "Traffic": 250}),
|
3023614=HsBookingItemEntity(CLOUD_SERVER, [2022-08-10,), BI vm2055, { "CPU": 8, "HDD": 250, "RAM": 16, "SLA-Infrastructure": "EXT4H", "SSD": 25, "Traffic": 250}),
|
||||||
3023615=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2010, { "CPU": 2, "RAM": 2048, "SLA-Infrastructure": "EXT4H", "SLA-Platform": "BASIC", "SSD": 51200, "Traffic": 250})
|
3023615=HsBookingItemEntity(CLOUD_SERVER, [2022-08-10,), BI vm2010, { "CPU": 2, "RAM": 2, "SLA-Infrastructure": "EXT4H", "SSD": 50, "Traffic": 250})
|
||||||
}
|
}
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(9000)
|
||||||
|
@Commit
|
||||||
|
void persistEntities() {
|
||||||
|
|
||||||
|
System.out.println("PERSISTING to database '" + jdbcUrl + "' as user '" + postgresAdminUser + "'");
|
||||||
|
deleteTestDataFromHsOfficeTables();
|
||||||
|
resetHsOfficeSequences();
|
||||||
|
deleteFromTestTables();
|
||||||
|
deleteFromRbacTables();
|
||||||
|
|
||||||
|
jpaAttempt.transacted(() -> {
|
||||||
|
context(rbacSuperuser);
|
||||||
|
bookingItems.forEach(
|
||||||
|
(key, bi) -> HsBookingItemEntityValidatorRegistry.validated(bi)
|
||||||
|
);
|
||||||
|
}).assertSuccessful();
|
||||||
|
|
||||||
|
jpaAttempt.transacted(() -> {
|
||||||
|
context(rbacSuperuser);
|
||||||
|
hostingAssets.forEach((key, ha) ->
|
||||||
|
new HostingAssetEntitySaveProcessor(ha)
|
||||||
|
.preprocessEntity()
|
||||||
|
.validateEntity()
|
||||||
|
.prepareForSave()
|
||||||
|
// .saveUsing(assetRepo::save)
|
||||||
|
// .validateContext()
|
||||||
|
);
|
||||||
|
}).assertSuccessful();
|
||||||
|
}
|
||||||
|
|
||||||
private void importIpNumbers(final String[] header, final List<String[]> records) {
|
private void importIpNumbers(final String[] header, final List<String[]> records) {
|
||||||
final var columns = new Columns(header);
|
final var columns = new Columns(header);
|
||||||
records.stream()
|
records.stream()
|
||||||
@ -281,7 +321,8 @@ public class ImportHostingAssets extends CsvDataImport {
|
|||||||
final var hive = new Hive(
|
final var hive = new Hive(
|
||||||
hive_id,
|
hive_id,
|
||||||
rec.getString("hive_name"),
|
rec.getString("hive_name"),
|
||||||
rec.getInteger("inet_addr_id"));
|
rec.getInteger("inet_addr_id"),
|
||||||
|
new AtomicReference<>());
|
||||||
hives.put(HIVE_ID_OFFSET + hive_id, hive);
|
hives.put(HIVE_ID_OFFSET + hive_id, hive);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -292,7 +333,6 @@ public class ImportHostingAssets extends CsvDataImport {
|
|||||||
.map(this::trimAll)
|
.map(this::trimAll)
|
||||||
.map(row -> new Record(columns, row))
|
.map(row -> new Record(columns, row))
|
||||||
.forEach(rec -> {
|
.forEach(rec -> {
|
||||||
|
|
||||||
final var packet_id = rec.getInteger("packet_id");
|
final var packet_id = rec.getInteger("packet_id");
|
||||||
final var basepacket_code = rec.getString("basepacket_code");
|
final var basepacket_code = rec.getString("basepacket_code");
|
||||||
final var packet_name = rec.getString("packet_name");
|
final var packet_name = rec.getString("packet_name");
|
||||||
@ -304,31 +344,43 @@ public class ImportHostingAssets extends CsvDataImport {
|
|||||||
final var old_inet_addr_id = rec.getInteger("old_inet_addr_id");
|
final var old_inet_addr_id = rec.getInteger("old_inet_addr_id");
|
||||||
final var free = rec.getBoolean("free");
|
final var free = rec.getBoolean("free");
|
||||||
|
|
||||||
|
final var biType = determineBiType(basepacket_code);
|
||||||
final var bookingItem = HsBookingItemEntity.builder()
|
final var bookingItem = HsBookingItemEntity.builder()
|
||||||
.type(switch (rec.getString("basepacket_code")) {
|
.type(biType)
|
||||||
case "SRV/CLD" -> HsBookingItemType.CLOUD_SERVER;
|
.caption("BI " + packet_name)
|
||||||
case "SRV/MGD" -> HsBookingItemType.MANAGED_SERVER;
|
.validity(toPostgresDateRange(created, cancelled))
|
||||||
case "PAC/WEB" -> HsBookingItemType.MANAGED_WEBSPACE;
|
|
||||||
default -> throw new IllegalArgumentException(
|
|
||||||
"unknown basepacket_code: " + rec.getString("basepacket_code"));
|
|
||||||
})
|
|
||||||
.caption(packet_name)
|
|
||||||
.build();
|
.build();
|
||||||
bookingItems.put(PACKET_ID_OFFSET + packet_id, bookingItem);
|
bookingItems.put(PACKET_ID_OFFSET + packet_id, bookingItem);
|
||||||
|
|
||||||
|
final var haType = determineHaType(basepacket_code);
|
||||||
final var asset = HsHostingAssetEntity.builder()
|
final var asset = HsHostingAssetEntity.builder()
|
||||||
.type(switch (rec.getString("basepacket_code")) {
|
.type(haType)
|
||||||
case "SRV/CLD" -> CLOUD_SERVER;
|
.identifier(packet_name)
|
||||||
case "SRV/MGD" -> MANAGED_SERVER;
|
|
||||||
case "PAC/WEB" -> MANAGED_WEBSPACE;
|
|
||||||
default -> throw new IllegalArgumentException(
|
|
||||||
"unknown basepacket_code: " + rec.getString("basepacket_code"));
|
|
||||||
})
|
|
||||||
.identifier(rec.getString("packet_name"))
|
|
||||||
.bookingItem(bookingItem)
|
.bookingItem(bookingItem)
|
||||||
// .caption(rec.getString("description"))
|
.caption("HA " + packet_name)
|
||||||
.build();
|
.build();
|
||||||
hostingAssets.put(PACKET_ID_OFFSET + packet_id, asset);
|
hostingAssets.put(PACKET_ID_OFFSET + packet_id, asset);
|
||||||
|
if (haType == MANAGED_SERVER) {
|
||||||
|
hive(hive_id).serverRef.set(asset);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// once we know all hosting assets, we can set the parentAsset for managed webspaces
|
||||||
|
records.stream()
|
||||||
|
.map(this::trimAll)
|
||||||
|
.map(row -> new Record(columns, row))
|
||||||
|
.forEach(rec -> {
|
||||||
|
final var packet_id = rec.getInteger("packet_id");
|
||||||
|
final var basepacket_code = rec.getString("basepacket_code");
|
||||||
|
final var hive_id = rec.getInteger("hive_id");
|
||||||
|
|
||||||
|
final var haType = determineHaType(basepacket_code);
|
||||||
|
if (haType == MANAGED_WEBSPACE) {
|
||||||
|
final var managedWebspace = pac(packet_id);
|
||||||
|
final var parentAsset = hive(hive_id).serverRef.get();
|
||||||
|
managedWebspace.setParentAsset(parentAsset);
|
||||||
|
managedWebspace.getBookingItem().setParentItem(parentAsset.getBookingItem());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,57 +390,73 @@ public class ImportHostingAssets extends CsvDataImport {
|
|||||||
.map(this::trimAll)
|
.map(this::trimAll)
|
||||||
.map(row -> new Record(columns, row))
|
.map(row -> new Record(columns, row))
|
||||||
.forEach(rec -> {
|
.forEach(rec -> {
|
||||||
final var packet_component_id = rec.getInteger("packet_component_id");
|
// final var packet_component_id = rec.getInteger("packet_component_id"); not needed
|
||||||
final var packet_id = rec.getInteger("packet_id");
|
final var packet_id = rec.getInteger("packet_id");
|
||||||
final var quantity = rec.getInteger("quantity");
|
final var quantity = rec.getInteger("quantity");
|
||||||
final var basecomponent_code = rec.getString("basecomponent_code");
|
final var basecomponent_code = rec.getString("basecomponent_code");
|
||||||
final var created = rec.getLocalDate("created");
|
// final var created = rec.getLocalDate("created"); TODO.spec: can we do without?
|
||||||
final var cancelled = rec.getLocalDate("cancelled");
|
// final var cancelled = rec.getLocalDate("cancelled"); TODO.spec: can we do without?
|
||||||
|
Function<Integer, Object> convert = (v -> v);
|
||||||
|
|
||||||
final var asset = hostingAssets.get(PACKET_ID_OFFSET + packet_id);
|
final var asset = pac(packet_id);
|
||||||
final var name = switch (basecomponent_code) {
|
final var name = switch (basecomponent_code) {
|
||||||
case "DAEMON" -> "Daemons";
|
case "DAEMON" -> "Daemons";
|
||||||
case "MULTI" -> "Multi";
|
case "MULTI" -> "Multi";
|
||||||
case "CPU" -> "CPU";
|
case "CPU" -> "CPU";
|
||||||
case "RAM" -> "RAM";
|
case "RAM" -> returning("RAM", convert = v -> v/1024);
|
||||||
case "QUOTA" -> "SSD";
|
case "QUOTA" -> returning("SSD", convert = v -> v/1024);
|
||||||
case "STORAGE" -> "HDD";
|
case "STORAGE" -> returning("HDD", convert = v -> v/1024);
|
||||||
case "TRAFFIC" -> "Traffic";
|
case "TRAFFIC" -> "Traffic";
|
||||||
case "OFFICE" -> "Online Office Server";
|
case "OFFICE" -> returning("Online Office Server", convert = v -> v == 1);
|
||||||
case "SLABASIC" -> "SLA-Platform";
|
|
||||||
|
case "SLABASIC" -> switch (asset.getType()) {
|
||||||
|
case CLOUD_SERVER -> "SLA-Infrastructure";
|
||||||
|
case MANAGED_SERVER -> "SLA-Platform";
|
||||||
|
case MANAGED_WEBSPACE -> "SLA-Platform";
|
||||||
|
default -> throw new IllegalArgumentException("SLABASIC not defined for " + asset.getType());
|
||||||
|
};
|
||||||
|
|
||||||
case "SLAINFR2H" -> "SLA-Infrastructure";
|
case "SLAINFR2H" -> "SLA-Infrastructure";
|
||||||
case "SLAINFR4H" -> "SLA-Infrastructure";
|
case "SLAINFR4H" -> "SLA-Infrastructure";
|
||||||
case "SLAINFR8H" -> "SLA-Infrastructure";
|
case "SLAINFR8H" -> "SLA-Infrastructure";
|
||||||
|
|
||||||
case "SLAEXT24H" -> "SLA-Platform";
|
case "SLAEXT24H" -> "SLA-Platform";
|
||||||
|
|
||||||
case "SLAPLAT2H" -> "SLA-Platform";
|
case "SLAPLAT2H" -> "SLA-Platform";
|
||||||
case "SLAPLAT4H" -> "SLA-Platform";
|
case "SLAPLAT4H" -> "SLA-Platform";
|
||||||
case "SLAPLAT8H" -> "SLA-Platform";
|
case "SLAPLAT8H" -> "SLA-Platform";
|
||||||
|
|
||||||
case "SLAWEB2H" -> "SLA-Web";
|
case "SLAWEB2H" -> "SLA-Web";
|
||||||
case "SLAWEB4H" -> "SLA-Web";
|
case "SLAWEB4H" -> "SLA-Web";
|
||||||
case "SLAWEB8H" -> "SLA-Web";
|
case "SLAWEB8H" -> "SLA-Web";
|
||||||
|
|
||||||
case "SLAMAIL2H" -> "SLA-EMail";
|
case "SLAMAIL2H" -> "SLA-EMail";
|
||||||
case "SLAMAIL4H" -> "SLA-EMail";
|
case "SLAMAIL4H" -> "SLA-EMail";
|
||||||
case "SLAMAIL8H" -> "SLA-EMail";
|
case "SLAMAIL8H" -> "SLA-EMail";
|
||||||
|
|
||||||
case "SLAMARIA2H" -> "SLA-Maria";
|
case "SLAMARIA2H" -> "SLA-Maria";
|
||||||
case "SLAMARIA4H" -> "SLA-Maria";
|
case "SLAMARIA4H" -> "SLA-Maria";
|
||||||
case "SLAMARIA8H" -> "SLA-Maria";
|
case "SLAMARIA8H" -> "SLA-Maria";
|
||||||
|
|
||||||
case "SLAPGSQL2H" -> "SLA-PgSQL";
|
case "SLAPGSQL2H" -> "SLA-PgSQL";
|
||||||
case "SLAPGSQL4H" -> "SLA-PgSQL";
|
case "SLAPGSQL4H" -> "SLA-PgSQL";
|
||||||
case "SLAPGSQL8H" -> "SLA-PgSQL";
|
case "SLAPGSQL8H" -> "SLA-PgSQL";
|
||||||
|
|
||||||
case "SLAOFFIC2H" -> "SLA-Office";
|
case "SLAOFFIC2H" -> "SLA-Office";
|
||||||
case "SLAOFFIC4H" -> "SLA-Office";
|
case "SLAOFFIC4H" -> "SLA-Office";
|
||||||
case "SLAOFFIC8H" -> "SLA-Office";
|
case "SLAOFFIC8H" -> "SLA-Office";
|
||||||
case "BANDWIDTH" -> null; // TODO.spec: not implemented yet
|
|
||||||
|
case "BANDWIDTH" -> "Bandwidth";
|
||||||
default -> throw new IllegalArgumentException("unknown basecomponent_code: " + basecomponent_code);
|
default -> throw new IllegalArgumentException("unknown basecomponent_code: " + basecomponent_code);
|
||||||
};
|
};
|
||||||
if (name == null) {
|
|
||||||
} else if (name.equals("SLA-Infrastructure")) {
|
if (name.equals("SLA-Infrastructure")) {
|
||||||
final var slaValue = switch (basecomponent_code) {
|
final var slaValue = switch (basecomponent_code) {
|
||||||
|
case "SLABASIC" -> "BASIC";
|
||||||
case "SLAINFR2H" -> "EXT2H";
|
case "SLAINFR2H" -> "EXT2H";
|
||||||
case "SLAINFR4H" -> "EXT4H";
|
case "SLAINFR4H" -> "EXT4H";
|
||||||
case "SLAINFR8H" -> "EXT4H";
|
case "SLAINFR8H" -> "EXT8H";
|
||||||
|
case "SLAINFR24H" -> "EXT24H";
|
||||||
default -> throw new IllegalArgumentException("unknown basecomponent_code: " + basecomponent_code);
|
default -> throw new IllegalArgumentException("unknown basecomponent_code: " + basecomponent_code);
|
||||||
};
|
};
|
||||||
asset.getBookingItem().getResources().put(name, slaValue);
|
asset.getBookingItem().getResources().put(name, slaValue);
|
||||||
@ -397,19 +465,57 @@ public class ImportHostingAssets extends CsvDataImport {
|
|||||||
case "SLABASIC" -> "BASIC";
|
case "SLABASIC" -> "BASIC";
|
||||||
case "SLAPLAT2H" -> "EXT2H";
|
case "SLAPLAT2H" -> "EXT2H";
|
||||||
case "SLAPLAT4H" -> "EXT4H";
|
case "SLAPLAT4H" -> "EXT4H";
|
||||||
case "SLAEXT24H" -> "EXT24H";
|
|
||||||
case "SLAPLAT8H" -> "EXT8H";
|
case "SLAPLAT8H" -> "EXT8H";
|
||||||
|
case "SLAEXT24H" -> "EXT24H";
|
||||||
default -> throw new IllegalArgumentException("unknown basecomponent_code: " + basecomponent_code);
|
default -> throw new IllegalArgumentException("unknown basecomponent_code: " + basecomponent_code);
|
||||||
};
|
};
|
||||||
asset.getBookingItem().getResources().put(name, slaValue);
|
if ( ofNullable(asset.getBookingItem().getResources().get(name)).map("BASIC"::equals).orElse(true) ) {
|
||||||
|
asset.getBookingItem().getResources().put(name, slaValue);
|
||||||
|
}
|
||||||
} else if (name.startsWith("SLA")) {
|
} else if (name.startsWith("SLA")) {
|
||||||
asset.getBookingItem().getResources().put(name, true);
|
asset.getBookingItem().getResources().put(name, true);
|
||||||
} else if (quantity > 0) {
|
} else if (quantity > 0) {
|
||||||
asset.getBookingItem().getResources().put(name, quantity);
|
asset.getBookingItem().getResources().put(name, convert.apply(quantity));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<V> V returning(final V value, final Object... assignments) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static @NotNull HsBookingItemType determineBiType(final String basepacket_code) {
|
||||||
|
return switch (basepacket_code) {
|
||||||
|
case "SRV/CLD" -> HsBookingItemType.CLOUD_SERVER;
|
||||||
|
case "SRV/MGD" -> HsBookingItemType.MANAGED_SERVER;
|
||||||
|
case "PAC/WEB" -> HsBookingItemType.MANAGED_WEBSPACE;
|
||||||
|
default -> throw new IllegalArgumentException(
|
||||||
|
"unknown basepacket_code: " + basepacket_code);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static @NotNull HsHostingAssetType determineHaType(final String basepacket_code) {
|
||||||
|
return switch (basepacket_code) {
|
||||||
|
case "SRV/CLD" -> CLOUD_SERVER;
|
||||||
|
case "SRV/MGD" -> MANAGED_SERVER;
|
||||||
|
case "PAC/WEB" -> MANAGED_WEBSPACE;
|
||||||
|
default -> throw new IllegalArgumentException(
|
||||||
|
"unknown basepacket_code: " + basepacket_code);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HsHostingAssetEntity ipNumber(final Integer inet_addr_id) {
|
||||||
|
return inet_addr_id != null ? hostingAssets.get(IP_NUMBER_ID_OFFSET + inet_addr_id) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Hive hive(final Integer hive_id) {
|
||||||
|
return hive_id != null ? hives.get(HIVE_ID_OFFSET + hive_id) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HsHostingAssetEntity pac(final Integer packet_id) {
|
||||||
|
return packet_id != null ? hostingAssets.get(PACKET_ID_OFFSET + packet_id) : null;
|
||||||
|
}
|
||||||
|
|
||||||
private String firstOfEachType(
|
private String firstOfEachType(
|
||||||
final int maxCount,
|
final int maxCount,
|
||||||
final HsHostingAssetType... types) {
|
final HsHostingAssetType... types) {
|
||||||
@ -442,6 +548,11 @@ public class ImportHostingAssets extends CsvDataImport {
|
|||||||
.collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
|
.collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void assumeThatWeAreExplicitlyImportingOfficeData() {
|
||||||
|
assumeThat(false).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
protected static boolean isImportingControlledTestData() {
|
protected static boolean isImportingControlledTestData() {
|
||||||
return MIGRATION_DATA_PATH.equals("migration");
|
return MIGRATION_DATA_PATH.equals("migration");
|
||||||
}
|
}
|
||||||
@ -449,5 +560,4 @@ public class ImportHostingAssets extends CsvDataImport {
|
|||||||
protected static void assumeThatWeAreImportingControlledTestData() {
|
protected static void assumeThatWeAreImportingControlledTestData() {
|
||||||
// assumeThat(isImportingControlledTestData()).isTrue(); FIXME
|
// assumeThat(isImportingControlledTestData()).isTrue(); FIXME
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,7 @@ public class ImportOfficeData extends CsvDataImport {
|
|||||||
private static final List<Integer> IGNORE_BUSINESS_PARTNERS = Arrays.asList(
|
private static final List<Integer> IGNORE_BUSINESS_PARTNERS = Arrays.asList(
|
||||||
512167, // 11139, partner without contractual contact
|
512167, // 11139, partner without contractual contact
|
||||||
512170, // 11142, partner without contractual contact
|
512170, // 11142, partner without contractual contact
|
||||||
|
511725, // 10764, partner without contractual contact
|
||||||
-1
|
-1
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -313,6 +314,8 @@ public class ImportOfficeData extends CsvDataImport {
|
|||||||
@Test
|
@Test
|
||||||
@Order(1040)
|
@Order(1040)
|
||||||
void importCoopShares() {
|
void importCoopShares() {
|
||||||
|
assumeThatWeAreExplicitlyImportingOfficeData();
|
||||||
|
|
||||||
try (Reader reader = resourceReader(MIGRATION_DATA_PATH + "share-transactions.csv")) {
|
try (Reader reader = resourceReader(MIGRATION_DATA_PATH + "share-transactions.csv")) {
|
||||||
final var lines = readAllLines(reader);
|
final var lines = readAllLines(reader);
|
||||||
importCoopShares(justHeader(lines), withoutHeader(lines));
|
importCoopShares(justHeader(lines), withoutHeader(lines));
|
||||||
@ -324,6 +327,7 @@ public class ImportOfficeData extends CsvDataImport {
|
|||||||
@Test
|
@Test
|
||||||
@Order(1041)
|
@Order(1041)
|
||||||
void verifyCoopShares() {
|
void verifyCoopShares() {
|
||||||
|
assumeThatWeAreExplicitlyImportingOfficeData();
|
||||||
assumeThatWeAreImportingControlledTestData();
|
assumeThatWeAreImportingControlledTestData();
|
||||||
|
|
||||||
assertThat(toFormattedString(coopShares)).isEqualToIgnoringWhitespace("""
|
assertThat(toFormattedString(coopShares)).isEqualToIgnoringWhitespace("""
|
||||||
@ -339,6 +343,7 @@ public class ImportOfficeData extends CsvDataImport {
|
|||||||
@Test
|
@Test
|
||||||
@Order(1050)
|
@Order(1050)
|
||||||
void importCoopAssets() {
|
void importCoopAssets() {
|
||||||
|
assumeThatWeAreExplicitlyImportingOfficeData();
|
||||||
|
|
||||||
try (Reader reader = resourceReader(MIGRATION_DATA_PATH + "asset-transactions.csv")) {
|
try (Reader reader = resourceReader(MIGRATION_DATA_PATH + "asset-transactions.csv")) {
|
||||||
final var lines = readAllLines(reader);
|
final var lines = readAllLines(reader);
|
||||||
@ -351,6 +356,7 @@ public class ImportOfficeData extends CsvDataImport {
|
|||||||
@Test
|
@Test
|
||||||
@Order(1059)
|
@Order(1059)
|
||||||
void verifyCoopAssets() {
|
void verifyCoopAssets() {
|
||||||
|
assumeThatWeAreExplicitlyImportingOfficeData();
|
||||||
assumeThatWeAreImportingControlledTestData();
|
assumeThatWeAreImportingControlledTestData();
|
||||||
|
|
||||||
assertThat(toFormattedString(coopAssets)).isEqualToIgnoringWhitespace("""
|
assertThat(toFormattedString(coopAssets)).isEqualToIgnoringWhitespace("""
|
||||||
@ -372,7 +378,9 @@ public class ImportOfficeData extends CsvDataImport {
|
|||||||
@Test
|
@Test
|
||||||
@Order(1099)
|
@Order(1099)
|
||||||
void verifyMemberships() {
|
void verifyMemberships() {
|
||||||
|
assumeThatWeAreExplicitlyImportingOfficeData();
|
||||||
assumeThatWeAreImportingControlledTestData();
|
assumeThatWeAreImportingControlledTestData();
|
||||||
|
|
||||||
assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace("""
|
assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace("""
|
||||||
{
|
{
|
||||||
17=Membership(M-1001700, P-10017, [2000-12-06,), ACTIVE),
|
17=Membership(M-1001700, P-10017, [2000-12-06,), ACTIVE),
|
||||||
@ -386,6 +394,8 @@ public class ImportOfficeData extends CsvDataImport {
|
|||||||
@Test
|
@Test
|
||||||
@Order(2000)
|
@Order(2000)
|
||||||
void verifyAllPartnersHavePersons() {
|
void verifyAllPartnersHavePersons() {
|
||||||
|
assumeThatWeAreExplicitlyImportingOfficeData();
|
||||||
|
|
||||||
partners.forEach((id, p) -> {
|
partners.forEach((id, p) -> {
|
||||||
final var partnerRel = p.getPartnerRel();
|
final var partnerRel = p.getPartnerRel();
|
||||||
assertThat(partnerRel).describedAs("partner " + id + " without partnerRel").isNotNull();
|
assertThat(partnerRel).describedAs("partner " + id + " without partnerRel").isNotNull();
|
||||||
@ -480,6 +490,23 @@ public class ImportOfficeData extends CsvDataImport {
|
|||||||
assertThat(idsToRemove.size()).isEqualTo(1); // only from partner #99
|
assertThat(idsToRemove.size()).isEqualTo(1); // only from partner #99
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(3005)
|
||||||
|
void removeEmptyPersons() {
|
||||||
|
// avoid a error when persisting the deliberately invalid partner entry #99
|
||||||
|
final var idsToRemove = new HashSet<Integer>();
|
||||||
|
persons.forEach( (id, p) -> {
|
||||||
|
if ( p.getPersonType() == null ||
|
||||||
|
(p.getFamilyName() == null && p.getGivenName() == null && p.getTradeName() == null) ) {
|
||||||
|
idsToRemove.add(id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
idsToRemove.forEach(id -> persons.remove(id));
|
||||||
|
|
||||||
|
assumeThatWeAreImportingControlledTestData();
|
||||||
|
assertThat(idsToRemove.size()).isEqualTo(0);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(9000)
|
@Order(9000)
|
||||||
@Commit
|
@Commit
|
||||||
@ -487,7 +514,7 @@ public class ImportOfficeData extends CsvDataImport {
|
|||||||
|
|
||||||
System.out.println("PERSISTING to database '" + jdbcUrl + "' as user '" + postgresAdminUser + "'");
|
System.out.println("PERSISTING to database '" + jdbcUrl + "' as user '" + postgresAdminUser + "'");
|
||||||
deleteTestDataFromHsOfficeTables();
|
deleteTestDataFromHsOfficeTables();
|
||||||
resetFromHsOfficeSequences();
|
resetHsOfficeSequences();
|
||||||
deleteFromTestTables();
|
deleteFromTestTables();
|
||||||
deleteFromRbacTables();
|
deleteFromRbacTables();
|
||||||
|
|
||||||
@ -500,6 +527,8 @@ public class ImportOfficeData extends CsvDataImport {
|
|||||||
jpaAttempt.transacted(() -> {
|
jpaAttempt.transacted(() -> {
|
||||||
context(rbacSuperuser);
|
context(rbacSuperuser);
|
||||||
persons.forEach(this::persist);
|
persons.forEach(this::persist);
|
||||||
|
relations.forEach( (id, rel) -> this.persist(id, rel.getAnchor()) );
|
||||||
|
relations.forEach( (id, rel) -> this.persist(id, rel.getHolder()) );
|
||||||
}).assertSuccessful();
|
}).assertSuccessful();
|
||||||
|
|
||||||
jpaAttempt.transacted(() -> {
|
jpaAttempt.transacted(() -> {
|
||||||
@ -560,6 +589,10 @@ public class ImportOfficeData extends CsvDataImport {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void assumeThatWeAreExplicitlyImportingOfficeData() {
|
||||||
|
assumeThat(true).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean isImportingControlledTestData() {
|
private static boolean isImportingControlledTestData() {
|
||||||
return partners.size() <= MAX_NUMBER_OF_TEST_DATA_PARTNERS;
|
return partners.size() <= MAX_NUMBER_OF_TEST_DATA_PARTNERS;
|
||||||
}
|
}
|
||||||
@ -568,62 +601,6 @@ public class ImportOfficeData extends CsvDataImport {
|
|||||||
assumeThat(partners.size()).isLessThanOrEqualTo(MAX_NUMBER_OF_TEST_DATA_PARTNERS);
|
assumeThat(partners.size()).isLessThanOrEqualTo(MAX_NUMBER_OF_TEST_DATA_PARTNERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteTestDataFromHsOfficeTables() {
|
|
||||||
jpaAttempt.transacted(() -> {
|
|
||||||
context(rbacSuperuser);
|
|
||||||
em.createNativeQuery("delete from hs_hosting_asset where true").executeUpdate();
|
|
||||||
em.createNativeQuery("delete from hs_booking_item where true").executeUpdate();
|
|
||||||
em.createNativeQuery("delete from hs_booking_project where true").executeUpdate();
|
|
||||||
em.createNativeQuery("delete from hs_office_coopassetstransaction where true").executeUpdate();
|
|
||||||
em.createNativeQuery("delete from hs_office_coopassetstransaction_legacy_id where true").executeUpdate();
|
|
||||||
em.createNativeQuery("delete from hs_office_coopsharestransaction where true").executeUpdate();
|
|
||||||
em.createNativeQuery("delete from hs_office_coopsharestransaction_legacy_id where true").executeUpdate();
|
|
||||||
em.createNativeQuery("delete from hs_office_membership where true").executeUpdate();
|
|
||||||
em.createNativeQuery("delete from hs_office_sepamandate where true").executeUpdate();
|
|
||||||
em.createNativeQuery("delete from hs_office_sepamandate_legacy_id where true").executeUpdate();
|
|
||||||
em.createNativeQuery("delete from hs_office_debitor where true").executeUpdate();
|
|
||||||
em.createNativeQuery("delete from hs_office_bankaccount where true").executeUpdate();
|
|
||||||
em.createNativeQuery("delete from hs_office_partner where true").executeUpdate();
|
|
||||||
em.createNativeQuery("delete from hs_office_partner_details where true").executeUpdate();
|
|
||||||
em.createNativeQuery("delete from hs_office_relation where true").executeUpdate();
|
|
||||||
em.createNativeQuery("delete from hs_office_contact where true").executeUpdate();
|
|
||||||
em.createNativeQuery("delete from hs_office_person where true").executeUpdate();
|
|
||||||
}).assertSuccessful();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void resetFromHsOfficeSequences() {
|
|
||||||
jpaAttempt.transacted(() -> {
|
|
||||||
context(rbacSuperuser);
|
|
||||||
em.createNativeQuery("alter sequence hs_office_contact_legacy_id_seq restart with 1000000000;").executeUpdate();
|
|
||||||
em.createNativeQuery("alter sequence hs_office_coopassetstransaction_legacy_id_seq restart with 1000000000;")
|
|
||||||
.executeUpdate();
|
|
||||||
em.createNativeQuery("alter sequence public.hs_office_coopsharestransaction_legacy_id_seq restart with 1000000000;")
|
|
||||||
.executeUpdate();
|
|
||||||
em.createNativeQuery("alter sequence public.hs_office_partner_legacy_id_seq restart with 1000000000;")
|
|
||||||
.executeUpdate();
|
|
||||||
em.createNativeQuery("alter sequence public.hs_office_sepamandate_legacy_id_seq restart with 1000000000;")
|
|
||||||
.executeUpdate();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void deleteFromTestTables() {
|
|
||||||
jpaAttempt.transacted(() -> {
|
|
||||||
context(rbacSuperuser);
|
|
||||||
em.createNativeQuery("delete from test_domain where true").executeUpdate();
|
|
||||||
em.createNativeQuery("delete from test_package where true").executeUpdate();
|
|
||||||
em.createNativeQuery("delete from test_customer where true").executeUpdate();
|
|
||||||
}).assertSuccessful();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void deleteFromRbacTables() {
|
|
||||||
jpaAttempt.transacted(() -> {
|
|
||||||
context(rbacSuperuser);
|
|
||||||
em.createNativeQuery("delete from rbacuser_rv where name not like 'superuser-%'").executeUpdate();
|
|
||||||
em.createNativeQuery("delete from tx_journal where true").executeUpdate();
|
|
||||||
em.createNativeQuery("delete from tx_context where true").executeUpdate();
|
|
||||||
}).assertSuccessful();
|
|
||||||
}
|
|
||||||
|
|
||||||
private <E extends RbacObject> void updateLegacyIds(
|
private <E extends RbacObject> void updateLegacyIds(
|
||||||
Map<Integer, E> entities,
|
Map<Integer, E> entities,
|
||||||
final String legacyIdTable,
|
final String legacyIdTable,
|
||||||
|
Loading…
Reference in New Issue
Block a user