use of com.newrelic.agent.TransactionData in project newrelic-java-agent by newrelic.
the class CompletableFutureTest method testApplyEither.
@Test
public void testApplyEither() throws Exception {
TransactionDataList txs = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txs);
CompletableFuture<Integer> future = doApplyEither();
Integer result = future.get();
assertNotNull(result);
assertEquals(4, (int) result);
// Give the transaction time to finish
txs.waitFor(1, 5000);
assertEquals(1, txs.size());
TransactionData txData = txs.get(0);
Map<String, Object> userAttributes = txData.getUserAttributes();
assertNotNull(userAttributes);
assertEquals(3, userAttributes.size());
assertEquals(1, userAttributes.get("f1"));
assertEquals(2, userAttributes.get("f2"));
assertEquals(4, userAttributes.get("f3"));
}
use of com.newrelic.agent.TransactionData in project newrelic-java-agent by newrelic.
the class CompletableFutureTest method testNoComplete.
@Test
public void testNoComplete() throws InterruptedException, ExecutionException {
TransactionDataList txs = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txs);
CompletableFuture<Object> future = composeCompletable();
// Give the transaction time to finish
txs.waitFor(1, 5000);
assertEquals(1, txs.size());
TransactionData txData = txs.get(0);
Map<String, Object> userAttributes = txData.getUserAttributes();
assertNotNull(userAttributes);
assertEquals(0, userAttributes.size());
}
use of com.newrelic.agent.TransactionData in project newrelic-java-agent by newrelic.
the class CompletableFutureTest method testApplyAsync.
@Test
public void testApplyAsync() throws Exception {
TransactionDataList txs = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txs);
CompletableFuture<Integer> future = doApplyAsync();
Integer result = future.get();
assertNotNull(result);
assertEquals(2, (int) result);
// Give the transaction time to finish
txs.waitFor(1, 5000);
assertEquals(1, txs.size());
TransactionData txData = txs.get(0);
Map<String, Object> userAttributes = txData.getUserAttributes();
assertNotNull(userAttributes);
assertEquals(2, userAttributes.size());
assertEquals(2, userAttributes.get("b"));
assertEquals(4, userAttributes.get("f"));
}
use of com.newrelic.agent.TransactionData in project newrelic-java-agent by newrelic.
the class CompletableFutureTest method testCompletableFutureError.
@Test
public void testCompletableFutureError() throws Exception {
TransactionDataList txs = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txs);
CompletableFuture<Integer> future = doCompletableFutureError();
Integer result = future.get();
assertNotNull(result);
assertEquals(3, (int) result);
// Give the transaction time to finish
txs.waitFor(1, 5000);
assertEquals(1, txs.size());
TransactionData txData = txs.get(0);
Map<String, Object> userAttributes = txData.getUserAttributes();
assertNotNull(userAttributes);
assertEquals(2, userAttributes.size());
assertEquals(1, userAttributes.get("f1"));
// f2 is not here because the "exceptionally" function will get called instead
assertEquals(3, userAttributes.get("e"));
}
use of com.newrelic.agent.TransactionData in project newrelic-java-agent by newrelic.
the class CompletableFutureTest method testAcceptBothAsync.
@Test
public void testAcceptBothAsync() {
TransactionDataList txs = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txs);
acceptBothAsync();
pause(500);
AgentHelper.verifyMetrics(AgentHelper.getMetrics(), TRANSACTION_NAME);
TransactionData transactionData = txs.get(0);
Map<String, Object> userAttributes = transactionData.getUserAttributes();
assertTrue(userAttributes.containsKey("three"));
}
Aggregations