PmaRegistryImpl implements PmaRegistry { @Override @Transactional(value = Transactional.TxType.REQUIRED, rollbackOn = {RuntimeException.class, Exception.class}) public Map<NetConfResponse, List<Notification>> executeNC(String deviceName, String netconfRequest) throws IllegalArgumentException, IllegalStateException, ExecutionException { return executeWithPmaSession(deviceName, session -> session.executeNC(netconfRequest)); } PmaRegistryImpl(DeviceManager deviceManager,
                           PmaSessionFactory factory); @Override @Transactional(value = Transactional.TxType.REQUIRED, rollbackOn = {RuntimeException.class, Exception.class}) Map<NetConfResponse, List<Notification>> executeNC(String deviceName, String netconfRequest); @Override RT executeWithPmaSession(String deviceName, PmaSessionTemplate<RT> sessionTemplate); @Override void forceAlign(String deviceName); @Override void align(String deviceName); void deviceRemoved(String deviceName); @Override NetConfResponse getAllPersistCfg(String deviceName); static final String COMPONENT_ID; }
@Test public void testExceptionIsThrownWhenDeviceNotManaged() throws ExecutionException { try { m_pmaRegistry.executeNC("device2", ""); fail("Expected an exception here"); } catch (IllegalArgumentException e) { assertEquals("Device not managed : device2", e.getMessage()); } }
@Ignore("This is applicable only in transparent mode") @Test public void testExceptionIsThrownWhenNoConnectionToDevice() throws ExecutionException { when(m_cm.isConnected(m_device1Meta)).thenReturn(false); try { m_pmaRegistry.executeNC("device1", ""); fail("Expected an exception here"); } catch (IllegalStateException e) { assertEquals("Device not connected : device1", e.getMessage()); } }