@Test public void testHandleMessage() throws Exception { long testBlogId = 2; BlogManagement blogManagement = createMock(BlogManagement.class); blogManagement.deleteBlog(testBlogId, null); replay(blogManagement); BaseTopic topic = new BaseTopic(); topic.setTopicId(testBlogId); DeleteTopicMessage message = new DeleteTopicMessage(); message.setTopic(topic); DeleteTopicMessageHandler handler = new DeleteTopicMessageHandler(); handler.setBlogManagement(blogManagement); handler.handleMessage(message); verify(blogManagement); }
@Override public CommunoteReplyMessage handleMessage(DeleteTopicMessage message) throws NoteManagementAuthorizationException, BlogNotFoundException, BlogAccessException { validateMessage(message); try { getBlogManagement().deleteBlog(TopicUtils.getTopicId(message.getTopic()), null); } catch (NoteManagementAuthorizationException | BlogAccessException e) { LOG.error("The Blog (\"" + message.getTopic().getTopicAlias() + "\") cannot be removed, since the user is not the manager of the blog. "); throw e; } catch (BlogNotFoundException e) { LOG.error("The Blog to be deleted could not be found.", e); throw e; } return null; }
DeleteTopicMessageHandler extends CommunoteMessageHandler<DeleteTopicMessage> { @Override public CommunoteReplyMessage handleMessage(DeleteTopicMessage message) throws NoteManagementAuthorizationException, BlogNotFoundException, BlogAccessException { validateMessage(message); try { getBlogManagement().deleteBlog(TopicUtils.getTopicId(message.getTopic()), null); } catch (NoteManagementAuthorizationException | BlogAccessException e) { LOG.error("The Blog (\"" + message.getTopic().getTopicAlias() + "\") cannot be removed, since the user is not the manager of the blog. "); throw e; } catch (BlogNotFoundException e) { LOG.error("The Blog to be deleted could not be found.", e); throw e; } return null; } }
DeleteTopicMessageHandler extends CommunoteMessageHandler<DeleteTopicMessage> { @Override public CommunoteReplyMessage handleMessage(DeleteTopicMessage message) throws NoteManagementAuthorizationException, BlogNotFoundException, BlogAccessException { validateMessage(message); try { getBlogManagement().deleteBlog(TopicUtils.getTopicId(message.getTopic()), null); } catch (NoteManagementAuthorizationException | BlogAccessException e) { LOG.error("The Blog (\"" + message.getTopic().getTopicAlias() + "\") cannot be removed, since the user is not the manager of the blog. "); throw e; } catch (BlogNotFoundException e) { LOG.error("The Blog to be deleted could not be found.", e); throw e; } return null; }  }
DeleteTopicMessageHandler extends CommunoteMessageHandler<DeleteTopicMessage> { @Override public CommunoteReplyMessage handleMessage(DeleteTopicMessage message) throws NoteManagementAuthorizationException, BlogNotFoundException, BlogAccessException { validateMessage(message); try { getBlogManagement().deleteBlog(TopicUtils.getTopicId(message.getTopic()), null); } catch (NoteManagementAuthorizationException | BlogAccessException e) { LOG.error("The Blog (\"" + message.getTopic().getTopicAlias() + "\") cannot be removed, since the user is not the manager of the blog. "); throw e; } catch (BlogNotFoundException e) { LOG.error("The Blog to be deleted could not be found.", e); throw e; } return null; }  @Override Class<DeleteTopicMessage> getHandledMessageClass(); @Override String getVersion(); @Override CommunoteReplyMessage handleMessage(DeleteTopicMessage message); boolean isTopicIdentifierAvailble(BaseTopic topic); void validateMessage(DeleteTopicMessage message); }
DeleteTopicMessageHandler extends CommunoteMessageHandler<DeleteTopicMessage> { @Override public CommunoteReplyMessage handleMessage(DeleteTopicMessage message) throws NoteManagementAuthorizationException, BlogNotFoundException, BlogAccessException { validateMessage(message); try { getBlogManagement().deleteBlog(TopicUtils.getTopicId(message.getTopic()), null); } catch (NoteManagementAuthorizationException | BlogAccessException e) { LOG.error("The Blog (\"" + message.getTopic().getTopicAlias() + "\") cannot be removed, since the user is not the manager of the blog. "); throw e; } catch (BlogNotFoundException e) { LOG.error("The Blog to be deleted could not be found.", e); throw e; } return null; }  @Override Class<DeleteTopicMessage> getHandledMessageClass(); @Override String getVersion(); @Override CommunoteReplyMessage handleMessage(DeleteTopicMessage message); boolean isTopicIdentifierAvailble(BaseTopic topic); void validateMessage(DeleteTopicMessage message);  }