@Test public void shouldRegisterChannelFromChannelRequest() { List<ActionEventRequest> actionEventRequests = asList(new TestActionEventRequestBuilder().setDisplayName("actionName") .setSubject("subject.foo").setDescription("action description").setServiceInterface("some.interface") .setServiceMethod("method").setActionParameters(new TreeSet<ActionParameterRequest>()) .setPostActionParameters(new TreeSet<ActionParameterRequest>()).createActionEventRequest()); List<TriggerEventRequest> triggerEventsRequest = asList(new TriggerEventRequest("displayName", "subject.foo", "description", asList(new EventParameterRequest("displayName", "eventKey")))); ChannelRequest channelRequest = new ChannelRequest(BUNDLE_SYMBOLIC_NAME, BUNDLE_SYMBOLIC_NAME, VERSION, "", triggerEventsRequest, actionEventRequests); channelService.registerChannel(channelRequest); ArgumentCaptor<Channel> captor = ArgumentCaptor.forClass(Channel.class); verify(channelsDataService).create(captor.capture()); Channel channelToBeCreated = captor.getValue(); assertEquals(BUNDLE_SYMBOLIC_NAME, channelToBeCreated.getDisplayName()); assertEquals(BUNDLE_SYMBOLIC_NAME, channelToBeCreated.getModuleName()); assertEquals(VERSION, channelToBeCreated.getModuleVersion()); assertEquals(1, channelToBeCreated.getTriggerTaskEvents().size()); TriggerEvent expectedTrigger = new TriggerEvent("displayName", "subject.foo", "description", asList(new EventParameter("displayName", "eventKey")), ""); TriggerEvent actualTrigger = channelToBeCreated.getTriggerTaskEvents().get(0); assertEquals(expectedTrigger, actualTrigger); assertEquals(1, channelToBeCreated.getActionTaskEvents().size()); ActionEvent expectedAction = new ActionEventBuilder().setDisplayName("actionName").setSubject("subject.foo") .setDescription("action description").setServiceInterface("some.interface").setServiceMethod("method") .setActionParameters(new TreeSet<>()).setPostActionParameters(new TreeSet<>()).build(); ActionEvent actualAction = channelToBeCreated.getActionTaskEvents().get(0); assertEquals(expectedAction, actualAction); }
@Override @Transactional public void registerChannel(ChannelRequest channelRequest) { LOGGER.info("Registering channel: {}", channelRequest.getModuleName()); addOrUpdate(ChannelBuilder.fromChannelRequest(channelRequest).build()); }
ChannelServiceImpl implements ChannelService { @Override @Transactional public void registerChannel(ChannelRequest channelRequest) { LOGGER.info("Registering channel: {}", channelRequest.getModuleName()); addOrUpdate(ChannelBuilder.fromChannelRequest(channelRequest).build()); } }
ChannelServiceImpl implements ChannelService { @Override @Transactional public void registerChannel(ChannelRequest channelRequest) { LOGGER.info("Registering channel: {}", channelRequest.getModuleName()); addOrUpdate(ChannelBuilder.fromChannelRequest(channelRequest).build()); } @Autowired  ChannelServiceImpl(TriggerEventService triggerEventService, ChannelsDataService channelsDataService, EventRelay eventRelay); }
ChannelServiceImpl implements ChannelService { @Override @Transactional public void registerChannel(ChannelRequest channelRequest) { LOGGER.info("Registering channel: {}", channelRequest.getModuleName()); addOrUpdate(ChannelBuilder.fromChannelRequest(channelRequest).build()); } @Autowired  ChannelServiceImpl(TriggerEventService triggerEventService, ChannelsDataService channelsDataService, EventRelay eventRelay); @Override @Transactional void registerChannel(ChannelRequest channelRequest); @Override @Transactional void unregisterChannel(String moduleName); @Override @Transactional void registerChannel(final InputStream stream, String moduleName, String moduleVersion); @Override @Transactional synchronized void addOrUpdate(final Channel channel); @Override @Transactional synchronized void delete(final String moduleName); @Override @Transactional List<Channel> getAllChannels(); @Override @Transactional Channel getChannel(final String moduleName); @Override @Transactional boolean channelExists(String moduleName); @Autowired(required = false) void setBundleContext(BundleContext bundleContext); }
ChannelServiceImpl implements ChannelService { @Override @Transactional public void registerChannel(ChannelRequest channelRequest) { LOGGER.info("Registering channel: {}", channelRequest.getModuleName()); addOrUpdate(ChannelBuilder.fromChannelRequest(channelRequest).build()); } @Autowired  ChannelServiceImpl(TriggerEventService triggerEventService, ChannelsDataService channelsDataService, EventRelay eventRelay); @Override @Transactional void registerChannel(ChannelRequest channelRequest); @Override @Transactional void unregisterChannel(String moduleName); @Override @Transactional void registerChannel(final InputStream stream, String moduleName, String moduleVersion); @Override @Transactional synchronized void addOrUpdate(final Channel channel); @Override @Transactional synchronized void delete(final String moduleName); @Override @Transactional List<Channel> getAllChannels(); @Override @Transactional Channel getChannel(final String moduleName); @Override @Transactional boolean channelExists(String moduleName); @Autowired(required = false) void setBundleContext(BundleContext bundleContext);  }