OrientBrowseNodeEventHandler implements EventAware, EventAware.Asynchronous { @Subscribe @AllowConcurrentEvents public void on(final AssetCreatedEvent event) { handle(event, e -> browseNodeManager.createFromAsset(e.getRepositoryName(), e.getAsset())); } @Inject  OrientBrowseNodeEventHandler(final OrientBrowseNodeManager browseNodeManager); @Subscribe @AllowConcurrentEvents void on(final AssetCreatedEvent event); @Subscribe @AllowConcurrentEvents void on(final AssetUpdatedEvent event); @Subscribe void on(final AssetDeletedEvent event); @Subscribe void on(final ComponentDeletedEvent event); @Subscribe @AllowConcurrentEvents void on(final ConfigurationDeletedEvent event);  }
@Test public void onAssetCreated() { Asset asset = new Asset(); AssetCreatedEvent event = mock(AssetCreatedEvent.class); when(event.getAsset()).thenReturn(asset); when(event.getRepositoryName()).thenReturn(REPOSITORY_NAME); when(event.isLocal()).thenReturn(true); handler.on(event); verify(browseNodeManager).createFromAsset(REPOSITORY_NAME, asset); }
@Test public void onAssetCreated_remote() { AssetCreatedEvent event = mock(AssetCreatedEvent.class); when(event.isLocal()).thenReturn(false); handler.on(event); verify(browseNodeManager, never()).createFromAsset(any(), any()); }
@Test public void onAssetDeleted() { Asset asset = mock(Asset.class); AssetDeletedEvent event = mock(AssetDeletedEvent.class); when(event.getAsset()).thenReturn(asset); when(event.isLocal()).thenReturn(true); handler.on(event); verify(browseNodeManager).deleteAssetNode(asset); }
@Test public void onAssetDeleted_remote() { AssetDeletedEvent event = mock(AssetDeletedEvent.class); when(event.isLocal()).thenReturn(false); handler.on(event); verify(browseNodeManager, never()).deleteAssetNode(any()); }
@Test public void onConfigurationDeleted() { ConfigurationDeletedEvent event = mock(ConfigurationDeletedEvent.class); when(event.isLocal()).thenReturn(true); when(event.getRepositoryName()).thenReturn(REPOSITORY_NAME); handler.on(event); verify(browseNodeManager).deleteByRepository(REPOSITORY_NAME); }
@Test public void onConfigurationDeleted_remote() { ConfigurationDeletedEvent event = mock(ConfigurationDeletedEvent.class); when(event.isLocal()).thenReturn(false); handler.on(event); verify(browseNodeManager, never()).deleteByRepository(any()); }