merge SPM-14
This commit is contained in:
commit
cdd93d7e64
|
@ -36,30 +36,20 @@ public class WeekOverview implements Analysis<Map<String, Map.Entry<Double, Inte
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = new HashMap<>();
|
result = new HashMap<>();
|
||||||
int dayIndex = Attribute.SHOPPING_DAY;
|
|
||||||
int amountIndex = Attribute.PURCHASE_AMOUNT;
|
|
||||||
|
|
||||||
int startArticles = Attribute.POWER_TOOLS;
|
|
||||||
int endArticles = Attribute.GARDENING_TOOLS + 1;
|
|
||||||
|
|
||||||
for (int i = 0; i < instances.numInstances(); i++) {
|
for (int i = 0; i < instances.numInstances(); i++) {
|
||||||
Instance instance = instances.get(i);
|
Instance instance = instances.get(i);
|
||||||
double amount = instance.value(amountIndex);
|
double amount = instance.value(Attribute.PURCHASE_AMOUNT);
|
||||||
String day = instance.stringValue(dayIndex);
|
String day = instance.stringValue(Attribute.SHOPPING_DAY);
|
||||||
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
for (int j = startArticles; j < endArticles; j++) {
|
|
||||||
count += (int) instance.value(j);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!result.containsKey(day)) {
|
if (!result.containsKey(day)) {
|
||||||
result.put(day, new AbstractMap.SimpleEntry<>(0.0, 0));
|
result.put(day, new AbstractMap.SimpleEntry<>(0.0, 0));
|
||||||
}
|
}
|
||||||
result.put(day,
|
result.put(day,
|
||||||
new AbstractMap.SimpleEntry<>(
|
new AbstractMap.SimpleEntry<>(
|
||||||
result.get(day).getKey() + amount,
|
result.get(day).getKey() + amount,
|
||||||
result.get(day).getValue() + count
|
result.get(day).getValue() + 1
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,7 @@ class WeekOverviewTest {
|
||||||
|
|
||||||
AtomicReference<Map<String, Map.Entry<Double, Integer>>> result = new AtomicReference<>();
|
AtomicReference<Map<String, Map.Entry<Double, Integer>>> result = new AtomicReference<>();
|
||||||
|
|
||||||
assertTimeout(Duration.ofMillis(5), () -> result.set(overview.getResult()));
|
assertTimeout(Duration.ofMillis(15), () -> result.set(overview.getResult()));
|
||||||
|
|
||||||
|
|
||||||
assertEquals(2477, result.get().get("Montag").getKey());
|
assertEquals(2477, result.get().get("Montag").getKey());
|
||||||
assertEquals(3359, result.get().get("Dienstag").getKey());
|
assertEquals(3359, result.get().get("Dienstag").getKey());
|
||||||
|
@ -40,12 +39,12 @@ class WeekOverviewTest {
|
||||||
assertEquals(2399, result.get().get("Freitag").getKey());
|
assertEquals(2399, result.get().get("Freitag").getKey());
|
||||||
assertEquals(18273, result.get().get("Samstag").getKey());
|
assertEquals(18273, result.get().get("Samstag").getKey());
|
||||||
|
|
||||||
assertEquals(3216, result.get().get("Montag").getValue());
|
assertEquals(8, result.get().get("Montag").getValue());
|
||||||
assertEquals(5503, result.get().get("Dienstag").getValue());
|
assertEquals(13, result.get().get("Dienstag").getValue());
|
||||||
assertEquals(1888, result.get().get("Mittwoch").getValue());
|
assertEquals(5, result.get().get("Mittwoch").getValue());
|
||||||
assertEquals(3568, result.get().get("Donnerstag").getValue());
|
assertEquals(9, result.get().get("Donnerstag").getValue());
|
||||||
assertEquals(2953, result.get().get("Freitag").getValue());
|
assertEquals(10, result.get().get("Freitag").getValue());
|
||||||
assertEquals(26243, result.get().get("Samstag").getValue());
|
assertEquals(55, result.get().get("Samstag").getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -57,8 +56,7 @@ class WeekOverviewTest {
|
||||||
|
|
||||||
AtomicReference<Map<String, Map.Entry<Double, Integer>>> result = new AtomicReference<>();
|
AtomicReference<Map<String, Map.Entry<Double, Integer>>> result = new AtomicReference<>();
|
||||||
|
|
||||||
assertTimeout(Duration.ofMillis(7), () -> result.set(overview.getResult()));
|
assertTimeout(Duration.ofMillis(15), () -> result.set(overview.getResult()));
|
||||||
|
|
||||||
|
|
||||||
assertEquals(26273, result.get().get("Montag").getKey());
|
assertEquals(26273, result.get().get("Montag").getKey());
|
||||||
assertEquals(23345, result.get().get("Dienstag").getKey());
|
assertEquals(23345, result.get().get("Dienstag").getKey());
|
||||||
|
@ -67,12 +65,12 @@ class WeekOverviewTest {
|
||||||
assertEquals(26413, result.get().get("Freitag").getKey());
|
assertEquals(26413, result.get().get("Freitag").getKey());
|
||||||
assertEquals(146279, result.get().get("Samstag").getKey());
|
assertEquals(146279, result.get().get("Samstag").getKey());
|
||||||
|
|
||||||
assertEquals(39839, result.get().get("Montag").getValue());
|
assertEquals(108, result.get().get("Montag").getValue());
|
||||||
assertEquals(34992, result.get().get("Dienstag").getValue());
|
assertEquals(93, result.get().get("Dienstag").getValue());
|
||||||
assertEquals(37299, result.get().get("Mittwoch").getValue());
|
assertEquals(89, result.get().get("Mittwoch").getValue());
|
||||||
assertEquals(35005, result.get().get("Donnerstag").getValue());
|
assertEquals(90, result.get().get("Donnerstag").getValue());
|
||||||
assertEquals(38911, result.get().get("Freitag").getValue());
|
assertEquals(110, result.get().get("Freitag").getValue());
|
||||||
assertEquals(214051, result.get().get("Samstag").getValue());
|
assertEquals(510, result.get().get("Samstag").getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -84,8 +82,7 @@ class WeekOverviewTest {
|
||||||
|
|
||||||
AtomicReference<Map<String, Map.Entry<Double, Integer>>> result = new AtomicReference<>();
|
AtomicReference<Map<String, Map.Entry<Double, Integer>>> result = new AtomicReference<>();
|
||||||
|
|
||||||
assertTimeout(Duration.ofMillis(60), () -> result.set(overview.getResult()));
|
assertTimeout(Duration.ofMillis(50), () -> result.set(overview.getResult()));
|
||||||
|
|
||||||
|
|
||||||
assertEquals(295688, result.get().get("Montag").getKey());
|
assertEquals(295688, result.get().get("Montag").getKey());
|
||||||
assertEquals(267269, result.get().get("Dienstag").getKey());
|
assertEquals(267269, result.get().get("Dienstag").getKey());
|
||||||
|
@ -94,11 +91,11 @@ class WeekOverviewTest {
|
||||||
assertEquals(330907, result.get().get("Freitag").getKey());
|
assertEquals(330907, result.get().get("Freitag").getKey());
|
||||||
assertEquals(1410789, result.get().get("Samstag").getKey());
|
assertEquals(1410789, result.get().get("Samstag").getKey());
|
||||||
|
|
||||||
assertEquals(426952, result.get().get("Montag").getValue());
|
assertEquals(1058, result.get().get("Montag").getValue());
|
||||||
assertEquals(379125, result.get().get("Dienstag").getValue());
|
assertEquals(942, result.get().get("Dienstag").getValue());
|
||||||
assertEquals(373891, result.get().get("Mittwoch").getValue());
|
assertEquals(915, result.get().get("Mittwoch").getValue());
|
||||||
assertEquals(356996, result.get().get("Donnerstag").getValue());
|
assertEquals(919, result.get().get("Donnerstag").getValue());
|
||||||
assertEquals(480062, result.get().get("Freitag").getValue());
|
assertEquals(1177, result.get().get("Freitag").getValue());
|
||||||
assertEquals(2015766, result.get().get("Samstag").getValue());
|
assertEquals(4989, result.get().get("Samstag").getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue