|
|
|
@ -56,6 +56,7 @@ import java.util.stream.Stream; |
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
|
|
import static org.junit.jupiter.api.Assertions.assertNotSame; |
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue; |
|
|
|
import static org.mockito.Mockito.timeout; |
|
|
|
import static org.mockito.Mockito.verify; |
|
|
|
|
|
|
|
@ExtendWith(MockitoExtension.class) |
|
|
|
@ -115,18 +116,7 @@ public class TbRestApiCallNodeTest extends AbstractRuleNodeUpgradeTest { |
|
|
|
assertTrue(request.containsHeader("Foo"), "Custom header included"); |
|
|
|
assertEquals("Bar", request.getFirstHeader("Foo").getValue(), "Custom header value"); |
|
|
|
response.setStatusCode(200); |
|
|
|
new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
try { |
|
|
|
Thread.sleep(1000L); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
// ignore
|
|
|
|
} finally { |
|
|
|
latch.countDown(); |
|
|
|
} |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
latch.countDown(); |
|
|
|
} catch (Exception e) { |
|
|
|
System.out.println("Exception handling request: " + e.toString()); |
|
|
|
e.printStackTrace(); |
|
|
|
@ -158,7 +148,7 @@ public class TbRestApiCallNodeTest extends AbstractRuleNodeUpgradeTest { |
|
|
|
ArgumentCaptor<TbMsg> msgCaptor = ArgumentCaptor.forClass(TbMsg.class); |
|
|
|
ArgumentCaptor<TbMsgMetaData> metadataCaptor = ArgumentCaptor.forClass(TbMsgMetaData.class); |
|
|
|
ArgumentCaptor<String> dataCaptor = ArgumentCaptor.forClass(String.class); |
|
|
|
verify(ctx).transformMsg(msgCaptor.capture(), metadataCaptor.capture(), dataCaptor.capture()); |
|
|
|
verify(ctx, timeout(10_000)).transformMsg(msgCaptor.capture(), metadataCaptor.capture(), dataCaptor.capture()); |
|
|
|
|
|
|
|
assertNotSame(metaData, metadataCaptor.getValue()); |
|
|
|
assertEquals(TbMsg.EMPTY_JSON_OBJECT, dataCaptor.getValue()); |
|
|
|
@ -184,18 +174,7 @@ public class TbRestApiCallNodeTest extends AbstractRuleNodeUpgradeTest { |
|
|
|
assertTrue(request.containsHeader("Foo"), "Custom header included"); |
|
|
|
assertEquals("Bar", request.getFirstHeader("Foo").getValue(), "Custom header value"); |
|
|
|
response.setStatusCode(200); |
|
|
|
new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
try { |
|
|
|
Thread.sleep(1000L); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
// ignore
|
|
|
|
} finally { |
|
|
|
latch.countDown(); |
|
|
|
} |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
latch.countDown(); |
|
|
|
} catch (Exception e) { |
|
|
|
System.out.println("Exception handling request: " + e.toString()); |
|
|
|
e.printStackTrace(); |
|
|
|
@ -227,7 +206,7 @@ public class TbRestApiCallNodeTest extends AbstractRuleNodeUpgradeTest { |
|
|
|
ArgumentCaptor<TbMsg> msgCaptor = ArgumentCaptor.forClass(TbMsg.class); |
|
|
|
ArgumentCaptor<TbMsgMetaData> metadataCaptor = ArgumentCaptor.forClass(TbMsgMetaData.class); |
|
|
|
ArgumentCaptor<String> dataCaptor = ArgumentCaptor.forClass(String.class); |
|
|
|
verify(ctx).transformMsg(msgCaptor.capture(), metadataCaptor.capture(), dataCaptor.capture()); |
|
|
|
verify(ctx, timeout(10_000)).transformMsg(msgCaptor.capture(), metadataCaptor.capture(), dataCaptor.capture()); |
|
|
|
|
|
|
|
assertNotSame(metaData, metadataCaptor.getValue()); |
|
|
|
assertEquals(TbMsg.EMPTY_JSON_OBJECT, dataCaptor.getValue()); |
|
|
|
|