ComponentTxData { Optional<TransactionalAnnotationAttributes> getEffectiveType(Method m) { if (txMap.containsKey(m)) { return getTxAttr(m); } try { Method effectiveMethod = beanClass.getDeclaredMethod(m.getName(), m.getParameterTypes()); Optional<TransactionalAnnotationAttributes> txAttr = getTxAttr(effectiveMethod); txMap.put(m, txAttr); return txAttr; } catch (NoSuchMethodException e) { return getFromMethod(m); } catch (SecurityException e) { throw new RuntimeException("Security exception when determining effective method", e); } } ComponentTxData(Class<?> c); boolean isTransactional(); Class<?> getBeanClass();  }
@Test public void testFindAnnotationExtended() throws Exception { ComponentTxData txData = new ComponentTxData(ExtendedPojo.class); assertEquals(TxType.REQUIRED, getEffectiveType(txData, "defaultType").getTxType()); assertEquals(TxType.SUPPORTS, getEffectiveType(txData, "supports").getTxType()); }
@Test public void testFindAnnotationExtended2() throws Exception { ComponentTxData txData = new ComponentTxData(ExtendedPojo2.class); assertEquals(TxType.MANDATORY, getEffectiveType(txData, "defaultType").getTxType()); assertEquals(TxType.SUPPORTS, getEffectiveType(txData, "supports").getTxType()); }
@Test public void testFindAnnotationExtended3() throws Exception { ComponentTxData txData = new ComponentTxData(ExtendedPojo3.class); assertEquals(TxType.MANDATORY, getEffectiveType(txData, "defaultType").getTxType()); assertEquals(TxType.REQUIRED, getEffectiveType(txData, "supports").getTxType()); }
@Test public void testOnRollback() { ComponentTxData txData = new ComponentTxData(OnRollbackPojo.class); List<Class> rollbackOnBatchUpdateException = getEffectiveType(txData, "throwBatchUpdateException").getRollbackOn(); assertFalse(rollbackOnBatchUpdateException.contains(SQLDataException.class)); assertTrue(rollbackOnBatchUpdateException.contains(BatchUpdateException.class)); List<Class> rollbackOnSQLDataException = getEffectiveType(txData, "throwSQLDataException").getRollbackOn(); assertTrue(rollbackOnSQLDataException.contains(SQLDataException.class)); assertFalse(rollbackOnSQLDataException.contains(BatchUpdateException.class)); }