Browse Source

AbstractWebTest exception wrapper into runtime exception to use in async futures without try/catch overhead

pull/6431/head
Sergey Matvienko 4 years ago
parent
commit
f6e71e4b93
  1. 16
      application/src/test/java/org/thingsboard/server/controller/AbstractWebTest.java
  2. 3
      common/queue/src/main/java/org/thingsboard/server/queue/memory/InMemoryTbQueueConsumer.java

16
application/src/test/java/org/thingsboard/server/controller/AbstractWebTest.java

@ -503,16 +503,24 @@ public abstract class AbstractWebTest extends AbstractInMemoryStorageTest {
return readResponse(doGet(urlTemplate, vars).andExpect(status().isOk()), responseType);
}
protected <T> T doPost(String urlTemplate, Class<T> responseClass, String... params) throws Exception {
return readResponse(doPost(urlTemplate, params).andExpect(status().isOk()), responseClass);
protected <T> T doPost(String urlTemplate, Class<T> responseClass, String... params) {
try {
return readResponse(doPost(urlTemplate, params).andExpect(status().isOk()), responseClass);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
protected <T> T doPost(String urlTemplate, T content, Class<T> responseClass, ResultMatcher resultMatcher, String... params) throws Exception {
return readResponse(doPost(urlTemplate, content, params).andExpect(resultMatcher), responseClass);
}
protected <T> T doPost(String urlTemplate, T content, Class<T> responseClass, String... params) throws Exception {
return readResponse(doPost(urlTemplate, content, params).andExpect(status().isOk()), responseClass);
protected <T> T doPost(String urlTemplate, T content, Class<T> responseClass, String... params) {
try {
return readResponse(doPost(urlTemplate, content, params).andExpect(status().isOk()), responseClass);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
protected <T, R> R doPostWithResponse(String urlTemplate, T content, Class<R> responseClass, String... params) throws Exception {

3
common/queue/src/main/java/org/thingsboard/server/queue/memory/InMemoryTbQueueConsumer.java

@ -64,6 +64,9 @@ public class InMemoryTbQueueConsumer<T extends TbQueueMsg> implements TbQueueCon
@Override
public List<T> poll(long durationInMillis) {
if (topic.contains("main")){
log.warn("poll {} {}", topic, durationInMillis);
}
if (subscribed) {
@SuppressWarnings("unchecked")
List<T> messages = partitions

Loading…
Cancel
Save