ChannelServiceImpl implements ChannelService { public void register(AbstractChannelType channelType) { ParameterCheck.mandatory("channelType", channelType); String id = channelType.getId(); if (channelTypes.containsKey(id)) { throw new IllegalArgumentException("Channel type " + id + " is already registered!"); } channelTypes.put(id, channelType); }  void setNodeService(NodeService nodeService); void setDictionaryService(DictionaryService dictionaryService); void setPublishingRootObject(PublishingRootObject rootObject); void setChannelHelper(ChannelHelper channelHelper); void setEncryptor(MetadataEncryptor encryptor); void register(AbstractChannelType channelType); List<ChannelType> getChannelTypes(); Channel createChannel(String channelTypeId, String name, Map<QName, Serializable> properties); void deleteChannel(Channel channel); List<Channel> getChannels(); @Override Channel getChannelByName(String channelName); List<Channel> getRelevantPublishingChannels(NodeRef nodeToPublish); List<Channel> getPublishingChannels(boolean filterByPublishPermission); List<Channel> getStatusUpdateChannels(boolean filterByPublishPermission); List<Channel> getAuthorisedStatusUpdateChannels(); ChannelType getChannelType(String id); void renameChannel(Channel channel, String newName); void updateChannel(Channel channel, Map<QName, Serializable> properties); Channel getChannelById(String id); static final String NAME; }
@Test public void testRegister() { List<ChannelType> types = channelService.getChannelTypes(); assertTrue(types.contains(mockChannelType)); channelService.getChannelType(MockChannelType.ID); try { channelService.register(null); fail("Exception expected when calling register(null)"); } catch(IllegalArgumentException e) { } try { channelService.register(mockChannelType); fail("Exception expected when trying to register the same ChannelType twice"); } catch(IllegalArgumentException e) { } }