StandardModelRegistrator { public void onDeployed(DeviceAdapter adapter, AdapterContext adapterContext) { for (StandardAdapterModelRegistrator registrator : m_standardModelRegistrators) { registrator.onDeployed(adapter, adapterContext); } } StandardModelRegistrator(NotificationService notificationService, AlarmService alarmService,
                                    SchemaRegistry dmSchemaRegistry); void onDeployed(DeviceAdapter adapter, AdapterContext adapterContext); void onUndeployed(DeviceAdapter adapter, AdapterContext adapterContext); Set<StandardAdapterModelRegistrator> getStandardPlugRegistrators(); void setOldIdentities(Set<IdentitySchemaNode> oldIdentities);  }
@Test public void testDeploymentOfSamePlugTwice() throws Exception { ArgumentCaptor<List> infoCaptor = ArgumentCaptor.forClass(List.class); NotificationContext context = new NotificationContext(); m_registry.buildSchemaContext(getYangFiles(), Collections.emptySet(), Collections.emptyMap()); AlarmService alarmService = new AlarmServiceImpl(mock(PersistenceManagerUtil.class), mock(AlarmQueue.class)); m_standardModelRegistrator = new StandardModelRegistrator(m_notificationService, alarmService, m_registry); m_standardModelRegistrator.onDeployed(m_deviceAdapter, m_adapterContext); verify(m_notificationService, times(1)).registerCallBack(infoCaptor.capture()); NotificationCallBackInfo callbackInfo1 = (NotificationCallBackInfo) infoCaptor.getValue().get(0); context.put(DeviceAdapterId.class.getSimpleName(), m_deviceAdapterId); assertTrue(callbackInfo1.getNotificationApplicableCheck().isApplicable(context)); List<NotificationCallBackInfo> notificationCallBackInfos = new ArrayList<>(); notificationCallBackInfos.add(callbackInfo1); when(m_notificationService.getNotificationCallBacks()).thenReturn(notificationCallBackInfos); List<YangTextSchemaSource> yangFiles = getYangFiles(); m_registry.buildSchemaContext(yangFiles, Collections.emptySet(), Collections.emptyMap()); m_standardModelRegistrator.onDeployed(m_deviceAdapter, m_adapterContext); verify(m_notificationService, times(1)).registerCallBack(infoCaptor.capture()); }