ericyu
(yuhongxi)
April 28, 2018, 12:12pm
1
when i study AKKA, in the documentation i have found a Testkit part at Part 5: Querying Device Groups missing one function implements;like this:
Testing the query actor:
assertEqualTemperatures(expectedTemperatures, response.temperatures);
the function of assertEqualTemperatures how to do?
please friends could help me,thanks.
bentito
(Brett Tofel)
April 28, 2018, 12:41pm
2
I found it, but it was a bit hard to track down as there is a 404’ed link from the tutorial:
public static void assertEqualTemperatures(Map<String, DeviceGroup.TemperatureReading> expected, Map<String, DeviceGroup.TemperatureReading> actual) {
for (Map.Entry<String, DeviceGroup.TemperatureReading> entry : expected.entrySet()) {
DeviceGroup.TemperatureReading expectedReading = entry.getValue();
DeviceGroup.TemperatureReading actualReading = actual.get(entry.getKey());
assertNotNull(actualReading);
assertEquals(expectedReading.getClass(), actualReading.getClass());
if (expectedReading instanceof DeviceGroup.Temperature) {
assertEquals(((DeviceGroup.Temperature) expectedReading).value, ((DeviceGroup.Temperature) actualReading).value, 0.01);
}
}
assertEquals(expected.size(), actual.size());
}
Which I got from here: https://github.com/akka/akka/blob/master/akka-docs/src/test/java/jdocs/tutorial_5/DeviceGroupQueryTest.java
Maintainers: This is the 404’ed link in the tutorial:
http://github.com/akka/akka/tree/master/akka-docs/src/main/paradox/java/guide/tutorial.md
Which is found at bottom of page here (and probably other locations too:
https://doc.akka.io/docs/akka/2.5.5/java/guide/tutorial.html
ktoso
(Konrad `ktoso` Malawski)
April 28, 2018, 12:43pm
3
@bentito Thanks for answering :-) Please the up to date version of the docs, though: https://doc.akka.io/docs/akka/2.5.12/guide/tutorial.html?language=java The link works there.
Or better yet, always use the “current” link: https://doc.akka.io/docs/akka/current/guide/tutorial.html?language=java
Yes, that’s how to get to the file.
Note also that the code there is not doing anything akka specific – it is mostly plain old junit assertions, thus it was omitted as the guide focuses only on the relevant Akka parts.
PS: Please spell Akka as Akka, not all in caps :-)
Hope this helps!