use of io.joynr.smrf.EncodingException in project joynr by bmwcarit.
the class MessagingServiceResponseMatchers method containsPayload.
public static Matcher<List<ImmutableMessage>> containsPayload(final String payload) {
return new BaseMatcher<List<ImmutableMessage>>() {
@Override
public boolean matches(Object item) {
@SuppressWarnings("unchecked") List<ImmutableMessage> messages = (List<ImmutableMessage>) item;
byte[] binaryPayload = payload.getBytes(Charsets.UTF_8);
for (ImmutableMessage message : messages) {
try {
if (Arrays.equals(message.getUnencryptedBody(), binaryPayload)) {
return true;
}
} catch (EncodingException e) {
e.printStackTrace();
return false;
}
}
return false;
}
@Override
public void describeTo(Description arg0) {
}
};
}
Aggregations