Compare commits

..

3 Commits

Author SHA1 Message Date
Michael Hoennig
731fa369ad better selection of test-data 2024-07-17 06:09:56 +02:00
Michael Hoennig
7d87a30d93 import booking items + its resources 2024-07-16 19:53:42 +02:00
Michael Hoennig
754231feb2 .gitignore /src/test/resources/migration-prod/* 2024-07-16 15:33:06 +02:00
3 changed files with 233 additions and 39 deletions

2
.gitignore vendored
View File

@ -141,4 +141,4 @@ Desktop.ini
# Project Related # Project Related
###################### ######################
/.environment* /.environment*
/src/test/resources/migration-prod/ /src/test/resources/migration-prod/*

View File

@ -139,6 +139,7 @@ public class CsvDataImport extends ContextBasedTest {
map.keySet().stream() map.keySet().stream()
.map(id -> " " + id + "=" + map.get(id).toString()) .map(id -> " " + id + "=" + map.get(id).toString())
.map(e -> e.replaceAll("\n ", " ").replace("\n", "")) .map(e -> e.replaceAll("\n ", " ").replace("\n", ""))
.sorted()
.collect(Collectors.joining(",\n")) + .collect(Collectors.joining(",\n")) +
"\n}\n"; "\n}\n";
} }

View File

@ -2,6 +2,7 @@ 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.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.rbac.test.JpaAttempt; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
@ -16,10 +17,10 @@ import org.springframework.context.annotation.Import;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import java.io.Reader; import java.io.Reader;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static java.util.Arrays.stream;
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;
@ -77,9 +78,12 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ImportHostingAssets extends CsvDataImport { public class ImportHostingAssets extends CsvDataImport {
private static final Integer IP_NUMBER_ID_OFFSET = 1000000; private static final Integer IP_NUMBER_ID_OFFSET = 1000000;
private static final Integer PACKET_ID_OFFSET = 2000000; private static final Integer HIVE_ID_OFFSET = 2000000;
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) {}
;
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<>();
@ -102,13 +106,13 @@ public class ImportHostingAssets extends CsvDataImport {
assumeThatWeAreImportingControlledTestData(); assumeThatWeAreImportingControlledTestData();
// no contacts yet => mostly null values // no contacts yet => mostly null values
assertThat(toFormattedString(firstOfType(5, hostingAssets, IPV4_NUMBER))).isEqualToIgnoringWhitespace(""" assertThat(firstOfEachType(5, IPV4_NUMBER)).isEqualToIgnoringWhitespace("""
{ {
1000333=HsHostingAssetEntity(IPV4_NUMBER, 83.223.95.4), 1000329=HsHostingAssetEntity(IPV4_NUMBER, 83.223.95.0),
1000332=HsHostingAssetEntity(IPV4_NUMBER, 83.223.95.3),
1000331=HsHostingAssetEntity(IPV4_NUMBER, 83.223.95.2),
1000330=HsHostingAssetEntity(IPV4_NUMBER, 83.223.95.1), 1000330=HsHostingAssetEntity(IPV4_NUMBER, 83.223.95.1),
1000329=HsHostingAssetEntity(IPV4_NUMBER, 83.223.95.0) 1000331=HsHostingAssetEntity(IPV4_NUMBER, 83.223.95.2),
1000332=HsHostingAssetEntity(IPV4_NUMBER, 83.223.95.3),
1000333=HsHostingAssetEntity(IPV4_NUMBER, 83.223.95.4)
} }
"""); """);
} }
@ -132,21 +136,21 @@ public class ImportHostingAssets extends CsvDataImport {
// no contacts yet => mostly null values // no contacts yet => mostly null values
assertThat(toFormattedString(first(5, hives))).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(first(5, hives))).isEqualToIgnoringWhitespace("""
{ {
1=Hive[hive_id=1, hive_name=h01, inet_addr_id=358], 2000001=Hive[hive_id=1, hive_name=h01, inet_addr_id=358],
2=Hive[hive_id=2, hive_name=h02, inet_addr_id=359], 2000002=Hive[hive_id=2, hive_name=h02, inet_addr_id=359],
4=Hive[hive_id=4, hive_name=h03, inet_addr_id=360], 2000004=Hive[hive_id=4, hive_name=h03, inet_addr_id=360],
7=Hive[hive_id=7, hive_name=h04, inet_addr_id=361], 2000007=Hive[hive_id=7, hive_name=h04, inet_addr_id=361],
13=Hive[hive_id=13, hive_name=h05, inet_addr_id=430] 2000013=Hive[hive_id=13, hive_name=h05, inet_addr_id=430]
} }
"""); """);
} }
@Test @Test
@Order(2000) @Order(2000)
void importServersAndWebspaces() { 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);
importServersAndWebspaces(justHeader(lines), withoutHeader(lines)); importPackets(justHeader(lines), withoutHeader(lines));
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -154,17 +158,100 @@ public class ImportHostingAssets extends CsvDataImport {
@Test @Test
@Order(2009) @Order(2009)
void verifyServersAndWebspaces() { void verifyPackets() {
assumeThatWeAreImportingControlledTestData();
assertThat(firstOfEachType(3, CLOUD_SERVER, MANAGED_SERVER, MANAGED_WEBSPACE)).isEqualToIgnoringWhitespace("""
{
3000003=HsHostingAssetEntity(MANAGED_WEBSPACE, agu00, D-???????-?:agu00),
3000007=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr00, D-???????-?:ahr00),
3000008=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr01, D-???????-?:ahr01),
3000964=HsHostingAssetEntity(MANAGED_SERVER, vm1064, D-???????-?:vm1064),
3000966=HsHostingAssetEntity(MANAGED_SERVER, vm1063, D-???????-?:vm1063),
3000967=HsHostingAssetEntity(MANAGED_SERVER, vm1062, D-???????-?:vm1062),
3023611=HsHostingAssetEntity(CLOUD_SERVER, vm2097, D-???????-?:vm2097),
3023612=HsHostingAssetEntity(CLOUD_SERVER, vm2062, D-???????-?:vm2062),
3023613=HsHostingAssetEntity(CLOUD_SERVER, vm2058, D-???????-?:vm2058)
}
""");
assertThat(firstOfEachType(
3,
HsBookingItemType.CLOUD_SERVER,
HsBookingItemType.MANAGED_SERVER,
HsBookingItemType.MANAGED_WEBSPACE)).isEqualToIgnoringWhitespace("""
{
3000003=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), agu00),
3000007=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), ahr00),
3000008=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), ahr01),
3000964=HsBookingItemEntity(MANAGED_SERVER, [2024-07-17,), vm1064),
3000966=HsBookingItemEntity(MANAGED_SERVER, [2024-07-17,), vm1063),
3000967=HsBookingItemEntity(MANAGED_SERVER, [2024-07-17,), vm1062),
3023611=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2097),
3023612=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2062),
3023613=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2058)
}
""");
}
@Test
@Order(2010)
void importPacketComponents() {
try (Reader reader = resourceReader(MIGRATION_DATA_PATH + "packet_component.csv")) {
final var lines = readAllLines(reader);
importPacketComponents(justHeader(lines), withoutHeader(lines));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Test
@Order(2019)
void verifyPacketComponents() {
assumeThatWeAreImportingControlledTestData(); assumeThatWeAreImportingControlledTestData();
// no contacts yet => mostly null values // no contacts yet => mostly null values
assertThat(toFormattedString(firstOfType(5, hostingAssets, CLOUD_SERVER, MANAGED_SERVER, MANAGED_WEBSPACE))).isEqualToIgnoringWhitespace(""" assertThat(firstOfEachType(5, CLOUD_SERVER, MANAGED_SERVER, MANAGED_WEBSPACE))
.isEqualToIgnoringWhitespace("""
{ {
2000012=HsHostingAssetEntity(MANAGED_WEBSPACE, al000), 3000003=HsHostingAssetEntity(MANAGED_WEBSPACE, agu00, D-???????-?:agu00),
2000008=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr01), 3000007=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr00, D-???????-?:ahr00),
2000009=HsHostingAssetEntity(MANAGED_WEBSPACE, aih00), 3000008=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr01, D-???????-?:ahr01),
2000007=HsHostingAssetEntity(MANAGED_WEBSPACE, ahr00), 3000009=HsHostingAssetEntity(MANAGED_WEBSPACE, aih00, D-???????-?:aih00),
2000003=HsHostingAssetEntity(MANAGED_WEBSPACE, agu00) 3000012=HsHostingAssetEntity(MANAGED_WEBSPACE, al000, D-???????-?:al000),
3000964=HsHostingAssetEntity(MANAGED_SERVER, vm1064, D-???????-?:vm1064),
3000966=HsHostingAssetEntity(MANAGED_SERVER, vm1063, D-???????-?:vm1063),
3000967=HsHostingAssetEntity(MANAGED_SERVER, vm1062, D-???????-?:vm1062),
3000968=HsHostingAssetEntity(MANAGED_SERVER, vm1061, D-???????-?:vm1061),
3000969=HsHostingAssetEntity(MANAGED_SERVER, vm1060, D-???????-?:vm1060),
3023611=HsHostingAssetEntity(CLOUD_SERVER, vm2097, D-???????-?:vm2097),
3023612=HsHostingAssetEntity(CLOUD_SERVER, vm2062, D-???????-?:vm2062),
3023613=HsHostingAssetEntity(CLOUD_SERVER, vm2058, D-???????-?:vm2058),
3023614=HsHostingAssetEntity(CLOUD_SERVER, vm2055, D-???????-?:vm2055),
3023615=HsHostingAssetEntity(CLOUD_SERVER, vm2010, D-???????-?:vm2010)
}
""");
assertThat(firstOfEachType(
5,
HsBookingItemType.CLOUD_SERVER,
HsBookingItemType.MANAGED_SERVER,
HsBookingItemType.MANAGED_WEBSPACE))
.isEqualToIgnoringWhitespace("""
{
3000003=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), agu00, { "Multi": 3, "SLA-Platform": "EXT24H", "SSD": 8192, "Traffic": 20}),
3000007=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), ahr00, { "Multi": 6, "SLA-Platform": "EXT24H", "SSD": 25600, "Traffic": 10}),
3000008=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), ahr01, { "Multi": 3, "SLA-Platform": "EXT24H", "SSD": 5120, "Traffic": 10}),
3000009=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), aih00, { "HDD": 20480, "Multi": 2, "SLA-Platform": "BASIC", "SSD": 3072, "Traffic": 10}),
3000012=HsBookingItemEntity(MANAGED_WEBSPACE, [2024-07-17,), al000, { "HDD": 10240, "Multi": 3, "SLA-Platform": "BASIC", "SSD": 6144, "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}),
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}),
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}),
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}),
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}),
3023611=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2097, { "CPU": 8, "RAM": 12288, "SLA-Infrastructure": "EXT4H", "SLA-Platform": "BASIC", "SSD": 25600, "Traffic": 250}),
3023612=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2062, { "CPU": 10, "RAM": 65536, "SLA-Infrastructure": "EXT4H", "SLA-Platform": "BASIC", "SSD": 25600, "Traffic": 250}),
3023613=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2058, { "CPU": 1, "RAM": 8192, "SLA-Infrastructure": "EXT4H", "SLA-Platform": "BASIC", "SSD": 25600, "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}),
3023615=HsBookingItemEntity(CLOUD_SERVER, [2024-07-17,), vm2010, { "CPU": 2, "RAM": 2048, "SLA-Infrastructure": "EXT4H", "SLA-Platform": "BASIC", "SSD": 51200, "Traffic": 250})
} }
"""); """);
} }
@ -191,14 +278,15 @@ public class ImportHostingAssets extends CsvDataImport {
.map(row -> new Record(columns, row)) .map(row -> new Record(columns, row))
.forEach(rec -> { .forEach(rec -> {
final var hive_id = rec.getInteger("hive_id"); final var hive_id = rec.getInteger("hive_id");
final var hive = new Hive(hive_id, final var hive = new Hive(
hive_id,
rec.getString("hive_name"), rec.getString("hive_name"),
rec.getInteger("inet_addr_id")); rec.getInteger("inet_addr_id"));
hives.put(hive_id, hive); hives.put(HIVE_ID_OFFSET + hive_id, hive);
}); });
} }
private void importServersAndWebspaces(final String[] header, final List<String[]> records) { private void importPackets(final String[] header, final List<String[]> records) {
final var columns = new Columns(header); final var columns = new Columns(header);
records.stream() records.stream()
.map(this::trimAll) .map(this::trimAll)
@ -216,29 +304,134 @@ 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 bookingItem = HsBookingItemEntity.builder()
.type(switch (rec.getString("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: " + rec.getString("basepacket_code"));
})
.caption(packet_name)
.build();
bookingItems.put(PACKET_ID_OFFSET + packet_id, bookingItem);
final var asset = HsHostingAssetEntity.builder() final var asset = HsHostingAssetEntity.builder()
.type(switch (rec.getString("basepacket_code")) { .type(switch (rec.getString("basepacket_code")) {
case "SRV/CLD" -> CLOUD_SERVER; case "SRV/CLD" -> CLOUD_SERVER;
case "SRV/MGD" -> MANAGED_SERVER; case "SRV/MGD" -> MANAGED_SERVER;
case "PAC/WEB" -> MANAGED_WEBSPACE; case "PAC/WEB" -> MANAGED_WEBSPACE;
default -> throw new IllegalArgumentException("unknown basepacket_code: " + rec.getString("basepacket_code")); default -> throw new IllegalArgumentException(
"unknown basepacket_code: " + rec.getString("basepacket_code"));
}) })
.identifier(rec.getString("packet_name")) .identifier(rec.getString("packet_name"))
.bookingItem(bookingItem)
// .caption(rec.getString("description")) // .caption(rec.getString("description"))
.build(); .build();
hostingAssets.put(PACKET_ID_OFFSET + packet_id, asset); hostingAssets.put(PACKET_ID_OFFSET + packet_id, asset);
}); });
} }
private Map<Integer, Object> firstOfType( private void importPacketComponents(final String[] header, final List<String[]> records) {
final var columns = new Columns(header);
records.stream()
.map(this::trimAll)
.map(row -> new Record(columns, row))
.forEach(rec -> {
final var packet_component_id = rec.getInteger("packet_component_id");
final var packet_id = rec.getInteger("packet_id");
final var quantity = rec.getInteger("quantity");
final var basecomponent_code = rec.getString("basecomponent_code");
final var created = rec.getLocalDate("created");
final var cancelled = rec.getLocalDate("cancelled");
final var asset = hostingAssets.get(PACKET_ID_OFFSET + packet_id);
final var name = switch (basecomponent_code) {
case "DAEMON" -> "Daemons";
case "MULTI" -> "Multi";
case "CPU" -> "CPU";
case "RAM" -> "RAM";
case "QUOTA" -> "SSD";
case "STORAGE" -> "HDD";
case "TRAFFIC" -> "Traffic";
case "OFFICE" -> "Online Office Server";
case "SLABASIC" -> "SLA-Platform";
case "SLAINFR2H" -> "SLA-Infrastructure";
case "SLAINFR4H" -> "SLA-Infrastructure";
case "SLAINFR8H" -> "SLA-Infrastructure";
case "SLAEXT24H" -> "SLA-Platform";
case "SLAPLAT2H" -> "SLA-Platform";
case "SLAPLAT4H" -> "SLA-Platform";
case "SLAPLAT8H" -> "SLA-Platform";
case "SLAWEB2H" -> "SLA-Web";
case "SLAWEB4H" -> "SLA-Web";
case "SLAWEB8H" -> "SLA-Web";
case "SLAMAIL2H" -> "SLA-EMail";
case "SLAMAIL4H" -> "SLA-EMail";
case "SLAMAIL8H" -> "SLA-EMail";
case "SLAMARIA2H" -> "SLA-Maria";
case "SLAMARIA4H" -> "SLA-Maria";
case "SLAMARIA8H" -> "SLA-Maria";
case "SLAPGSQL2H" -> "SLA-PgSQL";
case "SLAPGSQL4H" -> "SLA-PgSQL";
case "SLAPGSQL8H" -> "SLA-PgSQL";
case "SLAOFFIC2H" -> "SLA-Office";
case "SLAOFFIC4H" -> "SLA-Office";
case "SLAOFFIC8H" -> "SLA-Office";
case "BANDWIDTH" -> null; // TODO.spec: not implemented yet
default -> throw new IllegalArgumentException("unknown basecomponent_code: " + basecomponent_code);
};
if (name == null) {
} else if (name.equals("SLA-Infrastructure")) {
final var slaValue = switch (basecomponent_code) {
case "SLAINFR2H" -> "EXT2H";
case "SLAINFR4H" -> "EXT4H";
case "SLAINFR8H" -> "EXT4H";
default -> throw new IllegalArgumentException("unknown basecomponent_code: " + basecomponent_code);
};
asset.getBookingItem().getResources().put(name, slaValue);
} else if (name.equals("SLA-Platform")) {
final var slaValue = switch (basecomponent_code) {
case "SLABASIC" -> "BASIC";
case "SLAPLAT2H" -> "EXT2H";
case "SLAPLAT4H" -> "EXT4H";
case "SLAEXT24H" -> "EXT24H";
case "SLAPLAT8H" -> "EXT8H";
default -> throw new IllegalArgumentException("unknown basecomponent_code: " + basecomponent_code);
};
asset.getBookingItem().getResources().put(name, slaValue);
} else if (name.startsWith("SLA")) {
asset.getBookingItem().getResources().put(name, true);
} else if (quantity > 0) {
asset.getBookingItem().getResources().put(name, quantity);
}
});
}
private String firstOfEachType(
final int maxCount, final int maxCount,
final Map<Integer, HsHostingAssetEntity> hostingAssets,
final HsHostingAssetType... types) { final HsHostingAssetType... types) {
final var typesList = Arrays.asList(types); return toFormattedString(stream(types)
return hostingAssets.entrySet().stream() .flatMap(t ->
.filter(ha -> typesList.contains(ha.getValue().getType())) hostingAssets.entrySet().stream()
.filter(hae -> hae.getValue().getType() == t)
.limit(maxCount) .limit(maxCount)
.collect(toMap(Map.Entry::getKey, Map.Entry::getValue)); )
.collect(toMap(Map.Entry::getKey, Map.Entry::getValue)));
}
private String firstOfEachType(
final int maxCount,
final HsBookingItemType... types) {
return toFormattedString(stream(types)
.flatMap(t ->
bookingItems.entrySet().stream()
.filter(bie -> bie.getValue().getType() == t)
.limit(maxCount)
)
.collect(toMap(Map.Entry::getKey, Map.Entry::getValue)));
} }
private Map<Integer, Object> first( private Map<Integer, Object> first(