@Test
public void testStoreDataFileWithTransaction_getDataFileFails() {

    final String path = "/left/of/rome";
    final String sql = "select f from DataFile f where f.path = ?1";
    final DataFile dataFile = createDataFile(path);
    doThrow(new PersistenceException(null, null, null, true)).when(persistenceManager).pick(sql, path);
    try {
        jpaStorage.storeWithTransaction(dataFile);
        fail("ToolException expected");
    } catch (ToolException expected) {
    }
    verify(persistenceManager, times(2)).transaction();
    verify(persistenceManager, times(1)).persist(dataFile);
    verify(persistenceManager, times(1)).commit();
    verify(persistenceManager, times(1)).pick(sql, path);
    verify(persistenceManager, times(1)).rollback();
    verify(persistenceManager, times(1)).pick("select s from Sensor s where s.name = ?1", "cloud");
    verifyNoMoreInteractions(persistenceManager);
}