private UserService userService;
@Test
public void testInsertBlog() throws Exception {
// upgrader should have inserted first post
BlogPost firstPost = blogService.getLatestPost();
Assert.assertNotNull(firstPost);
User user = new User();
user.setUsername("test_user_" + System.currentTimeMillis());
user.setName("Test user");
user.setRole(UserRole.WRITER);
userService.saveUser(user, "secret");
BlogPost newPost = new BlogPost();
newPost.setAuthor(user);
newPost.setPosted(new Date());
newPost.setTitle("Test title");
newPost.setText("This is a test post.");
blogService.savePost(newPost);
BlogPost latestPost = blogService.getLatestPost();
Assert.assertNotSame(firstPost.getId(), latestPost.getId());
Assert.assertEquals(newPost.getId(), latestPost.getId());
}